|
Post by Robert on Nov 24, 2023 13:17:13 GMT -5
George,
Currently, the macro function Get_Arg_KW("keyword") returns True or False, depending on whether the keyword was used and was parsed by SPF_Parse.
However, if a macro keyword is being passed to some primary command via SPF_CMD, it is likely that the keyword string-value itself is needed, not a boolean flag that indicates its presence or absence.
The suggestion is to support this usage.
Get_Arg_KW$("keyword") would return the string "keyword" in upper-case if "keyword" is used on the macro primary command line, otherwise it would return a "" null string. (All keywords are case insensitive)
Example:
Get_Arg_KW$("ALL") returns "ALL" if ALL was used, else it returns ""
R
|
|
|
Post by Stefan on Nov 25, 2023 10:30:33 GMT -5
Hmm... this amendment will potentially require changes to existing macros that use Get_Arg_KW("...") already and expect a boolean value in return.
Most of the time, the logic only needs to know if a specific keyword is present and a boolean true/false is perfectly adequate.
If the actual keyword text needs to be passed to another function (e.g. SPF_CMD), this relatively easy as the coder already knows what the keyword string is.
e.g.:
SPF_CMD("FIND <whatever> "+IIF$(Get_ARG_KW("ALL"),"ALL",""))
I'm not keen on this suggestion which only saves a few keystrokes of code.
|
|
|
Post by Robert on Nov 25, 2023 12:28:37 GMT -5
No, it wouldn't require changes, because it's a different name. With an ending $ and without it makes two different names, despite their similarity.
In any case, it's possible to write a string function to simulate what the suggested function does, which I assume I'll be doing if George doesn't like the idea.
|
|
|
Post by George on Nov 25, 2023 12:46:13 GMT -5
Don't need a change here, use what's available.
If you want ALL or a null, then define the KW as a single item Group: "KWDALL:ALL" instead of just "ALL" then retrieve it with str = Get_Arg_KWGroup$("KWDALL")
George
|
|
|
Post by Robert on Nov 25, 2023 13:23:09 GMT -5
My solution is to us a plain "ALL" and then call this:
function Get_Arg_KW$(kw as string) as string IF Get_Arg_KW(ucase$(kw)) then function = ucase$(kw) else function = "" end if end function
|
|
|
Post by George on Nov 25, 2023 13:44:10 GMT -5
Whatever floats your boat.
|
|
|
Post by Stefan on Nov 27, 2023 4:48:00 GMT -5
No, it wouldn't require changes, because it's a different name. With an ending $ and without it makes two different names, despite their similarity. In any case, it's possible to write a string function to simulate what the suggested function does, which I assume I'll be doing if George doesn't like the idea.
Robert,
My bad!!! I didn't notice the '$' in your proposal. Sorry.
|
|