Jump to content
Developer Wiki and Function Reference Links ×

Help(!) with NIL handle


VectorGeek

Recommended Posts

Hey y'all:

 

We have a custom Path PIO that we use to track various areas (unit overall, storage, balcony) for apartment units. So that I can create a database worksheet that summarizes all the areas, unit by unit, I am working on a command that posts the areas from two small path polys to a larger path poly. The user would run this command before recalculating the database worksheet. I'm using a few ForEachObject() procedures (one in the main procedure, and two in a subroutine) to cycle through the objects, looking for a match by "unit number". Here is the code:

 

Procedure bindareas;

VAR
    h : HANDLE;
    hProcessStorage, hProcessBalcony : HANDLE;
    TheUnitNumber, StorageArea, BalconyArea : STRING;

 

Procedure process_storage (hProcessStorage : HANDLE);
BEGIN
    IF GetRField(hProcessStorage,'VG-Area Poly','unitnumber') = TheUnitNumber THEN
    BEGIN
        {get the storage area and post it to the source object}
        StorageArea := GetRField(hProcessStorage,'VG-Area Poly','calculatedarea');
        SetRField(h,'VG-Area Poly','boundstorage', StorageArea);    
    END;
END;

 

Procedure process_balcony (hProcessBalcony : HANDLE);
BEGIN
    IF GetRField(hProcessBalcony,'VG-Area Poly','unitnumber') = TheUnitNumber THEN
    BEGIN
        {get the balcony area and post it to the source object}
        BalconyArea := GetRField(hProcessBalcony,'VG-Area Poly','calculatedarea');
        SetRField(h,'VG-Area Poly','boundbalcony', BalconyArea);        
    END;
END;

    
Procedure do_me (h : HANDLE);
BEGIN
    TheUnitNumber := GetRField(h,'VG-Area Poly','unitnumber');
    ForEachObject(process_storage,((NOTINDLVP & NOTINREFDLVP & (R IN ['VG-Area Poly']) & ('VG-Area Poly'.'polyclass'='Area-Storage'))));
    ForEachObject(process_balcony,((NOTINDLVP & NOTINREFDLVP & (R IN ['VG-Area Poly']) & ('VG-Area Poly'.'polyclass'='Area-Balcony Open'))));
END;
    
BEGIN {main}
    ForEachObject(do_me,((NOTINDLVP & NOTINREFDLVP & (R IN ['VG-Area Poly']) & ('VG-Area Poly'.'polyclass'='Area-Strata'))));
    ResetObject(h);
END;

Run(bindareas);

 

When I run it, it works, except for the posting of values to the main Path PIOs (the SetRField() procedures). In the subroutines “process_storage” and “process_balcony”, I am getting an error in the debugger that the handle called “h” is NIL so it doesn't execute the SetRField() routine. I don’t really understand passing handles to subroutines very well so I think it’s probably something simple.

 

Any help would be greatly appreciated.

 

All the best,

 

V-G

 

Link to comment

It is available, but as you do not set it, it has a default value that is NIL.

 

May be you can try something like:

 

Procedure do_me (myH : HANDLE);
BEGIN
    h := myH;
    TheUnitNumber := GetRField(h,'VG-Area Poly','unitnumber');
    ForEachObject(process_storage,((NOTINDLVP & NOTINREFDLVP & (R IN ['VG-Area Poly']) & ('VG-Area Poly'.'polyclass'='Area-Storage'))));
    ForEachObject(process_balcony,((NOTINDLVP & NOTINREFDLVP & (R IN ['VG-Area Poly']) & ('VG-Area Poly'.'polyclass'='Area-Balcony Open'))));
END;

 

Link to comment

I think the score of variables with the same name is confusing. You have h defined as a global variable. Do_me also defines h, which is local for do_me and takes precedence— the arguments in a function definition are essentially like a VAR block for that function. 

 

If you rename your global as gH, and in do_me set gH := h, you may be good. 

 

You also may want to restructure your script a bit to make calculated area a global and add an & statement to the do_me FEO criteria so you also only search for object matching the unit number. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...