Page 1 of 1

Array that is not an array (solved)

Posted: Wed Aug 10, 2016 2:36 pm
by MaxV
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"] ?

Re: Array that is not an array

Posted: Wed Aug 10, 2016 2:49 pm
by Klaus
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

Re: Array that is not an array

Posted: Wed Aug 10, 2016 2:55 pm
by FourthWorld
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"].

Re: Array that is not an array

Posted: Wed Aug 10, 2016 3:03 pm
by MaxV
Damn! I didn't notice it!!! :evil:
Thank you so much!!! :D

Re: Array that is not an array (solved)

Posted: Wed Aug 10, 2016 5:22 pm
by FourthWorld
Weird data happens to all of us. Like Linus Torvalds says, "Given enough eyeballs all bugs are shallow."