Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Error when using an array of types


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-27-2007, 07:21 PM
Newbie
 
Join Date: Oct 2007
Posts: 1
Unhappy Error when using an array of types

Hi,

could someone help me with this :

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.

Any idea ? Is this a bug ?
Reply With Quote
  #2 (permalink)  
Old 10-27-2007, 07:47 PM
taximania's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 238
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Once you've declared a Global variable, you can't change its size
__________________
Endemol
Waste of space

O2 XDA Artemis Touch Flo 4.02 Full Cube Rom WM6.1

http://www.taximania.net
Reply With Quote
  #3 (permalink)  
Old 10-27-2007, 07:53 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

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
    Dim Type(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).
Reply With Quote
  #4 (permalink)  
Old 10-27-2007, 07:54 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by taximania View Post
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

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing

Last edited by Cableguy : 10-27-2007 at 07:57 PM.
Reply With Quote
  #5 (permalink)  
Old 10-27-2007, 08:29 PM
taximania's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 238
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by taximania View Post
Once you've declared a Global variable, you can't change its size
I meant a Global Array.
I stand corrected

But: I'm even more confused now

Code:
Dim Depart(NbDepart,5)
    Depart(0).dep = 13331
Doesn't that make an Array of NbDepart(5)

So shouldn't it be NbDepart(0).dep = 13331 etc
__________________
Endemol
Waste of space

O2 XDA Artemis Touch Flo 4.02 Full Cube Rom WM6.1

http://www.taximania.net
Reply With Quote
  #6 (permalink)  
Old 10-27-2007, 09:19 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

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.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Different Line Types ceaser Code Samples & Tips 4 08-20-2008 02:39 PM
Nullifying an Array mjcoon Questions & Help Needed 1 06-20-2008 06:20 PM
Array but not array Cableguy Questions & Help Needed 1 09-22-2007 09:09 PM
Array of Array possibility? Stellaferox Basic4ppc Wishlist 0 09-18-2007 01:16 PM
Undeclared array error with version 5 mwaite Questions & Help Needed 6 05-19-2007 11:39 AM


All times are GMT. The time now is 10:01 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0