Storing information from database in an array

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Babyprincess
Posts: 17
Joined: Sat Aug 10, 2013 3:23 pm

Storing information from database in an array

Post by Babyprincess » Wed Aug 14, 2013 5:14 pm

Hello,

I have information in my database. I would wish to store them in an array. After which i would like to loop them to perform a particular function. Any idea how i can do it ?

Thank you (:

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Storing information from database in an array

Post by dunbarx » Wed Aug 14, 2013 5:39 pm

Hi.

Any reason to store the data in an array? If the data is already intact, why not just work with it in the clear?

You should practice just a little with arrays, though there is nothing wrong with using your database info to get going. Arrays are very useful in that they are compact and powerful tools to assemble and disassemble data. But you already have your data "assembled", so to speak.

Anyway, what is it that you wish to do with your data? Since it is likely in tab and return delimited format, you can perform any task you wish, using the tab as an item delimiter and return as the record delimiter. Do you have experience parsing and manipulating data using the "chunk" tools within LiveCode?

Write back...

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Storing information from database in an array

Post by FourthWorld » Wed Aug 14, 2013 6:26 pm

The revDataFromQuery function can populate a supplied array variable. See the Dictionary entry for that function for details.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Babyprincess
Posts: 17
Joined: Sat Aug 10, 2013 3:23 pm

Re: Storing information from database in an array

Post by Babyprincess » Thu Aug 15, 2013 7:23 am

Hi Craig Newman ( Dunbarx)

I have many images in my database which are encoded. I wish to perform the decode function. I am only able to decode each image individually.
I will copy my image's encoded string in "my_image_string" ... It's very long so i did not put it here.... Now i wish to decode all the images from the database which i would need a loop function, without having to manually copy the image's string in. Apart from storing them in an array, is there any other way i can do ?

on mouseUp

put "my_image_string" into dataV
put databaseGetData("SELECT data FROM messages WHERE media_wa_type = 1 AND data = '"& dataV & "'") into pText
set the dgText of group "Table" to ptext
put base64decode(pText) into image "Image Area"
put image "Image Area" into url ("binfile:" & specialFolderPath("C:\Users\Administrator\Desktop\sdcard") & "logo.png")

end mouseUp

Regards,
Priya

Post Reply