Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Pass a constant into an include file


--dd-- Sep 29, 2022 11:54 AM

How can I pass a constant into an Include file without losing its const property?

Include "CPU:Include.CR1X"

Const PI = 3.141592654
Const PI_2 = PI * 2

BeginProg
  Scan (1,Sec,0,0)

   NextScan
EndProg

 CPU:Include.CR1X

Const PI_3 = PI * 3

 

[Version]C:\Campbellsci\Lib\Compilers\CR1000XComp.exe VERSION:CR1000X.Std.05.01  DATE:05/10/2021test.CR1X -- Compile Failed!
<Include.CR1X> line 1: Variable used in CONST expression.

If i declare PI_2 in the main program it works fine, but if i do the same (PI_3) in the include file i get a compile error. Is there any way to pass a constant into the include file?


JDavis Sep 29, 2022 07:09 PM

Try with the Include after the other constant declarations.


--dd-- Oct 1, 2022 10:22 AM

Thanks. That of course helped. 

Log in or register to post/reply in the forum.