How should I interpret the Dictionary?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

How should I interpret the Dictionary?

Post by Simon Knight » Thu Feb 18, 2010 12:10 pm

Hi all,
I have just started playing with scrollbars and copied some found code into my stack:

Code: Select all

on scrollbarDrag sbValue -- display new value of scroll bar
   global gTgtSpeed
   
   put sbValue into gTgtSpeed
   put gTgtSpeed into fld"TargetSpeed"
 
end scrollbarDrag
My code then refers to the global variable and all is well.
Then I conducted a search of the forum and discovered reference to the following syntax:

Code: Select all

put the thumbposition of scrollbar"theScrollbar" into tAnyVar
Now this is great as I no longer have to bother with a global variable. But my confusion stems from looking "thumb position" up in the dictionary where the syntax just describes using "SET" command with no reference to the "PUT" or any other.

Is it the case that where the dictionary displays a 'SET" syntax I will be able to use a "PUT", or am I always able to read Type:property or do I just have to know?

thumbPosition
Type: property
Syntax: set the thumbPosition of scrollbar to number
Objects (or Types): scrollbar
Synonyms:
thumbPos
See Also: scrollbarBeginning Message, scrollbarLineInc Message, thumbSize Property
Introduced: 1.0.....<snip>

best wishes
Simon :?:
best wishes
Skids

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: How should I interpret the Dictionary?

Post by bn » Thu Feb 18, 2010 1:00 pm

Hi Simon,
a property you can either only get or get/set. Some are read only and you can only get them, some you can also set.
Put is a different story. Put is for containers, not properties. Container beeing a variable/Field/file.

If you issue a put command for a property you implicitly do the following: get myProperty, put it into myVariable or myField. With the put you grab the value of the property and put it into a container.
Rev might be confusing in that you can not PUT a value into a property, you can only set a property.

Code: Select all

put 5 into the thumbpositon of scrollbar 1 -- does NOT work
 set the thumbposition of scrollbar 1 to 5 -- works
You have to use set for that. If you address a property you should use THE before the property. This is especially important if you create a custom property. Rev has no way to distiguish between a variable and a custom property except for the THE. Example

Code: Select all

set the uValueOfThumbposition of this card to 5
In this line of code you create the custom property uValueOfThumbpositon of the current card and set it to 5.
You can than access this custom property from anywhere in your stack.

Code: Select all

put the uValueOfThumbpositon of card xyz into myContainer
Any object in Rev can have custom properties, you can look at them in the properties inspector -> Custom Properties. I explained this in a little more detail because I rarely use global variables for the simple reason that I find them harder to maintain, who puts what into them when. And they are not persistent, after closing the stack they are gone. Custom properties are saved with the stack, next time you open the stack they are still there. If not using custom properties I prefer script local variables over global variables whenever possible.
Anyways, I hope my attempt at an explanation does not add confusion but helps a little.
regards

PS did you try the offset script? (http://forums.runrev.com/phpBB2/viewtop ... 478#p21478)
Bernd

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: How should I interpret the Dictionary?

Post by Simon Knight » Thu Feb 18, 2010 4:48 pm

Bernd,
Yet again thanks for a detailed response. Have you thought of writing a book about RunRev?

I'm sorry that I missed your offset example which I will have a look at. However, things have moved on: we decided that the GPS would not be able to work with enough accuracy so I am now looking at using a "Hall effect" sensor interfaced with RunRev using an Arduino interface card. I have a working prototype which includes five leds to indicate how late or early the car is running. The rally car driver has an older trip meter which connects to the speedometer cable and we plan to fix our sensor to this.

All good fun!

best wishes

Simon
best wishes
Skids

Post Reply