Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

"Error in script line: endsub" - no idea - help plz


Hi,

I have worked with subroutines a few times, but not often. Usually I had to pass only one parameter to the subroutine. This is the first intance where I have to pass two:

- A full path (with a lot of \ - I enclose that in square brackets to be sure)

- An ending.

Everything is in place. I use a command like that

>> sub Dateicheck ($(v_checkfolder), $(v_ending)) <<

>> endsub; <<

>> CALL Dateicheck ($(v_folder_to_check), $(v_ending_to_check)); <<

But I keep getting an error_message "error in script line: endsub". I have already tried some variations on this, but I guess the error lies elsewhere. Maybe in the opening sub statement? (I tried without the $() before because it's without in my other subroutines, too, but that didn't work)

Can someone help me here? I am Flasche leer;

Thanks a lot!

Best regards,

DataNibbler

13 Replies
datanibbler
Champion
Champion
Author

Hi,

still doesn't work.

A little more context might be helpful 😉

my call_statement is inside a FOR_NEXT loop where I parse a table I have created beforehand, so I do have a variable already.

And I get that error_message in the Debugger,  before it even reached the CALL statement.

>> FOR i = 0 TO (NoOfRows('RtM')-1)
   
LET v_folder_to_check = chr(39) & PEEK('Ziel', $(i), 'RtM') & chr(39);
   
LET v_ending_to_check = PEEK('Typ', $(i), 'RtM');
   
CALL Dateicheck ('$(v_folder_to_check)', '$(v_ending_to_check)');
NEXT <<<

The complete code of my subroutine is attached as a txt file.

The error_message is still the same.

marcus_sommer

It's quite difficult to find here the syntax issue's. The easiest way is most to run this step by step within the debugger.

I would as next remove the chr(39) wrapping from v_folder_to_check or call these variable within the call-statement without the single-quotes then they could be double which then led to an error.

Further I don't understand the sub from text-file. You made a join without a common field and the check to "Aktuell" could be done within the first load.

- Marcus

tcullinane
Creator II
Creator II

what is the purpose of $ expansion in the Sub and Call statements?

Try Like:

>> sub Dateicheck (v_checkfolder, v_ending) <<

....use $(v_checkfolder) and $(v_ending) within the sub...

>> endsub; <<

>> FOR i = 0 TO (NoOfRows('RtM')-1)
   
LET v_folder_to_check = chr(39) & PEEK('Ziel', $(i), 'RtM') & chr(39);
   
LET v_ending_to_check = PEEK('Typ', $(i), 'RtM');
   
CALL Dateicheck ('v_folder_to_check', 'v_ending_to_check');
NEXT <<<

datanibbler
Champion
Champion
Author

Hi,

thanks to you all!

I've seen it now.

The error, just like I thought, was somewhere else - in that subroutine, I had a FOR_EACH loop which I forgot to close. That was it.

Now there's some more trouble with the variables, but I'll get through that.

Thanks a lot!