Overview | Commands | Syntax | Properties | Functions | Event Handlers | Compatibility
id
The id uniquely identifies an object. In ViperCard, all objects will have different ids, even if they are different types or are on different cards.
If you put the long id of an object into a variable, you can use that variable to refer to the object.
put the long id of card id 1011 into z
set the name of z to "changed"
The short id of an object is just the number. For example the short id of card id 1011 is 1011.
put the short id of card id 1011 into z
set the name of cd id z to "changed"
name
You can get or set the name of an object.
doMenu "New Button"
set the name of the result to "my new button"
set the name of cd btn id 1011 to "changed"
answer the short name of cd btn id 1011 -- "changed"
number
You can get the number of an object.
answer the number of cd fld 2 -- 2
answer the number of cd btn 3 -- 3
answer the number of card 4 -- 4
owner
Gets the parent object. Btns and flds belong to cards, cards belong to backgrounds, and backgrounds belong to the stack.
Examples:
put the owner of cd btn "myBtn" into z
set the name of the owner of cd btn "myBtn" to "changed"
script
It's unlikely to be useful, but a script can dynamically change the contents of another script.
Examples:
put return & "on newCode" & return & "answer 234" & \
return & "end newCode" into newCode
put the script of cd btn id 123 into oldCode
set the script of cd btn id 123 to oldCode & newCode
send "newCode" to cd btn id 123
btn: autohilite
Does the button turn black when you click on it?
Examples:
put the autohilite of cd btn "myBtn" into z
btn: checkmark
Examples:
set the checkmark of cd btn "myBtn" to true.
btn: enabled
If a button is not enabled, it is greyed out and can't be clicked.
Examples:
set the enabled of cd btn "myBtn" to true
set the enabled of cd btn "myBtn" to false
btn: left
The x coordinate of the top left corner of the object, in pixels. I.e. the distance from the left of the screen to the object.
Examples:
set the left of cd btn "myBtn" to 4
btn: loc, location
The coordinates of the center of the object.
Examples:
put the location of cd btn "myBtn" into z
btn: height
The height of the object on screen, in pixels.
Examples:
put the height of cd btn "myBtn" into z
btn: hilite
Examples:
put the hilite of cd btn "myBtn" into z
btn: label
Examples:
put the label of cd btn "myBtn" into z
btn: icon
Number of the icon.
Examples:
put the icon of cd btn "myBtn" into z
btn: rect, rectangle
Four numbers representing the left, top, bottom, and right coordinates. I.e. the first two numbers are the coordinates of the top left corner, and the last two numbers are the coordinates of the bottom right corner.
Examples:
set the rect of cd btn "myBtn" to 45,56,67,78
set the rectangle of cd btn "myBtn" to 45,56,67,78
btn: showlabel
Is the label text shown?
Examples:
put the showlabel of cd btn "myBtn" into z
btn: style
Styles include:
Transparent
Rectangle
Opaque
Roundrect
Plain
Shadow
OsStandard
OsDefault
OsBoxmodal
Checkbox
Radio
Examples:
set the style of cd btn "myBtn" to "Shadow"
btn: textalign
Set alignment of the label text.
Examples:
set the textalign of cd btn "myBtn" to "left"
set the textalign of cd btn "myBtn" to "center"
btn: textfont
Set typeface of the label text.
Examples:
set the textfont of cd btn "myBtn" to "courier"
btn: textsize
Set size of the label text.
Examples:
set the textsize of cd btn "myBtn" to 24
btn: textstyle
Set style of the label text.
Examples:
set the textstyle of cd btn "myBtn" to "bold"
btn: top
The y coordinate of the top left corner of the object, in pixels. I.e. the distance from the top of the screen to the object.
Examples:
put the top of cd btn "myBtn" into z
btn: topleft
The x,y coordinates of the upper left corner.
Examples:
set the topleft of cd btn "myBtn" to 34, 56
btn: visible
Hide or show the object.
Examples:
set the visible of cd btn "myBtn" to false
btn: width
The width of the object on screen, in pixels.
Examples:
put the width of cd btn "myBtn" into z
fld: alltext
Get or set all contents of the field.
Examples:
put the alltext of cd fld "myFld" into z
fld: dontwrap
Wrap text onto different lines.
Examples:
put the dontwrap of cd fld "myFld" into z
fld: enabled
A disabled field is greyed out and can't be edited.
Examples:
put the enabled of cd fld "myFld" into z
fld: defaulttextfont
If the user deletes all text in a field and then types a letter, the font of this letter will be determined by the defaulttextfont.
Examples:
put the defaulttextfont of cd fld "myFld" into z
fld: defaulttextsize
If the user deletes all text in a field and then types a letter, the size of this letter will be determined by the defaulttextsize.
Examples:
put the defaulttextsize of cd fld "myFld" into z
fld: defaulttextstyle
If the user deletes all text in a field and then types a letter, the style of this letter will be determined by the defaulttextstyle.
Examples:
put the defaulttextstyle of cd fld "myFld" into z
fld: left
The x coordinate of the top left corner of the object, in pixels. I.e. the distance from the left of the screen to the object.
Examples:
set the left of cd fld "myFld" to 4
fld: loc, location
The coordinates of the center of the object.
Examples:
put the location of cd fld "myFld" into z
fld: locktext
You can't type new text into a 'locked' field. You can still set the contents via a script.
Examples:
set the locktext of cd fld "myFld" to true
put "still can change" into cd fld "myFld"
fld: height
The height of the object on screen, in pixels.
Examples:
put the height of cd fld "myFld" into z
fld: rect, rectangle
Four numbers representing the left, top, bottom, and right coordinates. I.e. the first two numbers are the coordinates of the top left corner, and the last two numbers are the coordinates of the bottom right corner.
Examples:
set the rect of cd fld "myFld" to 45,56,67,78
set the rectangle of cd fld "myFld" to 45,56,67,78
fld: scroll
The vertical scroll position.
Examples:
put the scroll of cd fld "myFld" into z
fld: singleline
Field is a single line, cannot contain newlines.
Examples:
put the singleline of cd fld "myFld" into z
fld: style
Styles include:
Opaque
Transparent
Rectangle
Shadow
Scrolling
Examples:
set the style of cd fld "myFld" to "shadow"
fld: textalign
Set alignment of text
Examples:
set the textalign of cd fld "myFld" to "left"
set the textalign of cd fld "myFld" to "center"
fld: textfont
By default, applies the property to the entire field.
set the textfont of cd fld "myFld" to "chicago"
put the textfont of cd fld "myFld" into z
We now support getting and setting by chunk!
set the textfont of char 3 to 4 of cd fld "myFld" to "geneva"
put the textfont of char 3 to 4 of cd fld "myFld" into z
When querying for a property and there are multiple values, returns the string "mixed".
fld: textsize
By default, applies the property to the entire field.
set the textsize of cd fld "myFld" to "chicago"
put the textsize of cd fld "myFld" into z
We now support getting and setting by chunk!
set the textsize of char 3 to 4 of cd fld "myFld" to "geneva"
put the textsize of char 3 to 4 of cd fld "myFld" into z
When querying for a property and there are multiple values, returns the string "mixed".
fld: textstyle
By default, applies the property to the entire field.
set the textstyle of cd fld "myFld" to "bold"
set the textstyle of cd fld "myFld" to "bold,italic"
set the textstyle of cd fld "myFld" to "plain"
put the textstyle of cd fld "myFld" into z
We now support getting and setting by chunk!
set the textstyle of char 3 to 4 of cd fld "myFld" to "bold"
put the textstyle of char 3 to 4 of cd fld "myFld" into z
When querying for a property and there are multiple values, returns the string "mixed".
You can also do the following:
set the textstyle of cd fld "myFld" to "add-bold"
set the textstyle of cd fld "myFld" to "subtract-italic"
set the textstyle of cd fld "myFld" to "toggle-outline"
set the textstyle of line 2 of cd fld "myFld" to "add-bold"
set the textstyle of line 2 of cd fld "myFld" to "subtract-italic"
set the textstyle of line 2 of cd fld "myFld" to "toggle-outline"
fld: top
The y coordinate of the top left corner of the object, in pixels. I.e. the distance from the top of the screen to the object.
Examples:
put the top of cd fld "myFld" into z
fld: topleft
The x,y coordinates of the upper left corner.
Examples:
set the topleft of cd fld "myFld" to 34, 56
fld: width
The width of the object on screen, in pixels.
Examples:
put the width of cd fld "myFld" into z
fld: visible
Show or hide the object.
Examples:
put the visible of cd fld "myFld" into z
cursor
Sets the current cursor.
Examples:
-- show the watch
set the cursor to "watch"
wait 2 seconds
-- spinning ball
repeat with x = 1 to 30
set the cursor to "busy"
wait 0.2 seconds
end repeat
filled
The color/opacity for drawing. Currently can be "true" for black, "false" for transparent, or "white" for white.
Examples:
set the filled to "white"
lineColor
The lineColor for drawing. Currently can be 0 (black) or 1 (white).
Examples:
set the lineSize to 1
lineSize
The linesize for drawing. Currently can be 1 (thin) or 2 (thicker).
Examples:
set the lineSize to 2
itemdelimiter
Examples:
put the itemdelimiter into z
set the itemdel to tab
answer item 2 of "a"&tab&"b"&tab&"c"
set the itemdel to ","
idlerate
The speed at which on idle
is called.
Examples:
set the idlerate to "default"
set the idlerate to "faster"
set the idlerate to "faster2"
multiple
The "draw multiple" setting for drawing. Does not yet affect script drawing.
Examples:
set the multiple to true
pattern
The current pattern number.