creating 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
Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

creating array

Post by Gautami » Wed Aug 28, 2013 9:06 pm

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

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

Re: creating array

Post by dunbarx » Thu Aug 29, 2013 12:56 am

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

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

Re: creating array

Post by MaxV » Thu Aug 29, 2013 9:15 am

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.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

Re: creating array

Post by Gautami » Thu Aug 29, 2013 9:19 am

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

Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

Re: creating array

Post by Gautami » Thu Aug 29, 2013 9:22 am

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

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

Re: creating array

Post by Klaus » Thu Aug 29, 2013 11:31 am

Just to be sure, your datagrid DOES have columns named:
fldname
fldpath
filepath
filenopath
?

Post Reply