I'm using a array of type :
Sub Globals
Dim Type(Dep, Arr, Fic1, Fic2, Tra) Depart (1)
Then, in a procedure, I'm reading the size of the array :
NbDepart = FileRead (c1)
I'm sizing the array :
Dim Depart (NbDepart)
But then I've got an error when trying :
Depart(0).Dep = 1
---
I've tried to put a fixed size on the array of type and it works.
I've tried to add 1 to NbDepart, to be sure it's concerted to an integer but it does not work.
One dimension array-structures are actually two dimension arrays where the second rank value equals to the number of fields.
You must use the array syntax to resize the structure:
Code:
Sub Globals DimType(Dep, Arr, Fic1, Fic2, Tra) Depart (0) End Sub
Sub App_Start Dim Depart(NbDepart,5) Depart(0).dep = 13331 Depart(1).Tra = 321 End Sub
Quote:
Once you've declared a Global variable, you can't change its size
You can resize an array any number of times during a program (resizing an array will clear all its records).
Once you've declared a Global variable, you can't change its size
Not true...
I have used globals before, and have their initial value (set in the globals sub) altered in other subs....
I'm thinking more of a file related error...
Code:
NbDepart = FileRead (c1)
Have you open the file for reading?
Are you sure you aren't getting an empty string?
EDIT: Erel beat me to the clock and as always he knows best...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France-Saumur
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate) B4PPC DLL Version Listing - B4Android DLL Version Listing
NbDepart is an integer. We like to resize Depart which is an array of structures.
As I wrote, an array of structures is actually a two dimensions array.
So:
Depart(0).Fic1 = 3 equals to Depart(0,2) = 3
And when we need to resize Depart we write:
Dim Depart(100,5) or Dim Depart(NbDepart,5) where 5 is the number of fields.
I want to resize an array declared in global and yet be able to retain the data in the array. i.e. if I have an array a(5) and there is data in all the five elements. Now I want to make the array a(10), I need to have the data in the first five elements as it is and the next 5 elements would be clear. In vb6 we get this by using "Preserve" with Redim.
Please let me know if this is possible in B4PPC. Moreover, if not possible what could be the workaround to get this done?