Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Declined Extend GOSUB to work with LIBRARY

Aug
1,915
68
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
 
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! :)
 
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
 
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
 
Yes, I have added;
Code:
library /r /u datesubs.library
to my 4start.btm, so that it gets loaded on startup.

Joe
 
How about changing the existing datesubs.btm file so the subroutines in it call datesubs.library and return those results?

That would avoid having to change every program that uses gosub "c:\users\jlc\utils\datesubs" 1231
 
Back
Top