I know everyone is now mostly busy with Freebasic, but if you could still help ona powerbasic question i will appreciate it.
I need to create an Array of 50 items. I have done this by loading the list of items from a file in a function in a module.
I first declared a UDt like:
'----------------------------------------
Type Tracker
TPrefix As String * 2
TText As String * 16
Used As Integer
End Type
'-----------------------------------------
Type Virtualtracker
Mytracker (1 To 50) As Tracker
End Type
In the module i can easily add data to the array and i tested it, the information is loaded correctly:
im VArray As Virtualtracker
'-clear all
For t& = 1 To 50
Varray.mytracker(t&).Tprefix = ""
Varray.mytracker(t&).TText = ""
Varray.mytracker(t&).used = 0
Next t&
Myfile& = FreeFile
Dim Xtracker As tracker
Open "Trackers.TRX" For Random As #myfile& Len = Len(Xtracker)
For t& = 1 To 50
Get #myfile&,t&, Xtracker
If Xtracker.used = 1 Then GoSub FFFOUNDER
Next t&
Close #myfile&
Exit Function
FFFounder:
Varray.mytracker(t&).Tprefix = Xtracker.Tprefix
Varray.mytracker(t&).TText = Xtracker.Ttext
Varray.mytracker(t&).used = 1
Return
Exit Function
I want to other functions across the program to be able to read this list of 50 items from the UDT, but i can only access the data while i am in the module.
Any attempt to access the UDT from another function returns no data. I assume this has to be a issue one has to solve with a POINTER.
I need the speed of the in-memory array.
Any ideas would be welcome if you can figure out what i am trying to say.... :)
Looks like you need to dim you Varray as GLOBAL
GLOBAL Varray() AS VirtualTracker
I guess that seems right? Hard to tell from my first look at your code.
I think Paul has it right, but wanted to add that the global declaration will need to be outside any sub or function.
Hi ALL
Nope, that doesnt help either.
I will try something else, 50 items isnt going to cause of much of a speed problem.
I will just load the process in the specific form and not bother with all this nested UDT's. That seem to be a problem here.
Thanks for the help guys.
_Peter
In your code it seems you are defining variable inside a function. That is a local, variable that is destroyed when function exit.
Suggested GLOBAL declaration should work and variable be seen across your modules as far as:
- declared outside any function/sub
- declared in a module that is loaded before the global variable is used
Hi all
Thanks a million. Will Go give it a try and let you know if i got it working.
-Pete