Decode in livecode

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller

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

Decode in livecode

Post by Babyprincess » Sat Aug 10, 2013 4:20 pm

I have images in my database. How do i extract them & view them on livecode itself ?I believe i need to decode the string, anyone knows whats the code to decode

Klaus
Posts: 10287
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Decode in livecode

Post by Klaus » Sat Aug 10, 2013 4:34 pm

Hi Babyprincess (Really? C'mon :-D )

1. welcome to the forum!

2. It depends on how the strings are ENCODED!
Any idea how? And are that really "strings"?


Best

Klaus

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

Re: Decode in livecode

Post by Babyprincess » Sat Aug 10, 2013 5:24 pm

Thank you very much. I actually copied the "strings" into some online decoder (base64) & it did decode & output the image. All my image data are in my database, however i can't see the thumbnail view of them, that's why i believe i am supposed to decode it ): Please help me.

Klaus
Posts: 10287
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Decode in livecode

Post by Klaus » Sat Aug 10, 2013 5:36 pm

Ah, OK, that helps :-)

Do this to display the db output (I use the variable db_image_output in my example) into an image object (dbimage)
...
## fetch your "image string" from the database, put it into a variable,
## decode that variable and simply "put" it into an existing image object:
put base64decode(db_image_output) into img "dbimage"
...


Best

Klaus

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

Re: Decode in livecode

Post by Babyprincess » Mon Aug 12, 2013 9:27 am

Hi Klaus,

Thank you so much for your help (:

I tried doing this, am i on the right track? But i got an error [(Chunk: no such object) near "dbimage", char 26] ):

When i named my 'Image Area' as dbimage, i don't have any error but there is no output of any images

on mouseUp
put media_name into columnName
put "data" into CN2
put base64decode(CN2) into img "dbimage"
put "SELECT messages." & columnName & ",messages." & CN2 & " FROM messages WHERE messages." &columnName& "= messages." &columnName&"" into sql
put databaseGetData(sql) into ptext
set the dgText of group "Table" to ptext

end mouseUp

sincerly,
Babyprincess (:

Klaus
Posts: 10287
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Decode in livecode

Post by Klaus » Mon Aug 12, 2013 1:12 pm

Hi Babyprincess,

please check these stacks to get the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html
Babyprincess wrote:...
I tried doing this, am i on the right track? But i got an error [(Chunk: no such object) near "dbimage", char 26] ):
When i named my 'Image Area' as dbimage, i don't have any error ...
Sigh, I did not think that it is neccessary to note that the object names in my EXAMPLE script may not fit YOUR actual object names! Is it? 8-)
Babyprincess wrote:... but there is no output of any images
...
put "data" into CN2
put base64decode(CN2) into img "dbimage"
...
Do you really exspect that the TEXT "data" will turn into an IMAGE after you base64decode it?
Although it may seem to some people that programming is some kind of witchcraft, I can assure you that this is not the case! :-D

Of course you need to get the correct "image-string" form your database and then base64decode and use THAT string:
...
## HINT: This is an example and you may need to modify the herein used object names to fit your script!
put "SELECT your_image from your_table WHERE XXX = YYY" into tSQL

## I think "databaseGetData" is a custom function?
## whatever, I hope you get the picture!
put databaseGetData(tSql) into pImage
put base64decode(pImage) into img "Image Area"
...


Best

Klaus

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

Re: Decode in livecode [Complete Beginner]

Post by Babyprincess » Mon Aug 12, 2013 6:36 pm

Hi Klaus,

I'm sorry but i'm quire confused. This is the first time i'm coding in livecode that's why.

I tried what you said but then i kept getting various errors & my original output did not appear, so i alter'd the code again to this,i got 2 outputs extracted. It just appeared on my dektop with the image name. But i was unable to view it. Haiz,it's still not working. I'm kinda noob in live-code. Please help me. Sorry ):

on mouseUp
put media_name into columnName
put "data" into CN2
put media_wa_name into CN3
put "SELECT messages." & columnName & ",messages." & CN2 & " FROM messages WHERE messages." &columnName& "= messages." &columnName&"" into sql
put databaseGetData(sql) into ptext
set the dgText of group "Table" to ptext
put databaseGetData(sql) into pImage
put base64decode(pImage) into img "Image Area"

end mouseUp


A little background on what i'm doing- I'm doing a project on Whatsapp forensics. So i have to extract the images from the database & display in a thumbnail format. I've managed to actually been able to decrypt n display all the other informations. But i'm stuck at the images part.

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

Re: Decode in livecode

Post by Babyprincess » Mon Aug 12, 2013 6:55 pm

This is how i display'd all the other information from my whatsapp decrypted database

on mouseUp
ask "Table name" #messages-for my reference i included this
put it into table

put databaseGetTableNames(table) into theFields
replace "," with CR in theFields
set the dgProp["columns"] of group "DataGrid 2" to theFields

ask "SQL Statement" #SELECT*FROM messages-for my reference i included this
put it into sql
put databaseGetData(sql) into ptext
set the dgText of group "DataGrid 2" to ptext
end mouseUp


When i run this, all my whatsapp conversation informations are displayed. But...
- For contents with images, the "thumbnail" column does not show the thumbnail of the image but it does have a weird sign there which i believe indicates the presence of a image under that column

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

Re: Decode in livecode

Post by Babyprincess » Tue Aug 13, 2013 7:21 pm

Hi Klaus,

Thank you so much for your help and guides. I've finally managed to output my images. Thank you so much.
The error i kept having was my naming conventions. After i check'd my naming conventions thoroughly, i managed to see where i went wrong.
Thank you once again for your genuine help.

Sincerely,
Babyprincess (ME) (:

Klaus
Posts: 10287
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Decode in livecode

Post by Klaus » Tue Aug 13, 2013 9:28 pm

Hi Babyprincess,

glad you got it working!

"Haiz"? Are you from Singapur? :-)


Best

Klaus

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

Re: Decode in livecode

Post by Babyprincess » Wed Aug 14, 2013 2:54 pm

Hahahas.. Yes !

Klaus
Posts: 10287
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Decode in livecode

Post by Klaus » Wed Aug 14, 2013 3:20 pm

:-)




Your message contains 3 characters. The minimum number of characters you need to enter is 10.

Post Reply

Return to “Converting to LiveCode”