Simon wrote:Hi Tom,
I've been posting this a bunch
http://forums.runrev.com/phpBB2/viewtop ... ce#p103136
Grab that myPlants stack.
Study where I put the files and after you have added some images and descriptions look at the Preference.txt file. (Watch out large images >5mb take a while to load). A lot of the code in it is really only used once to create a new file.
Everything is there to show you how to create your own preference file.
If you get stuck just ask
Simon
Edit: OK a bit more info just in case I'm being a smarty pants. The text file will be save in a subfolder of your Documents folder "myPlants" and I use tab as an item delimeter (note: set itemDel to tab). The stack works correctly on the desktop and mobile.
Edit 2: I didn't plan for returns (cr, crlf etc.) in the description field... it may break on that.
Simon,
I don't need images so I have tried to delete all image related code fro your Myplants stack.
I only need 5 text lines of code and never more than that. I have assumed (probably naively) that a simple text file can be used for this purpose.
Here is the code for the card that attempts to implement this:
on preOpenCard
--check to make sure your folder exists
if there is not a directory (specialFolderPath("documents") & "/sellnet") then
create folder (specialFolderPath("documents") & "/sellnet")
else
end if
set the defaultFolder to (specialFolderPath("documents") & "/sellnet")
--load your Preference file into memory
put url("file:tAgent.txt") into tfile
end preOpenCard
on openCard
set itemDel to tab
if tfile <> empty then
-- this will tell us to load the last image into this cd
#put the number of lines of gPref into gCount I left this out because there there only needs to be 1 page.
put line 1 of tfile into fld "Aname"
put line 2 of tfile into fld "Aoffice"
put line 3 of tfile into fld "Acell"
put line 4 of tfile into fld "officep"
put line 5 of tfile into fld "Aemail"
else
end if
if fld "begin" of card 1 ="T"
then
put "F" into fld "begin" of card 1
go card 1
end if
end openCard
The begin fld on card 1 is a flag I set.
When the app is first started it = "T" and on open card 1 is sent to this card to populate the 5 fields on card 5 with the stored values in the text file.
there is a button on card 1 that sends the user to card 5 allowing them to edit or enter the data in the fields.
In this case after entering all data there is a "Finished" button with the following code:
on mouseUp
put fld "Aname" into tvar
put tvar into line 1 of tfile
put fld "Aoffice" into tvar
put tvar into line 2 of tfile
put fld "acell" into tvar
put tvar into line 3 of tfile
put fld "officep" into tvar
put tvar into line 4 of tfile
put fld "Aemail" into tvar
put tvar into line 5 of tfile
go card 1
end mouseUp