Array that is not an array (solved)

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
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Array that is not an array (solved)

Post by MaxV » Wed Aug 10, 2016 2:36 pm

Hello,
I have a mystery to solve with your help.
I have a list like this:

Code: Select all

Image ,ImageDescription,SAMSUNG CAMERA PICTURES,ASCII,158
Image ,Make,SAMSUNG,ASCII,190
EXIF ,Model,NX3000,ASCII,198
Thumbnail ,Orientation,1,Short,54
Image ,XResolution,72/1,Ratio,230
Image ,YResolution,72/1,Ratio,238
Image ,ResolutionUnit,Pixels/Inch,Short,90
Image ,Software,FW Ver 01.02,ASCII,246
Image ,DateTime,2015:10:24 16:28:49,ASCII,262
Image ,YCbCrPositioning,2,Short,126
I create an array with this code:
########CODE#######
function exifProcessFileArray pData
repeat for each line tLine in pdata
put item 1 of tLine into tnome1
put item 2 of tLine into tnome2
put item 3 to -1 of tLine into tArray [tnome1] [tnome2]
end repeat
return tArray
end exifProcessFileArray
#####END OF CODE#####

Well, the array tArrya is not an array! I get the first set of keys: tArray["EXIF"], tArray["Thumbnail"] and tArray["Image"], but any other data is unreachable!!! :shock:
the code:

Code: Select all

put tArray["EXIF"] is an array 
returns false!!!
But the IDE debugger says that is an array!
Look this picture:
Image
What is it? How can I reach the tArray["EXIF"]["ColorSpace"] ?
Last edited by MaxV on Wed Aug 10, 2016 3:04 pm, edited 1 time in total.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Array that is not an array

Post by Klaus » Wed Aug 10, 2016 2:49 pm

Buongiorno Max,

this does the trick:
...
put tArray["EXIF "]["Model"]
## -> NX3000,ASCII,198
...
Please note the SPACE before the first comma in your list!
Either remove them when creating the array or take them into account later!


Best

Klaus

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

Re: Array that is not an array

Post by FourthWorld » Wed Aug 10, 2016 2:55 pm

The source data appears to have an extra space between the end of the key name and the comma. If that's correct, the key would be tArray["EXIF "] rather than tArray["EXIF"].
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Array that is not an array

Post by MaxV » Wed Aug 10, 2016 3:03 pm

Damn! I didn't notice it!!! :evil:
Thank you so much!!! :D
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: Array that is not an array (solved)

Post by FourthWorld » Wed Aug 10, 2016 5:22 pm

Weird data happens to all of us. Like Linus Torvalds says, "Given enough eyeballs all bugs are shallow."
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply