Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is this my mistage or bug?
If INCLUDE is inside anykind of IF-clause it dosn't work!
Not work , display error message "Script line error: Call DropTables"
--------- NOT work ------------
SET QVscBase = 'JVR.SC';
IF NOT IsNull(QvdCreateTime('$(QvWorkPath)\$(QVscBase)')) then
TRACE File $(QvWorkPath)\$(QVscBase) OK!;
$(Include=$(QvWorkPath)\$(QVscBase));
ELSE
TRACE File $(QvWorkPath)\$(QVscBase) not found!;
EXIT Script;
ENDIF
Call DropTables;
-------------------------------
This work nicely
--------- work ------------
SET QVscBase = 'JVR.SC';
IF NOT IsNull(QvdCreateTime('$(QvWorkPath)\$(QVscBase)')) then
TRACE File $(QvWorkPath)\$(QVscBase) OK!;
ELSE
TRACE File $(QvWorkPath)\$(QVscBase) not found!;
EXIT Script;
ENDIF
$(Include=$(QvWorkPath)\$(QVscBase));
Call DropTables;
-------------------------------
---------- JVR.SC -------------
SUB DropTables
FOR i=nooftables()-1 TO 0 STEP -1
LET vTable=tablename(i);
DROP TABLE $(vTable);
NEXT
TRACE 'DropTables run OK';
ENDSUB
-------------------------------
Hi Jussi,
I believe the problem is not the include within the If-then-else, if you debug step through your code, you will see that it will be executed.
I think the problem is that the lifetime of your SUB routine is limited to the scope of the THEN statement part.
For example, if you add your CALL DropTables just after the include, it will work.
Probably you don't want to put all your code within that THEN statement code group.
I think what you can do is something like:
set QVscBase =./test.txt;
$(Include=$(QVscBase));
//let testTime = FileTime('$(QVscBase)');
If not isnull(FileTime('$(QVscBase)')) then
Trace Test1;
ELSE
Trace Test2;
exit script;
endif
Call DropTables;
i.e. including your code at the beginning (if the file does not exist, it won't throw an error, just doing nothing).
Then you might check for the existing of your file, exit if necessary.
then you can Call your SUB routines.
Hope this helps,
Stefan