Internet PLC Forum

General => Technical support => Topic started by: Steve Ebstein on February 17, 2004, 06:43:16 PM

Title: Compiler error ?
Post by: Steve Ebstein on February 17, 2004, 06:43:16 PM
When compiling a special function with lots of nested IF THEN ELSEs, I get "Unknown keyword" error that shows up a variable. I delete most of the function, it compiles, I paste the code back, it compiles, then I go to transfer the program to the PLC and it bombs on the compile with "unknown keyword". Any suggestions ?
Title: Re:Compiler error ?
Post by: support on February 18, 2004, 02:07:09 PM
You will have to carefully match each IF THEN ELSE with its own ENDIF otherwise sometimes the compiler will encounter an error that it does'nt understand and hence report as "unknown keyword".

If you still have trouble compiling that function, then send it to us at support@tri-plc.com and we can try to see what's going on.
Title: Re:Compiler error ?
Post by: Steve Ebstein on February 18, 2004, 02:48:08 PM
I found the problem - I was misusing the IF THEN ELSE syntax. So I guess 'unknown keyword' really means 'syntax error'.
Title: Re:Compiler error ?
Post by: Joel Moore on February 27, 2004, 11:17:04 AM
I've often been confused by strange behavior from the compiler.  Nothing major, though, and since I recognize that it's probably no simple task writing any sort of compiler I figured the infrequent quirks aren't worth raising a stink about.  Although I may compile a list of them over time to submit here just so the developers are aware of them.
Title: Re:Compiler error ?
Post by: corley on March 10, 2004, 07:23:21 AM
I have seen a strange thing.. at least it seems strange to me being a native VB/QBasic programmer.. but I've noticed the you cannot include the THEN syntax in the IF THEN statement when using integer values. For example.. I have to use the following:

IF A<B
   [...code]
ENDIF

however if using strings I use this:

IF STRCMP(A$, "SOME_STRING")=0 THEN
    [...code]
ENDIF

If I try to include 'THEN' after integer constants or variables I get a syntax error. Maybe you can work with that and see.


This is different when using
When compiling a special function with lots of nested IF THEN ELSEs, I get "Unknown keyword" error that shows up a variable. I delete most of the function, it compiles, I paste the code back, it compiles, then I go to transfer the program to the PLC and it bombs on the compile with "unknown keyword". Any suggestions ?
Title: Re:Compiler error ?
Post by: support on March 11, 2004, 07:13:24 PM
I tried the following program fragment with both "THEN" and without "THEN" and didn't encounter any problem in either case. I used the TRiLOGI version 5.3 to test. As far as I know, the latest TRiLOGI version 5.3 has fixed some problems related to use of complex relational statement in the IF command. Maybe you like to upgrade to 5.3 and check if it take care of your reported problem.

-----code tested -----

IF STRCMP(A$, "SOME_STRING")=0 THEN
    B$ = "same"
ELSE
   B$ = "Not the same"
ENDIF