I will preface this by saying that to the extent I can write scripts, I am self taught. I had one Fortran class in college in the mid 80's.
There is very little information about LABELS in the Vectorscript user guide that I could find, short of what it states in the GOTO statement section. And it is not easy to find info online for Labels in Pascal...not that there is much info needed: must be declared, where / how to declare them, do not declare labels not being used, AND a couple other little tidbits...
I just spent HOURS learning that if the main procedure script uses Labels, then user any user defined functions / sub-routines ALSO HAVE TO USE LABELS...even if it is just 1 label for 1 statement.
If I am mistaken please let me know, so that I can go bang my head on a wall again.
I was changing the input from a dimension type to a popup (showing / limiting options to the dimensions available) ...and needed to be able to get the input back into dimension form.
The script compiled fine before adding the user defined Str2Num function...however, after adding it, I continually got errors regarding the LABEL associated with every GOTO statement in my script. After much before mentioned head banging, experimenting and googling. I found an old website for pascal that gave a little more information about Labels - stating "Line labels defined within a procedure are exclusive to that procedure", and it gave an example showing Labels in the main and sub sections .
This information didn't solve my problem, but it did eventually ring the very small bell my head...."Do I need to add a label to the user defined function?" No idea WHY this would be necessary but I have tried everything else. So:
FUNCTION Str2Num(str :STRING) :REAL;
Label 1;
Var
num : Real;
BEGIN
1: Str2Num := 0;
IF ValidNumStr(str, num) THEN Str2Num := num;
END;
And it compiles without any errors regarding the Labels in the main procedure.
So not only do I think there should be a blurb about the possibility of adding separate labels to sub routines / procedures/ user defined functions within a main procedure or $INCLUDE files, it should state that you HAVE to use labels in those sub routines if you use them in the main procedure.
Again, if I am wrong please let me know, and where I screwed up.
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.
Question
SLFY
I will preface this by saying that to the extent I can write scripts, I am self taught. I had one Fortran class in college in the mid 80's.
There is very little information about LABELS in the Vectorscript user guide that I could find, short of what it states in the GOTO statement section. And it is not easy to find info online for Labels in Pascal...not that there is much info needed: must be declared, where / how to declare them, do not declare labels not being used, AND a couple other little tidbits...
I just spent HOURS learning that if the main procedure script uses Labels, then user any user defined functions / sub-routines ALSO HAVE TO USE LABELS...even if it is just 1 label for 1 statement.
If I am mistaken please let me know, so that I can go bang my head on a wall again.
----
I am modifying a relatively large (for me) script and added a user defined function to replace the Str2Num function as suggested on the developer page http://developer.vectorworks.net/index.php/VS:Str2Num.
I was changing the input from a dimension type to a popup (showing / limiting options to the dimensions available) ...and needed to be able to get the input back into dimension form.
The script compiled fine before adding the user defined Str2Num function...however, after adding it, I continually got errors regarding the LABEL associated with every GOTO statement in my script. After much before mentioned head banging, experimenting and googling. I found an old website for pascal that gave a little more information about Labels - stating "Line labels defined within a procedure are exclusive to that procedure", and it gave an example showing Labels in the main and sub sections .
This information didn't solve my problem, but it did eventually ring the very small bell my head...."Do I need to add a label to the user defined function?" No idea WHY this would be necessary but I have tried everything else. So:
FUNCTION Str2Num(str :STRING) :REAL;
Label 1;
Var
num : Real;
BEGIN
1: Str2Num := 0;
IF ValidNumStr(str, num) THEN Str2Num := num;
END;
And it compiles without any errors regarding the Labels in the main procedure.
So not only do I think there should be a blurb about the possibility of adding separate labels to sub routines / procedures/ user defined functions within a main procedure or $INCLUDE files, it should state that you HAVE to use labels in those sub routines if you use them in the main procedure.
Again, if I am wrong please let me know, and where I screwed up.
Now I will have to see if it actually works. 😉
Sean
Link to comment
10 answers to this question
Recommended Posts
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.