Saving error between test and Device
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Saving error between test and Device
Hello,
when I run the below script while testing the app on my MAC (not in the simulator) it saves the entries correctly; however when I delay the app to my phone it saves apparently replace the saved entry with the new entry.
I'm at my wits end on this.
on saveitem
global gData
put the long time into tTime
put the date into tDate
convert the date && the time to seconds
put it into tCtime
set itemDel to tab
put specialFolderPath("documents") & "/ItemList.txt" into tFile
get the number of lines of tFile
answer it
if there is a file tFile then
put url ("file:" & specialFolderPath("documents") & "/ItemList.txt") into tSavedFile
ELSE
put EMPTY into tSavedFile
end if
put the number of lines in tSavedFile + 1 into tNextFileNumber
answer tNextFileNumber
get field "ItemName"
put it into tTitle
if it is empty then
answer error "An Item Name is Required"
exit top
end if
put tTitle into item 2 of line tNextFileNumber of tSavedFile
get field "ItemDesc"
if it is empty then
Put "No Description" into it
end if
put it into item 3 of line tNextFileNumber of tSavedFile
get field "Date"
if it is empty then
put "No Date" into it
put "No Date" into field "Date"
end if
put it into item 4 of line tNextFileNumber of tSavedFile
get field "CatMain"
if it is empty then
put "No Category" into it
end if
put it into item 5 of line tNextFileNumber of tSavedFile
get field "Lat"
if it is empty then
put "Not Lat" into it
end if
put it into item 6 of line tNextFileNumber of tSavedFile
get field "long"
if it is empty then
put "No Long" into it
end if
put it into item 7 of line tNextFileNumber of tSavedFile
put the long time into tTime
put the date into tDate
--put specialFolderPath("documents") into appPath
if image "itemPic1" is empty
then
put "No Picture" into item 8 of line tNextFileNumber of tSavedFile
put "No Picture" into tImageID
else
put the long ID of image "itemPic1" into tImageID
mobileExportImageToAlbum tImageID
if image "itemPic3" is not empty then
put the long ID of image "itemPic3" into tImageID
mobileExportImageToAlbum tImageID
else
end if
put the long id of image "itemPic1" into tImageID
put tImageID into item 8 of line tNextFileNumber of tSavedFile
end if
put the hilited of button "HIgh Rank" into item 9 of line tNextFileNumber of tSavedFile
put the hilited of button "Med Rank" into item 10 of line tNextFileNumber of tSavedFile
put the hilited of button "Low Rank" into item 11 of line tNextFileNumber of tSavedFile
put the hilited of button "save Location" into item 12 of line tNextFileNumber of tSavedFile
put tdate into item 13 of line tNextFileNumber of tSavedFile
put tTime into item 14 of line tNextFileNumber of tSavedFile
convert the date && the time to seconds
put it into item 1 of line tNextFileNumber of tSavedFile
put it into field "seq Numb"
get field "price"
if it is empty then
put "No Price" into it
end if
put it into item 15 of line tNextFileNumber of tSavedFile
--answer tSavedFile
put tSavedFile into URL ("file:" & specialFolderPath("documents") & "/itemlist.txt")
end save item
Thank you
Ty
when I run the below script while testing the app on my MAC (not in the simulator) it saves the entries correctly; however when I delay the app to my phone it saves apparently replace the saved entry with the new entry.
I'm at my wits end on this.
on saveitem
global gData
put the long time into tTime
put the date into tDate
convert the date && the time to seconds
put it into tCtime
set itemDel to tab
put specialFolderPath("documents") & "/ItemList.txt" into tFile
get the number of lines of tFile
answer it
if there is a file tFile then
put url ("file:" & specialFolderPath("documents") & "/ItemList.txt") into tSavedFile
ELSE
put EMPTY into tSavedFile
end if
put the number of lines in tSavedFile + 1 into tNextFileNumber
answer tNextFileNumber
get field "ItemName"
put it into tTitle
if it is empty then
answer error "An Item Name is Required"
exit top
end if
put tTitle into item 2 of line tNextFileNumber of tSavedFile
get field "ItemDesc"
if it is empty then
Put "No Description" into it
end if
put it into item 3 of line tNextFileNumber of tSavedFile
get field "Date"
if it is empty then
put "No Date" into it
put "No Date" into field "Date"
end if
put it into item 4 of line tNextFileNumber of tSavedFile
get field "CatMain"
if it is empty then
put "No Category" into it
end if
put it into item 5 of line tNextFileNumber of tSavedFile
get field "Lat"
if it is empty then
put "Not Lat" into it
end if
put it into item 6 of line tNextFileNumber of tSavedFile
get field "long"
if it is empty then
put "No Long" into it
end if
put it into item 7 of line tNextFileNumber of tSavedFile
put the long time into tTime
put the date into tDate
--put specialFolderPath("documents") into appPath
if image "itemPic1" is empty
then
put "No Picture" into item 8 of line tNextFileNumber of tSavedFile
put "No Picture" into tImageID
else
put the long ID of image "itemPic1" into tImageID
mobileExportImageToAlbum tImageID
if image "itemPic3" is not empty then
put the long ID of image "itemPic3" into tImageID
mobileExportImageToAlbum tImageID
else
end if
put the long id of image "itemPic1" into tImageID
put tImageID into item 8 of line tNextFileNumber of tSavedFile
end if
put the hilited of button "HIgh Rank" into item 9 of line tNextFileNumber of tSavedFile
put the hilited of button "Med Rank" into item 10 of line tNextFileNumber of tSavedFile
put the hilited of button "Low Rank" into item 11 of line tNextFileNumber of tSavedFile
put the hilited of button "save Location" into item 12 of line tNextFileNumber of tSavedFile
put tdate into item 13 of line tNextFileNumber of tSavedFile
put tTime into item 14 of line tNextFileNumber of tSavedFile
convert the date && the time to seconds
put it into item 1 of line tNextFileNumber of tSavedFile
put it into field "seq Numb"
get field "price"
if it is empty then
put "No Price" into it
end if
put it into item 15 of line tNextFileNumber of tSavedFile
--answer tSavedFile
put tSavedFile into URL ("file:" & specialFolderPath("documents") & "/itemlist.txt")
end save item
Thank you
Ty
Re: Saving error between test and Device
I actually fooled around with this for a minute. You have a typo at the "end" line. Lose that space.
You (or I) am missing the handler "mobileExportImageToAlbum tImageID". But not sure this is your problem. The handler runs fine in the IDE, as you noted.
When you make the standalone, are you sure you are not trying to save the executable? I am not sure what you meant in your description. Most errors are that the standalone will not save at all. You must have another stack file attached to the executable, and save there. Your description sort of indicates the opposite, though I probably do not understand.
Someone more adept with mobil will chime in soon. But note that long handlers are daunting to analyse. Good luck...
Craig Newman
You (or I) am missing the handler "mobileExportImageToAlbum tImageID". But not sure this is your problem. The handler runs fine in the IDE, as you noted.
When you make the standalone, are you sure you are not trying to save the executable? I am not sure what you meant in your description. Most errors are that the standalone will not save at all. You must have another stack file attached to the executable, and save there. Your description sort of indicates the opposite, though I probably do not understand.
Someone more adept with mobil will chime in soon. But note that long handlers are daunting to analyse. Good luck...
Craig Newman
Re: Saving error between test and Device
The handler could be considerably condensed, but that's another topic.
I see two issues. One is what Craig spotted -- the last line has an extra space. Change it to "end saveItem".
The second issue, which is more likely to be the cause, is that desktop machines are not case-sensitive but mobile devices are. The handler looks for a file named "ItemList.txt" (capital "I") but saves the content to a file named "itemList.txt" (lower-case "i"). I'm thinking you have two files on your mobile device after the handler runs.
I see two issues. One is what Craig spotted -- the last line has an extra space. Change it to "end saveItem".
The second issue, which is more likely to be the cause, is that desktop machines are not case-sensitive but mobile devices are. The handler looks for a file named "ItemList.txt" (capital "I") but saves the content to a file named "itemList.txt" (lower-case "i"). I'm thinking you have two files on your mobile device after the handler runs.
Last edited by jacque on Sat Mar 15, 2014 11:21 pm, edited 1 time in total.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: Saving error between test and Device
Thanks, but even with the suggestions it is still not saving correctly. Sorry about the description it should have been when I "deploy" not "delay" ...
I'll keep digging and I'll update you.
Thank you
Ty
I'll keep digging and I'll update you.
Thank you
Ty
Re: Saving error between test and Device
Hi Ty,
Jacque was right but left a test.
ItemList.txt
Capital "I" Capital "L"
Working here.
Simon
Jacque was right but left a test.
ItemList.txt
Capital "I" Capital "L"
Working here.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Saving error between test and Device
Sharp eyes, Simon.Simon wrote:Capital "I" Capital "L"

Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Saving error between test and Device
Elephants have trunks, Camels have cases 
Simon

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: Saving error between test and Device
Very sharp eyes, Thank you all so much.
Ty
Ty