Random Variable in a column

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jakea782
Posts: 26
Joined: Wed Dec 11, 2013 4:43 pm

Random Variable in a column

Post by jakea782 » Sun Dec 15, 2013 1:21 pm

I'm trying to find a way to assign a random column to display in a text field after I assign mouseUp to a button. So right now this is my code to display the random variable for the row but I only know how to assign one column.

put the dgDataOfLine[random(22)] of grp "WordsChart" of stack "FWsub" into FirWord
put FirWord["Nouns"] into FirWordValue
put FirWordValue into field "FirstWord" <--- that is the text field that displays the word

So on mouseUp, I click the button and it puts a random number into FirWord. It then assigns the column "Nouns" into FirWordValue. The word that is assigned to this cell that is the random number and in column "Nouns" is then displayed. What can I do to assign a random column instead? All my columns are named and I have eight of them.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Random Variable in a column

Post by Klaus » Sun Dec 15, 2013 1:41 pm

Grüezi Jakea782,

you can use the "dgProp["columns"] for this:
...
put the dgDataOfLine[random(22)] of grp "WordsChart" of stack "FWsub" into FirWord

## Get a random line of this CR delimited list:
put any line of the dgProp["columns"] of grp "WordsChart" of stack "FWsub" into tRandomKey

## Or to visualize the single staps:
## 1. Get list of columns:
## put the dgProp["columns"] of grp "WordsChart" of stack "FWsub" into tColumnList
## 2. get a RANDOM line from this list:
## put ANY line of tColumnList into tRandomKey

put FirWord[tRandomKey] into field "FirstWord"
...

I recommend to load the DataGrid Docs in PDF format and read it at least 100 times!
Or more, if neccessary, that's what I did, and still have to when using datagrids anew
after a couple of days, they are so damn complex beasts! :D

Get it here: http://lessons.runrev.com/m/datagrid


Best

Klaus

jakea782
Posts: 26
Joined: Wed Dec 11, 2013 4:43 pm

Re: Random Variable in a column

Post by jakea782 » Fri Dec 27, 2013 3:29 am

I never came back and thanked you for this. Merci Klaus!

Post Reply

Return to “Games”