JDog37
12-25-2008, 06:21 AM
I used 3 diffrent examples for a planner I made for my wife, (Thanks to all of you) and on the 3rd page I wanted for her to be able to save her favorite photos. Well the only problem I can find is it will let me save them but it will only allow like 3 or 4 then it wont add anymore????:huh
Page: On show -
db = SQLite.Open("Autoplay\\docs\\images.db")
if db then
tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")
else
Dialog.Message("Error", _tblErrorMessages[Application.GetLastError()])
end
if tblQ then
ListBox.DeleteItem("ListBox1", -1)
for n=1, tblQ.Rows do
ListBox.AddItem("ListBox1", tblQ.Data[n]["Image_Title"], n)
end
end
The list box: On select - Selected = ListBox.GetSelected("ListBox1")
if Selected then
x = String.ToNumber(ListBox.GetItemData("ListBox1", Selected[1]))
Image_Data = tblQ.Data[x]["Image"]
Image_ID = tblQ.Data[x]["ImageID"]
local Image_File = _TempFolder.."\\IMG.jpg"
Crypto.Base64DecodeFromString(Image_Data, Image_File)
Image.Load("Image1", Image_File)
Image.SetVisible("Image1", true)
Button.SetEnabled("Button2", true)
end
The add photo btn: On click -
local Image_File = Dialog.FileBrowse(true, "Select Image File", "", "Jpeg Files (*.jpg)|*.jpg|" , "", "")
if Image_File ~= "CANCEL" then
encoded_image = Crypto.Base64EncodeToString(Image_File[1], 0);
-- Check to see if an error occurred using the Crypto.Base64EncodeToString action.
error = Application.GetLastError();
if (error ~=0) then
result = Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
return
end
if encoded_image == "" then
Dialog.Message("Sorry", "Could not encode image file", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
return
end
Image_Title = Dialog.Input("Image Title", "Please enter a title for this image", "My Cool Image", MB_ICONQUESTION)
if Image_Title == "CANCEL" or Image_Title == "" then
Image_Title = "My Cool Image"
end
SQLite.Query(db, "Insert into Images Values(Null, \"" .. encoded_image .. "\", '" .. Image_Title .. "')")
tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")
if tblQ then
ListBox.DeleteItem("ListBox1", -1)
for n=1, tblQ.Rows do
ListBox.AddItem("ListBox1", tblQ.Data[n]["Image_Title"], n)
end
end
end
Clear btn: On click -
if Selected then
SQLite.Query(db, "DELETE FROM Images WHERE ImageID="..Image_ID)
tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")
if tblQ then
ListBox.DeleteItem("ListBox1", -1)
for r=1, tblQ.Rows do
ListBox.AddItem("ListBox1", tblQ.Data[r]["Image_Title"], r)
Progress.SetCurrentPos("Progress1", r)
end
end
Button.SetEnabled("Button2", false)
Image.SetVisible("Image1", false)
end
I cant figure it out, because I'm not a programing wiz, but I like to tinker around.. With that said, I don't know how to debunk it.
Can anyone please help me??
All I want is to be able to add as many photos as I want..! :rolleyes
Thanks,
Joe
Ps. The .apz is like 4mb, so I can't upload it unfortunately...
Page: On show -
db = SQLite.Open("Autoplay\\docs\\images.db")
if db then
tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")
else
Dialog.Message("Error", _tblErrorMessages[Application.GetLastError()])
end
if tblQ then
ListBox.DeleteItem("ListBox1", -1)
for n=1, tblQ.Rows do
ListBox.AddItem("ListBox1", tblQ.Data[n]["Image_Title"], n)
end
end
The list box: On select - Selected = ListBox.GetSelected("ListBox1")
if Selected then
x = String.ToNumber(ListBox.GetItemData("ListBox1", Selected[1]))
Image_Data = tblQ.Data[x]["Image"]
Image_ID = tblQ.Data[x]["ImageID"]
local Image_File = _TempFolder.."\\IMG.jpg"
Crypto.Base64DecodeFromString(Image_Data, Image_File)
Image.Load("Image1", Image_File)
Image.SetVisible("Image1", true)
Button.SetEnabled("Button2", true)
end
The add photo btn: On click -
local Image_File = Dialog.FileBrowse(true, "Select Image File", "", "Jpeg Files (*.jpg)|*.jpg|" , "", "")
if Image_File ~= "CANCEL" then
encoded_image = Crypto.Base64EncodeToString(Image_File[1], 0);
-- Check to see if an error occurred using the Crypto.Base64EncodeToString action.
error = Application.GetLastError();
if (error ~=0) then
result = Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
return
end
if encoded_image == "" then
Dialog.Message("Sorry", "Could not encode image file", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
return
end
Image_Title = Dialog.Input("Image Title", "Please enter a title for this image", "My Cool Image", MB_ICONQUESTION)
if Image_Title == "CANCEL" or Image_Title == "" then
Image_Title = "My Cool Image"
end
SQLite.Query(db, "Insert into Images Values(Null, \"" .. encoded_image .. "\", '" .. Image_Title .. "')")
tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")
if tblQ then
ListBox.DeleteItem("ListBox1", -1)
for n=1, tblQ.Rows do
ListBox.AddItem("ListBox1", tblQ.Data[n]["Image_Title"], n)
end
end
end
Clear btn: On click -
if Selected then
SQLite.Query(db, "DELETE FROM Images WHERE ImageID="..Image_ID)
tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")
if tblQ then
ListBox.DeleteItem("ListBox1", -1)
for r=1, tblQ.Rows do
ListBox.AddItem("ListBox1", tblQ.Data[r]["Image_Title"], r)
Progress.SetCurrentPos("Progress1", r)
end
end
Button.SetEnabled("Button2", false)
Image.SetVisible("Image1", false)
end
I cant figure it out, because I'm not a programing wiz, but I like to tinker around.. With that said, I don't know how to debunk it.
Can anyone please help me??
All I want is to be able to add as many photos as I want..! :rolleyes
Thanks,
Joe
Ps. The .apz is like 4mb, so I can't upload it unfortunately...