Author Topic: Types and members  (Read 8441 times)

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Types and members
« on: November 01, 2005, 12:12:01 PM »
I know it has nothing to do with this, once again, but when I see
rob(Shots(t).Parent).kills
I see tehre is "."s and when I try in vb to use "." it just complain, why?
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Types and members
« Reply #1 on: November 01, 2005, 12:16:29 PM »
The . only works if the thing in front of it is a class or a type.

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Types and members
« Reply #2 on: November 01, 2005, 01:04:44 PM »
oh, and how do I make a class/type and what do they serv for purpose?
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Types and members
« Reply #3 on: November 01, 2005, 01:16:26 PM »
Types are logical units you can use to combine variables togehter with.

For instance, if you have a point, it would be good to define it thusly:

type point
x as single
why as single
end type

instead of:

x as single
why as single

by themselves.
« Last Edit: November 01, 2005, 01:16:38 PM by Numsgil »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Types and members
« Reply #4 on: November 01, 2005, 01:16:49 PM »
Hehe, the filter problem ;)

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Types and members
« Reply #5 on: November 01, 2005, 01:21:41 PM »
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: [Select]
Private type test
  subtest1 as integer
  subtest2 as string
  subtest3 as long
end type

public newtest(1000) as test

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: [Select]
with newtest
  for t = 1 to 1000
    .subtest1 = t
  next t
end with

Does that make a little sense now?
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Types and members
« Reply #6 on: November 01, 2005, 01:33:37 PM »
it did make sense acctualy, so the types are to groupthing toghater like that and to be used with . s?
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Types and members
« Reply #7 on: November 01, 2005, 02:00:39 PM »
Thread split and moved to keep bug reports on topic.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Types and members
« Reply #8 on: November 01, 2005, 02:01:08 PM »
Quote
it did make sense acctualy, so the types are to groupthing toghater like that and to be used with . s?
That is pretty much it.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Types and members
« Reply #9 on: November 01, 2005, 02:41:14 PM »
sweet sweetety sweet sweet
ned flanders
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Types and members
« Reply #10 on: November 01, 2005, 03:24:24 PM »
is it so aswell with types that I have to write it like formname.thing when I load from another form or file thing?
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Types and members
« Reply #11 on: November 01, 2005, 03:28:14 PM »
That depends a lot if you set them up as public or private types.
Public is accessable from anywhere. Private is accessable only in the same module or form.

In DB, "bot()" is defined as public so it can be accessed from anywhere in the whole program without need to say "form1.bot(23).nrg". We just use "bot(23).nrg"
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Types and members
« Reply #12 on: November 01, 2005, 03:33:37 PM »
sweet:D
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Types and members
« Reply #13 on: November 01, 2005, 09:33:46 PM »
Quote
Public is accessable from anywhere. Private is accessable only in the same module or form.

So would changing a var from private to public have any negative affects?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Types and members
« Reply #14 on: November 01, 2005, 10:36:05 PM »
It ruins encapsulation.

ie:

(in software engineering) the process of enclosing programming elements inside a larger, more abstract entity, similar to information hiding and separation of concerns. It is often associated with Object Oriented Programming. One or more of these attributes are often associated with the term:

    * Physically grouping together related operations or things.
    * "Gate keeper" of state or data; a single access point.
    * Hiding implementation details so that the external world only sees an interface. Note that functions also provide this capability.

So the code can could care less, but programmers upkeeping your code are apt to become sloppy and not use your type the way you intended.