Hello, in my code below I look for a text file. If it exists, it reads all 3 lines and sets variables.
It then looks for a file, if it exists, then it renames all of the files in the IF statement. If it doesn't find the file (it may still be in the process of being created) then it will sleep and loop again.
The program runs, it even renames the files like it's supposed to, but then it gives me:
ERROR : Loop without WHILE!
Script : (script name)
Line : 39 (which is the line with the word "LOOP")

Can someone tell me what's wrong with the code? I thought it was pretty straight up.
 Code:
IF Open(1,"L:\Sigrity_UPD\master_strips\Unit_Array\unit_array_info.txt", 0) = 0
	$DWG_NUMBER = ReadLine(1)
	$DWG_REVISION = ReadLine(1)
	$SOURCE_FOLDER = ReadLine(1)
ELSE
	? ('Cannot find the file')
ENDIF
Close (1)
; gerber name = 123456GBL010A.GBR

$CheckFile = $SOURCE_FOLDER + 'unit.dxf'

;Rename the gerber files
$TIME_OUT = 0
WHILE $TIME_OUT < 300
	IF EXIST ( $CheckFile )	;Check for unit.dxf
		IF EXIST ( $SOURCE_FOLDER + 'EB01.gbr' ) MOVE $SOURCE_FOLDER + 'EB01.gbr' $SOURCE_FOLDER + $DWG_NUMBER + 'GBEB01' + $DWG_REVISION + '.gbr'
		IF EXIST ( $SOURCE_FOLDER + 'EB04.gbr' ) MOVE $SOURCE_FOLDER + 'EB04.gbr' $SOURCE_FOLDER + $DWG_NUMBER + 'GBEB04' + $DWG_REVISION + '.gbr'
		IF EXIST ( $SOURCE_FOLDER + 'INNER.gbr' ) MOVE $SOURCE_FOLDER + 'INNER.gbr' $SOURCE_FOLDER + $DWG_NUMBER + 'GBINNER' + $DWG_REVISION + '.gbr'
		IF EXIST ( $SOURCE_FOLDER + 'L01.gbr' ) MOVE $SOURCE_FOLDER + 'L01.gbr' $SOURCE_FOLDER + $DWG_NUMBER + 'GBL01' + $DWG_REVISION + '.gbr'
		IF EXIST ( $SOURCE_FOLDER + 'L04.gbr' ) MOVE $SOURCE_FOLDER + 'L04.gbr' $SOURCE_FOLDER + $DWG_NUMBER + 'GBL04' + $DWG_REVISION + '.gbr'
		IF EXIST ( $SOURCE_FOLDER + 'S01.gbr' ) MOVE $SOURCE_FOLDER + 'S01.gbr' $SOURCE_FOLDER + $DWG_NUMBER + 'GBS01' + $DWG_REVISION + '.gbr'
		IF EXIST ( $SOURCE_FOLDER + 'S04.gbr' ) MOVE $SOURCE_FOLDER + 'S04.gbr' $SOURCE_FOLDER + $DWG_NUMBER + 'GBS04' + $DWG_REVISION + '.gbr'
		$TIME_OUT = 300
	ELSE
		sleep 20
		$TIME_OUT = $TIME_OUT + 20
	ENDIF
LOOP


Thanks,
Mark


Edited by Mart (2013-12-19 10:09 AM)
Edit Reason: Added code tags.