Jump to content
Developer Wiki and Function Reference Links ×

What am I doing wrong?


Petri

Recommended Posts

Something odd here:

---------------------------------------------------------

PROCEDURE CheckForSymbol;

BEGIN

ok := FALSE;

theSymbol := GETOBJECT(PMARKER1);

symName := GETSDNAME(theSymbol);

IF theSymbol <> NIL THEN ok := TRUE ELSE ALRTDIALOG(CONCAT('No such symbol as ', symName));

END;

BEGIN

Initialise;

MESSAGE(PUSESYMBOL);

IF PUSESYMBOL THEN CheckForSymbol;

IF ok THEN UseSymbol ELSE BEGIN

---------------------------------------------------------

PUSESYMBOL is FALSE; nevertheless, the procedure CheckForSymbol is executed and the whole PIO fails.

Am I blind once again?

EDIT

To clarify: this morning the construct was this:

---------------------------------------------------------

PROCEDURE UseSymbol;

BEGIN

SYMBOL(PMARKER1, 0, 0, 0);

END;

BEGIN

IF PUSESYMBOL THEN UseSymbol ELSE BEGIN

Initialise;

---------------------------------------------------------

That worked technically, but not for the user. The "Initialise" routine essentially contains

---------------------------------------------------------

PROCEDURE Initialise;

BEGIN

ok := GETCUSTOMOBJECTINFO(myName, me, rHd, wHd);

---------------------------------------------------------

and reading of parameters into variables.

("ok" is a temporary Boolean I use everywhere, many times in any script or PIO. Should not cause the problem.)

Edited by Petri
Link to comment

Petri

I looked at this for quite some time, and the only thing that I see that looks a bit off is PUSESYMBOL. If I wrote this I'd probably use a param name with a space so that it read nicely in OIP: "Use Symbol".

What kind of havoc is wreaked in a PIO that has a parameter reference with an underscore missing I do not know....do you? I would think it'd be a "Identifier Not Declared" error, but maybe not.

In any case, it's nice to know someone's paying attention don't you think?

Charles

Link to comment

Charles,

I always have "alternative names" for parameters, so that I can recycle code and also change (or translate!) the user interface. In this case the parameter is called useSymbol, but shown as "K?yt? symbolia".

Yes, it is indeed nice to know someone's paying attention.

But this is truly baffling: how can a test for a Boolean fail this way?

Link to comment

Another one. In an object script:

-------------

ok := GETCUSTOMOBJECTINFO(myName, me, recHd, wallHd);

IF me = LNEWOBJ THEN isNew := TRUE ELSE isNew := FALSE;

-------------

Why isn't the newly-created object 'me' LNEWOBJ? After the above, isNew = FALSE.

Or perhaps someone knows & reveals how to establish that the incidence of the PIO is a new object. If so, I'll donate an auto-numbering routine which this is supposed to be a part of.

Link to comment

LOBJECT (instead on LNEWOBJ) seems to work, so I win the prize!

OK - this was my mistake: I forgot that a PIO is a "layer".

EDIT

I'll donate it anyway:

In the main program:

-----------------

IF (autoNumber AND isNew) THEN GenerateSerialNo;

-----------------

and the call is to

-----------------

PROCEDURE GenerateSerialNo;

BEGIN

n := COUNT(R IN [myName]);

theID := NUM2STR(0, n);

END;

-----------------

which of course should be a function...

In addition, somewhere (like in the standard "Initialisation" -procedure) we need

-----------------

ok := GETCUSTOMOBJECTINFO(myName, me, recHd, wallHd);

IF me = LOBJECT THEN isNew := TRUE ELSE isNew := FALSE;

autoNumber := PAUTONUMBER; { Boolean parameter }

-----------------

not to forget

-----------------

VAR

n, ID : INTEGER;

myName, theID : STRING;

me : HANDLE;

autoNumber, isNew : BOOLEAN;

-----------------

Phew! Thanks to the trusty old VW 12, I'm making progress instead of playing games.

Edited by Petri
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...