Assigning a value to a card field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Assigning a value to a card field
Hello,
How does one assign a value to a card field? I have a field defined as " rWord ". Then:
put the dgDataOfLine[theLine] of group "entriesGrid" into tWord
set the text of field "rWord" to tWord
But the second line does not assign the value of tWord (yes, it has a value) to the firled " rWord ". I tried many combinations with "set" and "put" but to no avail.
Help before I go nuts!
r
How does one assign a value to a card field? I have a field defined as " rWord ". Then:
put the dgDataOfLine[theLine] of group "entriesGrid" into tWord
set the text of field "rWord" to tWord
But the second line does not assign the value of tWord (yes, it has a value) to the firled " rWord ". I tried many combinations with "set" and "put" but to no avail.
Help before I go nuts!
r
Re: Assigning a value to a card field
Hi resty,
the functions "the dgDataOfLine[xxx]" and "the dgDataOfIndex[theLine]" return an ARRAY!
So you cannot put it into a field, you need to define a key of that array to put into your field.
Example:
...
put the dgDataOfLine[theLine] of group "entriesGrid" into tArray
put tArray["whatever"] into fld "rWord"
...
Consult the dictionary if in doubt!
Starting with version 8 it also contains the DataGrid docs.
Best
Klaus
the functions "the dgDataOfLine[xxx]" and "the dgDataOfIndex[theLine]" return an ARRAY!
So you cannot put it into a field, you need to define a key of that array to put into your field.
Example:
...
put the dgDataOfLine[theLine] of group "entriesGrid" into tArray
put tArray["whatever"] into fld "rWord"
...
Consult the dictionary if in doubt!
Starting with version 8 it also contains the DataGrid docs.
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Assigning a value to a card field
Step through your handler, and you will see the array decomposed in the debugger. That is always a convenient place to see array contents.
Read about the "combine" command in the dictionary, just for practice and new knowledge.
Craig Newman
Read about the "combine" command in the dictionary, just for practice and new knowledge.
Craig Newman
Re: Assigning a value to a card field
Klaus,
Thank you for your reply. So how do I, ah, uhm, create an index? I tried the following but no
cigar.
put the dgHilitedLines of group "entriesGrid" into theLine
put the dgDataofIndex[theLine] of group "entriesGrid" into tIndex
put the dgDataOfLine[theLine] of group "entriesGrid" into tWord
put tWord[tIndex[1]] into fld "rWord"
In the above, the content of tWord[tIndex[1]], is not being moved to "rWord".
Thanks for the help and cheers!
Thank you for your reply. So how do I, ah, uhm, create an index? I tried the following but no
cigar.
put the dgHilitedLines of group "entriesGrid" into theLine
put the dgDataofIndex[theLine] of group "entriesGrid" into tIndex
put the dgDataOfLine[theLine] of group "entriesGrid" into tWord
put tWord[tIndex[1]] into fld "rWord"
In the above, the content of tWord[tIndex[1]], is not being moved to "rWord".
Thanks for the help and cheers!
Re: Assigning a value to a card field
Hi resty,
that was just an example that these two DIFFERENT functions
-> dgDataofIndex[theLine]
and
-> dgDataOfLine[theLine]
are returning an ARRAY and not that you have to use both of them!
Did you name the columns in your datagrid?
If yes, then use these names for the keys, if not the columns will have the "deffault" names like
Col 1
Col 2
etc...
Get the picture?
Do like this:
Best
Klaus
that was just an example that these two DIFFERENT functions
-> dgDataofIndex[theLine]
and
-> dgDataOfLine[theLine]
are returning an ARRAY and not that you have to use both of them!
Did you name the columns in your datagrid?
If yes, then use these names for the keys, if not the columns will have the "deffault" names like
Col 1
Col 2
etc...
Get the picture?
Do like this:
Code: Select all
...
put the dgHilitedLines of group "entriesGrid" into theLine
## Since you used this line to get the currently highlited line, you need to stick to LINE now!
## Hint: LINE can be <> INDEX!
put the dgDataOfLine[theLine] of group "entriesGrid" into tSingleDimensionalArray
put tSingleDimensionalArray["name of your column here..."] into fld "rWord"
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Assigning a value to a card field
Do this in a button script:
First look at the variable "myArray" (the keys are in the variable name area, the values are in the value area). As I said, the debugger is a very nice tool to see array contents. The answer command will pull out those keys.
Craig
Code: Select all
on mouseUp
put "1st letter" into myArray["A"]
put "2nd letter" into myArray["B"]
put "3rd letter" into myArray["C"]
breakpoint
answer the keys of myArray
end mouseUp
Craig
Re: Assigning a value to a card field
Klaus,
That works really well! Thanks for the Christmas gift!
Thanks to dunbarx for the enlightenment.
That works really well! Thanks for the Christmas gift!
Thanks to dunbarx for the enlightenment.