Page 1 of 1

Structure Arrays

Posted: Thu Sep 23, 2010 10:26 am
by orb_505
Hi all,

I'm having a bit of a nightmare with this one and was wondering if anyone could help.

I'm making a Structure, within that Structure is a Array:

Code: Select all

Structure Systems
  SystemName.s
  DefaultPath.s
  FileList.s[50]
EndStructure
I then create an Array of that that Structure:

Code: Select all

Dim SystemsList.Systems(20)
I then want the try and populate the FileList Array from an INI file:

Code: Select all

      If ExaminePreferenceKeys()
        While NextPreferenceKey()
          If UCase(PreferenceKeyName()) = "DEFAULTPATH"
            SystemsList(GroupNum)\DefaultPath = PreferenceKeyValue()
          EndIf
          If UCase(Left(PreferenceKeyName(),4)) = "FILE"
            FilesInINI = FilesInINI + 1
            SystemsList(GroupNum)\FileList(FilesInINI) = PreferenceKeyValue()
          EndIf
        Wend
      EndIf
But I keep getting the error 'Garbage at End of Line' for this line SystemsList(GroupNum)\FileList(FilesInINI) = PreferenceKeyValue()

Any help appreciated!

Mark

EDIT:

FYI the INI file looks like this:

Code: Select all

[Type 1 System]
SystemName = Joe Bloggs System
DefaultPath = C:\Program Files\JBloggs\Database\System\
File1 = Names.DAT
File2 = Supply.DBD
File3 = Institution.DAT
    
[Type 2 System]
SystemName = Jimmy System
DefaultPath = C:\
File1 = Names.MDB
File2 = Address.DAT
File3 = TBL.DAT

Re: Structure Arrays

Posted: Thu Sep 23, 2010 10:49 am
by srod
You have defined the FileList field as a static array (you have used square brackets). That is fine, PB 4.51 can cope with either static or dynamic arrays within structures. However, because you are using a static array you must persevere with the square brackets.

Code: Select all

SystemsList(GroupNum)\FileList[FilesInINI] = PreferenceKeyValue()

Re: Structure Arrays

Posted: Thu Sep 23, 2010 2:59 pm
by orb_505
Thank you very much sir!

Re: Structure Arrays

Posted: Thu Sep 23, 2010 3:06 pm
by orb_505
On that subjuct of fixed or dynamic arrays. Can you not have a dynamic array in a Structure?

EG:

Code: Select all

Structure Systems
  SystemName.s
  DefaultPath.s
  FileList.s(50)
EndStructure
I've tried it but I get the Garbage error again.

Re: Structure Arrays

Posted: Thu Sep 23, 2010 3:08 pm
by orb_505
Forget it, I'm on 4.50 not 4.51 :oops: I'll upgrade

Re: Structure Arrays

Posted: Thu Sep 23, 2010 3:13 pm
by srod
You'll need something like :

Code: Select all

Structure Systems
  SystemName.s
  DefaultPath.s
  Array FileList.s(50)
EndStructure