robert fuschetto Posted October 12, 2021 Share Posted October 12, 2021 I have this and it works in the code below: -SET &RM = IF &DATEM EQ 01 THEN -118 ELSE -119; I need to make it more complicated and I get this error: ERROR AT OR NEAR LINE 51 IN PROCEDURE _ADHOCRQFOCEXEC * (FOC266) IF THEN ELSE SYNTAX ERROR What do I have wrong I do not even have 51 linesthe error is s a result of the SET statement though -SET &RM = IF &DATEM GE 01 THEN -118 ELSE IF &DATEM GE 02 THEN -119 ELSE IF &DATEM GE 03 THEN -120 ELSE IF &DATEM GE 04 THEN -121 ELSE IF &DATEM GE 05 THEN -122 ELSE IF &DATEM GE 06 THEN -123 ELSE IF &DATEM GE 07 THEN -112 ELSE IF &DATEM GE 08 THEN -113 ELSE IF &DATEM GE 09 THEN -114 ELSE IF &DATEM GE 10 THEN -115 ELSE IF &DATEM GE 11 THEN -116 ELSE -117; TABLE FILE TBLMSTR_CALENDARPERIOD BY TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.PERIODTEXT BY TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.ROLLINGMONTHS WHERE TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.ROLLINGMONTHS LE &RM; ON TABLE SET PAGE-NUM NOLEAD ON TABLE SET ASNAMES ON ON TABLE NOTOTAL ON TABLE PCHOLD FORMAT HTML ON TABLE SET HTMLEMBEDIMG ON ON TABLE SET HTMLCSS ON ON TABLE SET STYLE * INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/warm.sty, $ ENDSTYLE END Thanks!!! Link to comment Share on other sites More sharing options...
David Beagan Posted October 12, 2021 Share Posted October 12, 2021 You need to have the - on each new line of the -SET statement. -SET &RM = IF &DATEM GE '01' THEN -118 ELSE -IF &DATEM GE '02' THEN -119 ELSE -IF &DATEM GE '03' THEN -120 ELSE -IF &DATEM GE '04' THEN -121 ELSE -IF &DATEM GE '05' THEN -122 ELSE -IF &DATEM GE '06' THEN -123 ELSE -IF &DATEM GE '07' THEN -112 ELSE -IF &DATEM GE '08' THEN -113 ELSE -IF &DATEM GE '09' THEN -114 ELSE -IF &DATEM GE '10' THEN -115 ELSE -IF &DATEM GE '11' THEN -116 ELSE -117; It seems like it would always set a value of &RM = -118. Link to comment Share on other sites More sharing options...
Matt Chapin Posted October 12, 2021 Share Posted October 12, 2021 robertf: &DATEM Is this numeric or alphanumeric The way I read this is that it is numeric and you are comparing it to an alphanumeric and that cannot be done. If alpha, add quotes around it, not sure if quotes are being passed in. Also, you may want to change GE to EQ. If you can run with SQL trace or add an echo statement, you can see the output to see how its being evaluated. Link to comment Share on other sites More sharing options...
john cullen Posted October 12, 2021 Share Posted October 12, 2021 Like pealing an onion. Remember, that when an if / then / else is satisfied, it exits and passes to the semi-colon, skipping the rest of the evaluations. So, peal from the top, or peal from the bottom. -SET &RM = IF &DATEM LE 01 THEN -118 ELSE -IF &DATEM LE 02 THEN -119 ELSE -IF &DATEM LE 03 THEN -120 ELSE -IF &DATEM LE 04 THEN -121 ELSE -IF &DATEM LE 05 THEN -122 ELSE -IF &DATEM LE 06 THEN -123 ELSE -IF &DATEM LE 07 THEN -112 ELSE -IF &DATEM LE 08 THEN -113 ELSE -IF &DATEM LE 09 THEN -114 ELSE -IF &DATEM LE 10 THEN -115 ELSE -IF &DATEM LE 11 THEN -116 ELSE -117; Run it with -SET &ECHO=ALL at the top will help you evaluate if you need quotes or no quotes for the equality test. (sometimes its hard to type focus code in this forum becuase it gets treated like html, or hits some autoformatting. add a space between the the dash and IF, like - IF . Link to comment Share on other sites More sharing options...
David Beagan Posted October 12, 2021 Share Posted October 12, 2021 &DATEM is a system variable. A variable is a string of characters and gets treated as either character or numeric based on how you use it. Try the following code to see: -SET &Result = &DATEM + 1; -TYPE &|Result = &Result -SET &Result = &DATEM | 'A'; -TYPE &|Result = &Result Link to comment Share on other sites More sharing options...
David Beagan Posted October 12, 2021 Share Posted October 12, 2021 RobertF, one other thought, if you really intended for your GE operators to be EQ operators, I think the whole thing could be done as a calculation: -SET &RM = -112 - MOD(&DATEM + 5, 12); Link to comment Share on other sites More sharing options...
robert fuschetto Posted October 12, 2021 Author Share Posted October 12, 2021 Thanks all, This just re-evolved into somethings else. I have the syntax down for the IF thoughThanks!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now