View Full Version : Global Array
Paul Fielder
10-06-2006, 11:50 AM
I know that it's bad practice but... Am I right in saying that to create a global variable I use: Global (blar$); Can I create a global array?
kornalius
10-06-2006, 05:20 PM
Yep,
Global(blar$);
Dim(blar$, 10, 10);
You end up with a global 10x10 array.
Paul Fielder
10-06-2006, 06:15 PM
Thanks for the speedy responce, now how about a list in a class!
My code looks like this:
#class People
List (ThePeople$);
Proc Add
Add (ThePeople$);
ThePeople$ = "Paul";
Add (ThePeople$);
ThePeople$ = "Tom";
End;
Proc Show
ShowMessage(ThePeople$);
End;
#Classend
But when I showmessage (ThePeople$) I only get one entry and not the list added, I guess
kornalius
10-06-2006, 08:12 PM
If you want to see all entries use the following:
ForEach(ThePeople$)
ShowMessage(ThePeople$);
end;
Here is the code I just tested that works great:
#class People
List(ThePeople$);
private(ThePeople$);
public proc AddIt
Add(ThePeople$);
ThePeople$ = "Paul";
Add(ThePeople$);
ThePeople$ = "Tom";
End;
public proc Show
ForEach (ThePeople$)
ShowMessage(ThePeople$);
end;
End;
#EndClass
proc main
#object people p$
p.AddIt;
p.Show;
end;
kornalius
10-06-2006, 08:14 PM
You have to make ThePeople$ either private or public. This way ThePeople$ is not only part of the init section of the class.
Paul Fielder
10-07-2006, 08:33 PM
Kornalius, it's the private(ThePeople$) that was missing everything is now working.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.