Saving error between test and Device
Posted: Sat Mar 15, 2014 5:01 pm
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