Page 1 of 1

Structure Problem

Posted: Thu Jan 27, 2005 10:22 pm
by RedmoonX

Code: Select all

; this works

Structure my_struct
  my_x.l
  my_y.l
  my_sprite.l
EndStructure

my_pointer.my_struct

my_pointer\my_x = 2

Debug my_pointer\my_x

; this works not

Procedure function()
  Structure my_struct2
    my_x.l
    my_y.l
    my_sprite.l
  EndStructure
  my_pointer2.my_struct2
EndProcedure

Procedure set_value(val.l)
  my_pointer2\my_x = val
EndProcedure 

function()
set_val(2)

Debug my_pointer2\my_x

; ERROR: 
; line 27 this variable doesnt have a structure!
;
; whats wrong cant i use structures in procedures
is it not possible to have structures within procedures??

RedmoonX

Posted: Thu Jan 27, 2005 10:35 pm
by GPI
make the variable global.

Re: Structure Problem

Posted: Thu Jan 27, 2005 10:39 pm
by traumatic
that's no structure-problem: my_pointer2.my_struct2 is neither shared nor global...

EDIT: Damn, I'm always too late :evil:

Posted: Thu Jan 27, 2005 10:49 pm
by RedmoonX
lol :D

haha when i try to make "my_struct2" or "my_pointer2" global
then i get error

variable already decleared with another type: my_pinter 2

all i did was adding "global my_pointer 22 before procedure my_struct2()


plzz help

RedmoonX

Posted: Thu Jan 27, 2005 10:53 pm
by traumatic
Obviously you can't define the same structure twice...

do it EITHER this way:

Code: Select all

Structure my_struct2
  my_x.l
  my_y.l
  my_sprite.l
EndStructure

Global my_pointer2.my_struct2
OR this way:

Code: Select all

Procedure function()
  Structure my_struct2
    my_x.l
    my_y.l
    my_sprite.l
  EndStructure
  Shared my_pointer2.my_struct2
EndProcedure

Procedure set_value(val.l)
  Shared my_pointer2.my_struct2
  my_pointer2\my_x = val
EndProcedure
See?

Posted: Thu Jan 27, 2005 10:55 pm
by RedmoonX
thx.. the structures isnt the same
the first is "my_struct, my_pointer" the second is
"my_struct2, my_pointer2"

but now i now how to share the variables

thx

it worked

RedmoonX