PDA

View Full Version : Syntax Error in macro ?


SoonTin
05-12-2004, 07:09 PM
Would someone advise me on the syntax error (if any) in the following macro (where 'DEPT' is a system variable) ?

IF ((SUBSTR (getenv 'DEPT') 1 4) = 'ENGR')
DISPLAY_NO_WAIT ( "Reading File:" + config_dir + "engr_settings.mc")
load_macro (config_dir + "engr_settings.mc")
END_IF

Thank you in advance for your kind assistance.

With best regards.

Thom Ivancso
05-13-2004, 04:10 AM
Hello

Not knowing the full body of your macro I pieced together this little example.

DEFINE Macro_name
LOCAL Department
LOCAL Config_dir
LET Config_dir 'C:\Temp\ '
LET Department (SUBSTR (GETENV 'DEPT') 1 4)
IF (Department='ENGR')
DISPLAY_NO_WAIT ( "Reading File:" + Config_dir + "engr_settings.mc")
LOAD_MACRO (Config_dir + "engr_settings.mc")
END_IF
END_DEFINE


Also some tips when writing macros for OneSpace Drafting

1: Make the first letter of variable names an uppercase letter followed by lower case

2: Keep commands all in uppercase as in GETENV

3: Do not try to shorten variable names if you do not have to for clarity purposes

4: Indent lines

5: And use lots of comment lines to help know what the code does in the future.

I also moved this thread to the Customization since it is more in line with this subject than Drafting..

Hope this helps

Thom

bfisher
05-13-2004, 10:20 AM
SoonTin, Tom,

I noticed one small little glitch in Tom's example. The definition for the config directory should include the backslash character at the end of the string, ('C:\Temp\'). Otherwise, those are great suggestions for macro writing. You can't have too many comments!

Bruce

Thom Ivancso
05-13-2004, 02:25 PM
Bruce,

It seems that if you do not put a space between the backslash and the quote it does not showup in the post. :rolleyes:


Cheers
Thom

John Scheffel
05-14-2004, 09:22 AM
You might try enclosing your macro code in CODE tags (click the # button in the edit window or click the f.a.q. button for more info). This will preserve indentation and might prevent losing the trailing slash. You can always do some trials in the Test Posts forum.

SoonTin
05-25-2004, 04:34 AM
Thank you everyone for your response and suggestion. I tried all options possible but none worked. I have decided to drop the call and I thank you for your time and kind assistance.

With best regards, SoonTin