SuperCard Programming/Basics/Fields

Fields edit

Fields in SuperCard are used to store text.


Field Properties edit

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 Syntax edit

Getting the contents of a field edit

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 field edit

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 background edit

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