Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a directory where all my subroutines are stored. I want to load them all at once, so that I can call every subroutine without the necessity to include the text file with the subroutine first.
When I use Version A in the script (without a loop), everthing is fine:
//Version A:
$(Include=z:\documents\functions\CreateCalendar.txt);
Call CreateCalendar ('01.01.2018',Today());
But when I use the loop, it get an error (Syntax error Call >>>>>>CreateCalendar<<<<<< ('01.01.2018',Today()))
//Version B:
SET pathDataOrigin = 'z:\documents\functions\';
FOR Each File in filelist ('$(pathDataOrigin)'&'CreateCal*.txt')
$(Include=$(File));
Next File;
Call CreateCalendar ('01.01.2018',Today());
I cannot find the reason for the error. Can anyone help me with that?
The subroutine is very simple:
SUB CreateCalendar (StartDate, EndDate)
LET vDateMin = Num(StartDate);
LET vDateMax = Num(EndDate);
Calendar:
LOAD
Date($(vDateMin) + RowNo() - 1) AS Date
AUTOGENERATE 1
WHILE
$(vDateMin)+IterNo()-1<= $(vDateMax)
;
End Sub;
A quick workaround is to create an include where you include all you functions.
I am taking this example from the QDF:
A qvs including all you functions
Including the previous on your App
I hope this helps
Hi, I mocked up your codes in my PC and i think the issue is happened with your sub. I updated a little and it could return data for me. Also in your default date format setting, I updated to this: SET DateFormat='MM.DD.YYYY';
SUB CreateCalendar (StartDate, EndDate)
LET vDateMin = NUM(StartDate);
LET vDateMax = NUM(EndDate);
Calendar:
LOAD
Date('$(vDateMin)' + RowNo() - 1) AS Date
AUTOGENERATE 1
WHILE
'$(vDateMin)'+IterNo()-1<= '$(vDateMax)'
;
End Sub;
Thanks!
A quick workaround is to create an include where you include all you functions.
I am taking this example from the QDF:
A qvs including all you functions
Including the previous on your App
I hope this helps
I'm not sure what happened to my answer but it was removed somehow. So I re-posted here,
SUB CreateCalendar (StartDate, EndDate)
LET vDateMin = NUM(StartDate);
LET vDateMax = NUM(EndDate);
Calendar:
LOAD
Date('$(vDateMin)' + RowNo() - 1) AS Date
AUTOGENERATE 1
WHILE
'$(vDateMin)'+IterNo()-1<= '$(vDateMax)'
;
End Sub;
I updated your sub and it's working for me now, also you need to watch out your date format to change to below:
SET DateFormat='MM.DD.YYYY';
Thanks!
Hi, the sub itself was working as expected without the changes. But also with your changes, inserting it with the loop and then calling it leads to the described error.
Hi,
thanks for this solution, but the workaround is not my prefered option, as I would state all function names explicitly when adding new subs. And when deleting subs, I would need to remove it from this list as well, ... I'd prefer a solution where changes don't need further effort.
Thank you!
HI
Version B should be as follows
//Version B:
SET pathDataOrigin = 'z:\documents\functions\';
FOR Each File in filelist ('$(pathDataOrigin)CreateCal*.txt')
$(Include=$(File));
Next File
Call CreateCalendar ('01.01.2018',Today());
HTH
Regards
Adrian
Your logic itself should work - just run it within the debugger with a break point below the loop and then you could see within the various debugger-tabs your include-variables. I could imagine that you find the routine CreateCalendar or any other one several times …
- Marcus
Hi,
I still get the same error. Did it work for you?
Kind Regards, Nigel
Hi,
I've done that, and no, the routine just appears this one time.
The debugger itself is not very helpful in this case.
KR