SuperCard Programming/Basics/Fields

FieldsEdit

Fields in SuperCard are used to store text.


Field PropertiesEdit

Fields have Style properties.

Text is an intrinsic property of a field. In fact, the text property of a field doesn't need to be named when getting or setting it. In fact, this can seem counter intuitive when compared to other languages and programming environments. To get or set the text of a field, you simply get or put a literal string or a variable into or out of the field. See the examples below under Field Syntax.

Field SyntaxEdit

Getting the contents of a fieldEdit

It might seem like you should be able to simply do the following:

-- WARNING!! Incorrect Code!
get field [name of field]
put it into [variable name]

However, fields either belong to cards or backgrounds, so you must specify this when getting or setting the text in a field:

get [cd/card/bg/background] field [name of field]
put it into [variable name]
put [cd/card/bg/background] field [name of field] into [variable name]

Putting (i.e. setting) the contents of a fieldEdit

Just as when getting the contents of a field, you must specify card or background when putting data in:

put [literal string/variable name] into [cd/card/bg/background] field [name of field]

Looping through the fields of a card or backgroundEdit

repeat with x = 1 to the number of [cd/card/bg/background] fields
[code to work with fields]
-- example [cd/card/bg/background] field x
end repeat
Last modified on 3 March 2008, at 02:36