Ren
Sophomore Member
Retired Mainframer
Posts: 82
|
MACROs
Jun 4, 2019 7:59:52 GMT -5
Post by Ren on Jun 4, 2019 7:59:52 GMT -5
Consider these two MACROS:
TRY.MACRO which is a Line command, and
TRYME.MACRO, a Primary Command:
When TRY is executed as a line command (on line 1) it works fine:
output is:
Starting TRY
as Line Command
top = 2
bot = 2
When TRYME is executed as a Primary command, with C on line 2 Starting Tryme
lntop = 2
lnbot = 2
Calling TRY
it apparently is not calling TRY.
Source:
' TRYME.MACRO
dim top, bot, lntop, lnbot as number
top = 3
bot = 3
SPF_Debug("Starting Tryme")
lntop = Get_LNUM(top)
lnbot = Get_LNUM(bot)
SPF_Debug(" lntop = " +Tstr$(lntop))
SPF_Debug(" lnbot = " +Tstr$(lnbot))
SPF_Debug(" Calling TRY")
SPF_CMD("LINE TRY " +TSTR$(Get_LNUM(top)) +" " +TSTR$(Get_Lnum(bot)))
Halt
'TRY.MACRO
SPF_Debug("Starting TRY")
If is_primary_Cmd Then SPF_Debug(" as Primary Command")
If is_Line_Cmd Then SPF_Debug(" as Line Command")
dim top, bot, as number
top = Get_Src1_Lptr
bot = Get_Src2_Lptr
SPF_Debug(" top = " +Tstr$(top))
SPF_Debug(" bot = " +Tstr$(bot))
Halt
What am I missing? Thanks
|
|
|
MACROs
Jun 4, 2019 9:19:36 GMT -5
Post by George on Jun 4, 2019 9:19:36 GMT -5
Ren: Trying to sneak in a macro execution from another macro is just not supported. Somewhere in the nested stuff the 2nd TRY is being rejected as a macro within a macro, the message is probably getting lost somewhere in the chain.
What are you trying to accomplish?
George
|
|
Ren
Sophomore Member
Retired Mainframer
Posts: 82
|
MACROs
Jun 4, 2019 10:59:30 GMT -5
Post by Ren on Jun 4, 2019 10:59:30 GMT -5
Never mind. I worked around it. I was trying to build a MACRO, (in this case COM), that could be issued from the Command Line using C or CC-CC, or as a Line Command COM, COMn, or COMM-COMM. I got it working.
But I do have a question. In REXX:
stuff Call ABC Return
ABC: stuff Return
How is this done in ThinBASIC? I see you just issue ABC as the call, but could not figure out how/where to declare the actual procedure (ABC). Also, REXX first looks for ABC in the executing code, if it is not there it looks to the PDS, assigned to SYSEXEC. So, in ThinBASIC, what would the (external) CALL statement look like, and where and what extension would ABC be?
One last question how do you continue a too long command onto the next line?
Thanks.
|
|
|
MACROs
Jun 4, 2019 13:09:31 GMT -5
Post by George on Jun 4, 2019 13:09:31 GMT -5
Ren: Do you want the ABC function to be a self contained file (like from a library) , or just a callable function within the macro?
If just internal, create your FUNCTION MyFunc(P1 as xxx, P2 as yyy) as zzz . . END FUNCTION and stick it at the end of your macro code. Make sure your main line has some kind of exit at the end just in case of 'fall-through'
There is a section in the HELP MACROS doc on "Locating Macros and INCLUDE files", read that first.
George
|
|
Ren
Sophomore Member
Retired Mainframer
Posts: 82
|
MACROs
Jun 5, 2019 14:17:33 GMT -5
Post by Ren on Jun 5, 2019 14:17:33 GMT -5
I've been reading. Thanks. (I like the #INCLUDE).
I've not yet tried a function call yet. But within a program it looks fairly straight forward. However, I need to build one, callable from multiple other programs. Can I just build it like an internal Function, and house it WHERE? Or is there more to it than that?
-----
Generally, why to some commands have a $ after them and some don't?
For example: Get_SETVARS$ and Set_SETVARS.
Speaking of SETVARS, is there a DEL_SETVARS, or an ERASE_SETVARS, or the equivalent?
-----
DIM question. I have a 3 statements:
tos = Get_TopScrn_LPtr
clp = Get_Csr_LPtr
cpc = Get_Csr_Col
dim tos, clp, cpc as number it gets an error: Variable name already defined (Duplicated generic) tos = Get_TopScrn_LPtr
but when I use dim clp, cpc as a number it works fine.
why do I not define tos in the DIM statement?
Thanks
|
|
|
MACROs
Jun 5, 2019 15:11:52 GMT -5
Post by George on Jun 5, 2019 15:11:52 GMT -5
Ren: OK, I can offer only limited help here, I've never called one module from another. dim tos, s, clp, cpc as number works just fine when I try it, so ?? The functions which end in a $ are functions that return strings. It's not mandatory, but has been a sort of convention in Basic for many years. Especially with Basic versions which don't force you to define all your variables, the trailing character was used to signify the data type, and $ meant string. No, there's no Del_Setvars or erase_setvars. If you're just using SET variables as sort of temporary storage, you should be using the Glbl variables instead I'd bet. If you're looking at external functions as a library type thing, and using it with SPFLite, my bet is it probably won't work. I don't know thinBasic internals, but if it chains to another module, I'm not sure it would execute the new module with the same environment as it's running itself. Remember, the SPFLite interface to thinBasic embeds all the SPFLite functions into the data space before passing in the actual macro to be executed. Whether that all gets passed to a called external module is a great unknown. George [Update] Robert got there first, I got interrupted while answering you. G.
|
|
Ren
Sophomore Member
Retired Mainframer
Posts: 82
|
MACROs
Jun 5, 2019 18:59:16 GMT -5
Post by Ren on Jun 5, 2019 18:59:16 GMT -5
OK I can work with #INCLUDE (It just goes against my grain as a programmer, because it is simply copying (and replicating) existing code). "No, there's no Del_Setvars or erase_setvars. If you're just using SET variables as sort of temporary storage, you should be using the Glbl variables instead I'd bet." - I;m using SETVAR as an entry in the (ISPF) PROFILE POOL. Attached is my FN MACRO. The DIM for tos is still commented out. But the MACRO works (kind of). Since there apparently no way tp get rid of a SETVAR variable, I have also included a MACRO, TRYME, that sets the variable (FINDBACK) to zero, and the code in FN checks to see if "entries, (the first 2 bytes) are equal to "00". How does one Right justify numerics (see comments in MACRO that start with ERROR) to do it in REXX would be: entries = Right(entries,2,0) or clp = Right(clp,6,0) Also: How do you continue a too long line command to a second line? (In REXX you just use a comma) Thanks Attachments:tryme.macro (678 B)
fn.macro (3.1 KB)
|
|
Ren
Sophomore Member
Retired Mainframer
Posts: 82
|
MACROs
Jun 6, 2019 8:02:12 GMT -5
Post by Ren on Jun 6, 2019 8:02:12 GMT -5
So the comma is not really a problem, it works fine without a DIM statement and with the comma. or without the comma, it must have a DIM statement. Sounds like an undocumented feature. LOL.
Back to RSET$. After a lot of experimentation, I got RSET$ to work. The ThinBasic manual offers for an example:
MyRSETString = RSET$(MyOLDString, Length+10 USING "*")
Which DOES NOT WORK, however removing the Length+ does work
MyRSETString = RSET$(MyOLDString, 10 USING "*")
Perhaps the ThinBasic people should be notified.
Thanks for the pointer. Ren
|
|
|
MACROs
Jun 6, 2019 13:19:34 GMT -5
Post by George on Jun 6, 2019 13:19:34 GMT -5
Ren: Robert: Also, reporting Doc errors in thinBasic isn't really much use when the supplied SPFLite version is quite old. We're on 1.9.16 and the current thinBasic is at 1.10.7, so who knows what the current doc says.
As to upgrading our version, well, it may slip in quite smoothly, or it might require some accompanying changes if any interfaces have been altered. What we have works pretty well, and until I hear of something significant in a new thinBasic release, my inclination is to leave things alone.
George
|
|