| View previous topic :: View next topic |
| Author |
Message |
vdshalotank Newbie
Joined: 06 Oct 2006 Posts: 5
|
Posted: Fri Oct 06, 2006 6:17 pm Post subject: Saving Variables then Opening them. |
|
|
I'm sure there is a topic about this, but I'm unable to find it, so I need ya'll's help.
Alright, I'm working on a "Record Book", to hold information about people, and when you save, this is the code I use:
| Code: |
list create,1
list add,1,%%name
list add,1,%%last_name
%%outfile = @filedlg("Record Book File (*.rec)|*.rec",,,SAVE)
list savefile,1,%%outfile
list close,1
|
It saves just fine, but how would I got about opening it?
Thanks in advance,
Steven DeYoung
EDIT: Actually, it doesn't save correctly either, it makes the file, but the file remains blank, anyone that can shed some light on this situation? |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Fri Oct 06, 2006 10:58 pm Post subject: |
|
|
| Quote: | list create,1
list add,1,%%name
list add,1,%%last_name
%%outfile = @filedlg("Record Book File (*.rec)|*.rec",,,SAVE)
list savefile,1,%%outfile
list close,1 |
To open a file use
LIST CREATE,<list>
LIST LOADFILE,<list>,<filetoload>
Now you can read the data in <list>.
Welcome to VDS  |
|
| Back to top |
|
 |
vdshalotank Newbie
Joined: 06 Oct 2006 Posts: 5
|
Posted: Fri Oct 06, 2006 11:45 pm Post subject: |
|
|
Thanks for the welcome haha.
But, why is it not saving correctly? |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Oct 07, 2006 5:41 am Post subject: |
|
|
Depends on what you mean by "not saving correctly"?
If you haven't created a dialog the @filedlg function will give an error.
Your example code is not giving the saved file an extension - unless the user specifies one.
You're adding the firstname and surname as separate entries in the list.
Plus, unless this program is only going to be used by you, the use of the rec extension may cause problems for some users, as the rec extension seen by some video player (and decoding/encoding) software as a video file.
| Code: | DIALOG CREATE,Add Entry,-1,0,285,125
DIALOG ADD,TEXT,TEXT1,20,14,,,First Name
DIALOG ADD,EDIT,EDIT1,17,84,180,19
DIALOG ADD,TEXT,TEXT2,46,15,51,13,Surname
DIALOG ADD,EDIT,EDIT2,44,84,180,19
DIALOG ADD,BUTTON,Add,82,72,64,24,Add
DIALOG ADD,BUTTON,Save,82,145,64,24,Save
DIALOG SHOW
list create,1
:evloop
wait event
goto @event()
:AddBUTTON
%%name = @dlgtext(edit1)
%%last_name = @dlgtext(edit2)
# check here if first name and surname edit boxes not empty
list add,1,%%name @tab() %%last_name
dialog set,edit1
dialog set,edit2
dialog focus,edit1
goto evloop
:SaveBUTTON
# using rbf file extension - i.e for 'R'ecord 'B'ook 'F'ile
%%outfile = @filedlg("Record Book File (*.rbf)|*.rbf",,,SAVE)
if @equal(@ext(%%outfile),rbf)
list savefile,1,%%outfile
else
list savefile,1,%%outfile.rbf
end
list close,1
:Close
stop
|
_________________ cheers
Dave |
|
| Back to top |
|
 |
vdshalotank Newbie
Joined: 06 Oct 2006 Posts: 5
|
Posted: Sat Oct 07, 2006 1:05 pm Post subject: |
|
|
Thank you very much Dave, and what I meant by "not saving correctly" was that it would save the file, but nothing would be in it.
Many Thanks,
Steven DeYoung
EDIT: What exactly does your add button do?
EDIT: Ah, it adds the item to the list. |
|
| Back to top |
|
 |
vdshalotank Newbie
Joined: 06 Oct 2006 Posts: 5
|
Posted: Sat Oct 07, 2006 2:15 pm Post subject: |
|
|
Now, how would I go about opening the vars into the file, this is the current code I have:
| Code: |
DIALOG SET,STATUS1,"Record Opened
%%outfile = @filedlg("Record Book File (*.rbf)|*.rbf",Open File)
LIST LOADFILE,1,%%outfile
DIALOG SET,EDIT1,%%name
DIALOG SET,EDIT2,%%lastname
DIALOG SET,STATUS1,"Record Opened"
end
LIST CLOSE,1
goto evloop |
EDIT:
And if it helps, the save code:
| Code: | :Save RecordMENU
DIALOG SET,STATUS1,"Record Saved"
%%name = @dlgtext(edit1)
%%last_name = @dlgtext(edit2)
# check here if first name and surname edit boxes not empty
list add,1,%%name @tab() %%last_name
%%outfile = @filedlg("Record Book File (*.rbf)|*.rbf",,,SAVE)
if @equal(@ext(%%outfile),rbf)
list savefile,1,%%outfile
else
list savefile,1,%%outfile.rbf
end
list close,1
goto evloop |
|
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Oct 07, 2006 2:52 pm Post subject: |
|
|
This would show the first item in the list:
| Code: | list seek,1,0
option fieldsep, @tab()
parse "%%name;%%lastname",@item(1)
DIALOG SET,EDIT1,%%name
DIALOG SET,EDIT2,%%lastname
|
Since your list contains all the items in the file you need to seek to the item you want to display.
You're going to need to display the list in a table if you want to see all the items at once. _________________ cheers
Dave
Last edited by DaveR on Sat Oct 07, 2006 2:53 pm; edited 1 time in total |
|
| Back to top |
|
 |
vdshalotank Newbie
Joined: 06 Oct 2006 Posts: 5
|
Posted: Sat Oct 07, 2006 2:53 pm Post subject: |
|
|
| Ah, thank you a million Dave. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|