Extend GOSUB to work with LIBRARY

#1
From the help file;
You can call a subroutine in another file by specifying filename (the name must be enclosed in double quotes, and the file cannot have been compressed with BATCOMP). This allows you to create libraries of subroutines, without having to duplicate them in each batch file. For example:
Code:
gosub "c:\library\batlib.btm" Evaluate [%1 %2 %3]
It would be great if I could use GOSUB to call a subroutine that is located in a LIBRARY

The only way I can do it now is to take the subroutines that I have in a .BTM, and separate them into individual LIBRARY functions, so that they can be called from a .BTM


Joe
 
May 30, 2008
212
1
#2
Can't you just CALL the library function directly?

I don't see why would GOSUB be needed in this case. Then again, have not tried to use library functions myself yet! :)
 
#3
As an example, I have a .BTM called datesubs.btm that I call from several .BTMs. From one of the .BTMs, I call it as;
Code:
@if %_isodate le %_year-12-31 gosub "c:\users\jlc\utils\datesubs" 1231
The datesubs.btm (partial) contents;
Code:
:0321
@set eventday=03-21
@set eventname=Spring!
@gosub setevent
@return

:1221
@set eventday=12-21
@set eventname=Shortest Day of The Year!
@gosub setevent
@return

:1225
@set eventday=12-25
@set eventname=Christmas!
@gosub setevent
@return

:1231
@set eventday=12-31
@set eventname=Last Day Of %_year
@gosub setevent
@return
Instead of having this in datesubs.btm, I want to have it as a LIBRARY called datesubs, that I can call as;
Code:
@if %_isodate le %_year-12-31 gosub datesubs 1231
from a .BTM file.

Joe
 
#4
I have changed the above as follows;
Code:
0321 {
@set eventday=03-21
@set eventname=Spring!
setevent
}

1221 {
@set eventday=12-21
@set eventname=Shortest Day of The Year!
setevent
}

1225 {
@set eventday=12-25
@set eventname=Christmas!
setevent
}

1231 {
@set eventday=12-31
@set eventname=Last Day Of %_year
setevent
}
...and I can now call it as;
Code:
:: The 1221 is in DateSubs.library
@if %_isodate le %_year-12-21 1221
which works, but instead of having my routines in a .BTM, I have to convert the .BTM to a .LIBRARY as I did above, and change all of the calling .BTM programs.

Would still like to see the changes made to GOSUB as I have indicated in my original post.

Joe