I can't seem to get the following syntax to work. I am trying to convert a term code into a year and a season. The codes are 6 characters (really all numbers). The first four represent the year and the last two represent the season (fall or spring). If the season is fall, then you need to subtract 1 from the year. If the season is spring, then you use the year "as is". So, 202020 is Spring 2020, but 202010 is Fall 2019. When I run my report I want the user to enter the term code and then I want to figure out the semester so that in my headings I can say "Spring 2020" or "Fall 2019". In the code below, &term_season, &term_year1, and &term_year2 work fine when I -TYPE them out, but I can't get &term_year to work. I keep getting a syntax error. I've tried a bunch of things but can never get it to work. Any help would be appreciated!
-SET &term_season = IF EDIT(&term_code,'$$$$99') EQ '10' THEN 'Fall' ELSE IF EDIT(&term_code,'$$$$99') EQ '20' THEN 'Spring' ELSE 'Other'; -TYPE term_season is &term_season -SET &term_year1 = EDIT(&term_code,'9999'); -TYPE term_year1 is &term_year1 -SET &term_year2 = &term_year1 - 1; -TYPE term_year2 is &term_year2 -SET &term_year = IF &term_season EQ 'Fall' then &term_year2 ELSE IF &term_season EQ 'Spring' THEN &term_year1 ELSE ''; -TYPE term_year is &term_year
Here is my output:
An error has occurred
Detail: term_season is Spring term_year1 is 2020 term_year2 is 2019 ERROR AT OR NEAR LINE 28 IN PROCEDURE ADHOCRQ FOCEXEC * (FOC266) IF .. THEN .. ELSE .. SYNTAX ERRORThis message has been edited. Last edited by: FP Mod Chuck,
April 08, 2020, 06:14 PM
The SYNTAX ERROR is because your first then is lower case ... it needs to be THEN (Upper Case)
WebFocus 8.201M, Windows, App Studio
April 09, 2020, 07:15 PM
Agreed. The keyword THEN needs to be capitalized.
Also, I have noticed that when using DM commands, it is helpful to use the .EVAL or .QUOTEDSTRING on the parameters:
-SET &term_year = IF &term_season.EVAL EQ 'Fall' THEN &term_year2.QUOTEDSTRING ELSE IF &term_season.EVAL EQ 'Spring' THEN &term_year1.QUOTEDSTRING ELSE '';
This message has been edited. Last edited by: Hallway,