Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
Tam123
- Posts: 19
- Joined: Mon Apr 30, 2007 12:55 pm
Post
by Tam123 » Tue May 01, 2007 11:01 am
Help!
I've created a progarm which randomly presents a series of words on a screen. The program then randomly selects a letter which it colours either blue, green or red (again in a random fashion). However, I now need code that will allow two arrows (or graphics) to appear one above and one below the randomly selected letter (ie to point to the letter and direct attention). Can anyone help me with code which will do this??
The biggest problem is that the word varies in length on any given trial...
My rev skills are limited so simple code would be much appreciated!
The code I have thus far is (if that helps at all?)....
put the number of characters of item 1 of line wordnumber of fld "wordField" into charnumber
put empty into fld "charfield"
put 1 into s
repeat until s > charnumber
put s & linefeed after fld "charfield"
add 1 to s
end repeat
put scramble(fld "charfield") into fld "charfield"
set the text of fld "colourLabel" to line wordnumber of fld "wordField"
put item 1 of line 1 of fld "charfield" into fred
set the textcolor of char fred of fld "colourLabel" to item 1 of line wordnumber of fld "colour"
Show fld "colourLabel"
-
marielle
- Livecode Opensource Backer

Post
by marielle » Tue May 01, 2007 4:33 pm
will give you the x,y position of the selected letter.
To know the height of the character (and therefore by how much you need to offset the graphic on top or bottom of the letter), you can use
Code: Select all
put the formattedheight of character 4 of field myField into tCharHeight
-
Tam123
- Posts: 19
- Joined: Mon Apr 30, 2007 12:55 pm
Post
by Tam123 » Wed May 02, 2007 12:50 pm
Hi,
Thanks for your prompt reply. But how do I use the code "selectedLoc"?
I tried the code below...
answer the selectedloc of char fred of fld "colourLabel"
and I don't get anything
I've also tried...
set the selectedloc of image "arrow" to the selectedloc of char fred of fld "colourLabel"
put the selectedloc of char fred of fld "colourLabel" into charLoc
set the topleft of image "arrow" to charLoc
and neither work... Sorry I must be using the code wrong any help would be much appreciated.
Thanks

-
marielle
- Livecode Opensource Backer

Post
by marielle » Wed May 02, 2007 1:41 pm
Tam123 wrote:answer the selectedloc of char fred of fld "colourLabel"
and I don't get anything
I've also tried...
Makes sense... but unfortunately runrev won't understand this. Why not try?
Code: Select all
select char fred of fld "colourLabel"
put the selectedloc
(select doesn't seem to run from the messagebox but this works from within a script)
-
Tam123
- Posts: 19
- Joined: Mon Apr 30, 2007 12:55 pm
Post
by Tam123 » Thu May 03, 2007 1:04 am
I'm so sorry but I'm still confused as to what to do after
put the selectedloc
How do I use this code to make the image's location the same as the selected letter?

-
Tam123
- Posts: 19
- Joined: Mon Apr 30, 2007 12:55 pm
Post
by Tam123 » Thu May 03, 2007 1:23 am
Hi,
I figured it out! I used the code below...
put the formattedleft of char fred of fld "colourLabel" into army
set the left of image "arrow" to army
your reference to the formattedheight code gave me a clue.
Thanks so much for all your time and effort-much appreciated!!
Tam
-
malte
- Posts: 1098
- Joined: Thu Feb 23, 2006 8:34 pm
-
Contact:
Post
by malte » Thu May 03, 2007 9:23 am
Hey Tam!
You beat me to it. I use rev over 5 years now and didn't know that works. Thanks a lot!
Malte
-
Tam123
- Posts: 19
- Joined: Mon Apr 30, 2007 12:55 pm
Post
by Tam123 » Thu May 03, 2007 11:39 am
Hi Malte,
No problem, glad to help! I discovered Rev two years ago but I am limited to psyc experiments so I tend to just recyle old code. I love it when I finally get to do something new and more challenging. I enjoy the puzzle
Cheers,
Tam
-
marielle
- Livecode Opensource Backer

Post
by marielle » Thu May 03, 2007 1:12 pm
Tam123 wrote: put the formattedleft of char fred of fld "colourLabel" into army set the left of image "arrow" to army
Cool, that's an excellent generalisation. I wouldn't have thought of it. On put the selectedloc and what comes after:
Then my loc contains something like 125,40
Code: Select all
put the selectedloc into myLoc
put item 1 of myLoc into myX
put item 2 of myLoc into myY
Your solution is very cool and more efficient

-
marielle
- Livecode Opensource Backer

Post
by marielle » Thu May 03, 2007 1:38 pm
Tam123 wrote:I am limited to psyc experiments
Can you tell me more about that? I am a cognitive psychologist. I produced this
museum of perception and cognition a few years back (well many years back now, as the look and feel of the website shows)
-
Tam123
- Posts: 19
- Joined: Mon Apr 30, 2007 12:55 pm
Post
by Tam123 » Fri May 04, 2007 10:57 am
Hi,
Very cool. I want to start doing more web based stuff.
The work varies.
If it's a clinical project then I'd be creating survey's (ie a depression questionnaire) using Rev. Where responses would be recorded and anaylsed by Rev which would output their score ie. severely depressed, moderately depressed etc.
If it's cognitive psyc it would be say a learning study where stimuli is presented on the screen and the person would learn response contingencies and their rate of learning would be measured.
Most recently it's been a Stroop task where response times are recorded. This is the project I was asking all the questions about.
