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.

Variable in "Include" statement crashes compiler


kcopeland Feb 23, 2017 08:05 PM

I wasn't sure if it was possible to use a variable in an include file and so I gave it a shot.  It seems it actually crashes the compiler.

 

Public filename As String = "const.dld"

Include ("CPU:"+filename)

Public PTemp, batt_volt

'Declare Other Variables
'Example:
'Dim Counter

'Define Data Tables.
DataTable (Test,1,-1) 'Set table size to # of records, or -1 to autoallocate.
	DataInterval (0,15,Sec,10)
	Minimum (1,batt_volt,FP2,False,False)
	Sample (1,PTemp,FP2)
EndTable

'Define Subroutines
'Sub
	'EnterSub instructions here
'EndSub

'Main Program
BeginProg
	Scan (1,Sec,0,0)
		PanelTemp (PTemp,250)
		Battery (Batt_volt)
		'Enter other measurement instructions
		'Call Output Tables
		'Example:
		CallTable Test
	NextScan
EndProg

 The idea here is that I want to be able to include any file on the CPU with a .dld extension.  I'm nervous of someone changing the name of the constant file but less nervous of someone changing the extension.  So all program code would have a .cr1 extension and constants would have a dld extension.  I would then like to FileList all files on the cpu, search the array for dld extensions and then include the file based on that extension.  Can it be done?


GaryTRoberts Feb 25, 2017 06:33 PM

Kyle,

Thank you for the report.  We will get the compiler crash fixed.  I will get back to you on your other question after I have had a chance to speak with Research and Development.


jtrauntvein Feb 27, 2017 04:13 PM

It doesn't make sense to use a variable in an include statement although it might make sense to use a constant.  It's important to consider that the include statement as well as conditional compilation statements are evaluated at compile time and not at run time.  Variables have no value at compile time.


kcopeland Feb 27, 2017 04:34 PM

John-

You are correct that a variable does not make sense.  I could never see changing the include statement while the scan is running.  But at compile time, I want to find all files on the CPU and include them based on file extension.  I plan on having all program files encrypted in a CR1 extension and then have Constant declarations in a file with a DLD extension.

The idea is that if someone changes the file name of my declarations file, it would not break the main program.  It's much less likely that a person would change the file extension.  There are, however, many changes to the file name due to program revisioning.

Thanks,

Kyle

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