SuperCard Programming/Basics/Fields

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Fields[edit | edit source]

Fields in SuperCard are used to store text.


Field Properties[edit | edit source]

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 | edit source]

Getting the contents of a field[edit | edit source]

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 | edit source]

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 | edit source]

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