Code center > Darwinbots Program Source Code

Types and members

<< < (2/5) > >>

PurpleYouko:
Have a look at the top of the "robots" module. You will see a whole bunch of variables, constants and types defined.

The primary one is the "robot" type

Later, rob() is defined as robot.

here is an example.


--- Code: ---Private type test
  subtest1 as integer
  subtest2 as string
  subtest3 as long
end type

public newtest(1000) as test
--- End code ---

Using this we define "test" as a type, then we add subtest1, 2 and 3 as members.

We can't actually use "test" in the main program as it is "type" rather than a variable, so we have to make a variable that mirrors the "type"

"public newtest(1000) as test" defines a new user type, "newtest" as the same format as the original "test" type.
In addition we now have it as an array with 1000 elements.

In the main loop we can now address things like....

newtest(389).subtest2

as a variable because subtest2 is a "member" of the "type"

In addition we can write stuff like


--- Code: ---with newtest
  for t = 1 to 1000
    .subtest1 = t
  next t
end with
--- End code ---

Does that make a little sense now?

Zelos:
it did make sense acctualy, so the types are to groupthing toghater like that and to be used with . s?

PurpleYouko:
Thread split and moved to keep bug reports on topic.

PurpleYouko:

--- Quote ---it did make sense acctualy, so the types are to groupthing toghater like that and to be used with . s?
--- End quote ---
That is pretty much it.

Zelos:
sweet sweetety sweet sweet
ned flanders

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version