Structure recognition problem

Just starting out? Need help? Post your questions and find answers here.
tseyfarth
User
User
Posts: 77
Joined: Sun Dec 05, 2010 8:05 pm

Structure recognition problem

Post by tseyfarth »

Hello all!

I have many many files in my project. The other day, I was very very happy to get them all ported to PB so that it would at least compile (may not work but that is for another day). Now that I have the basis done, I started porting another file. This time, it uses structures that are declared in other files. Here are some details:

Code: Select all

Structure AccountsRec
   AccessCode.l ;As Long           ; Integer
   FirstName.s{30} ;As String * 30             ; String
   LastName.s{30} ;As String * 30              ; String
   Address.s{50} ;As String * 50               ; String
   City.s{50} ;As String * 50          ; String
   State.s{2} ;As String * 2          ; String
   AccessUnits.s{250} ;As String * 250
EndStructure 
Global Dim Accounts.AccountsRec(1)


Here is the code trying to access the structure:

Code: Select all

Procedure.w  RemoteEvent(Address.l, Slot.w, Remote_Response_Data.s, Module_Type.s, Module_Device_No.l = 0, Remote_Date.s=#NULL$, Remote_Time.s = #NULL$,DrOpen.a=#False, DispAlarm.a = #False, MstcMuxAddress.l=0, Count.w=0, ExtraData.s = #NULL$);.w ; As Integer
Protected Stat.w ; As Integer
   ;Clear these out so it displays properly if there is an invalid code...
    Accounts(1)\FirstName = ""
    Accounts(1)\LastName = ""

The compiler complains on the line Accounts(1)\FirstName.
However, if I put this same line into the Main file, which is the default target, it compiles just fine (I do have to remove the offending file from the project in it).

All files are part of an include list that is accessed before this file is (in code, not sure in compile).

This is the Main file starting code:

Code: Select all

EnableExplicit
IncludeFile "IncludeFiles.pbi" 
It immediately calls an IncludeFiles.pbi file:

Code: Select all

IncludeFile "Globals.pbi"
IncludeFile "Initialize.pb"
IncludeFile "Poll.pbi"
IncludeFile "Decode Global.pb"
IncludeFile "Decode Voltage.pb"
IncludeFile "Decode Wireless.pb"
IncludeFile "Make String.pb"
IncludeFile "Manage License.pbi"
IncludeFile "Act On Status.pb"
IncludeFile  "Database\PSQL_Accounts.pbi"
Thought this would make it nice and neat, separating out the includes etc, easy to find and manage.

The only thing I can think of, is PB wants these structures to be reviewed before anything else. But that does not seem realistic to me, nor does it make sense since the Main file is not accessing this data or structures either. Or. it wants the files with the Structures listed FIRST, then the others? I may not be explaining this well - because I don't really know what is going on.

Can anyone enlighten me?

Thank you
Tim
tseyfarth
User
User
Posts: 77
Joined: Sun Dec 05, 2010 8:05 pm

Re: Structure recognition problem

Post by tseyfarth »

OK, found a fix but still do not understand why. So long as the file that has the structure is include *before* the one that may use it, there is no problem.

Is there any way around this?
Tim
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Structure recognition problem

Post by Trond »

Is there any way around this?
Tim
No, you must declare the structure before you can use it, else the compiler can't know about it.
tseyfarth
User
User
Posts: 77
Joined: Sun Dec 05, 2010 8:05 pm

Re: Structure recognition problem

Post by tseyfarth »

So as I found, the file that it/they are in, must be *included* prior to others. Not just declared before use. I guess What I was thinking was that the include list was run, then having that the compiler went on its way, so the order of the include list did not matter - apparantly I was wrong.

Thanks for the confirming response!
Tim
Post Reply