Author Topic: Compiler error ?  (Read 7383 times)

Steve Ebstein

  • Guest
Compiler error ?
« 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 ?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3170
    • View Profile
    • Internet Programmable PLCs
Re:Compiler error ?
« Reply #1 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.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Steve Ebstein

  • Guest
Re:Compiler error ?
« Reply #2 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'.

Joel Moore

  • Full Member
  • Posts: 128
    • View Profile
Re:Compiler error ?
« Reply #3 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.

corley

  • Newbie
  • Posts: 15
    • View Profile
Re:Compiler error ?
« Reply #4 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 ?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3170
    • View Profile
    • Internet Programmable PLCs
Re:Compiler error ?
« Reply #5 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
« Last Edit: March 11, 2004, 07:14:27 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS