Re: Structs

new topic     » goto parent     » topic index » view thread      » older message » newer message

Sometimes it might be convenient to "package" several related variables together into another. We call this a "variable structure," or "struct" for short.

You define a structure like this:

struct name 
   string first 
   string middle 
   string last 
end struct 
 
struct address 
   string street 
   string city 
   string state 
   string zip 
end struct 
 
-- structs can hold other structs 
struct employee 
   name name 
   address address 
end struct 

You instantiate a struct like other variable types:

name nName 
address nAddress 
employee nEmployee 

You assign values to a struct like this:

nName.first = "Billy" 
nName.middle = "Gene" 
nName.last = "Smith" 
 
nAddress.street = "1200 Independence Pkwy" 
nAddress.city = "New York City" 
nAddress.state = "New York" 
nAddress.zip = "01234" 
 
nEmployee.name = nName 
nEmployee.address = nAddress 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu