Page 1 of 1

creating array

Posted: Wed Aug 28, 2013 9:06 pm
by Gautami
Hello,
I don't see where I am going wrong.
Can someone help me point out what I am doing wrong. I know its probably a very stupid mistake.
Been at this for hours now :(

Code: Select all

on mouseUp
   local tFolder, tFileList
   answer folder "Select the Folder" 
   put it into tFolder
   set the defaultFolder to tFolder
   put filteredFolders() into mainfolder
 
    ----- having problem from here on
   put 1 into tcounter
   repeat for each line tItem in mainfolder
      put tItem into folderArray[tcounter]["fldname"]
      put tFolder & "/" & tItem into folderArray[tcounter]["fldpath"]
      put filteredFilesWithPaths() into folderArray[tcounter]["filepath"]
      put filteredFiles() into folderArray[tcounter]["filenopath"]
      add 1 to tcounter
   end repeat
   set the dgText of group "DG" to folderArray --- returns no keys
   set the dgData of group "DG" to folderArray --- returns every line as a key
   
--- but datagrid remains empty.   
end mouseUp

Thanks for the help!

Gautami

Re: creating array

Posted: Thu Aug 29, 2013 12:56 am
by dunbarx
Your array construction is valid, though I know nothing of the data you get from your custom functions. Do you get any errors with these?

Craig Newman

Re: creating array

Posted: Thu Aug 29, 2013 9:15 am
by MaxV
Or you use dgData (array solution) or you use dgText (tabbed grid text solution), you can't use both.
Remember that the array organization is the following: dgData[row][column_name], where row is an integer and column_name is a string.
Column in array and column name (not label) in datagrid must be the same.

Re: creating array

Posted: Thu Aug 29, 2013 9:19 am
by Gautami
Nope, I don't. All of them give me valid output.
This code works when there is only 1 item inside the repeat loop.
When I have more than one, I get no output.

G

Re: creating array

Posted: Thu Aug 29, 2013 9:22 am
by Gautami
Hi Max,
Sorry, I did not comment out one of the dgtext/dgdata in the above code.
But i used only 1 at a time. I tried the other to see if that worked by chance; it did not.
When I print the keys out for each method,
i get the results are stated above.

G

Re: creating array

Posted: Thu Aug 29, 2013 11:31 am
by Klaus
Just to be sure, your datagrid DOES have columns named:
fldname
fldpath
filepath
filenopath
?