Following on from Frank Clarke's presentation to the 2013 Symposium, I wonder if users would benefit from an ::Asset directive. It would function much as the ::Constant directive, but the value would be whatever was on the subsequent source lines up to the next directive or end of file. The parser would treat these lines as comment.
This could be used for panel data as per Frank's presentation, or sql queries or user instructions or a host of other things
made up example
::class queries
::Asset Margin
Select profit - costs as margin
from balancesheet
::Asset liability
select cost
from balancesheet
where profit > 0
The string value of the asset could be retrieved by .class~AssetName ie .queries~Margin
An added bonus would be the ability to substitute values on retrieval, but perhaps that would over-complicate matters.
::class queries2
::asset sales %startdate %enddate
select sum(amount)
from sales
where invoicedate >= '%startdate'
and invoicedate <= '%enddate'
the substitution argument(s) can be any string and the passed parameters are substituted for it wherever it appears in the asset at retrieval time
qry = .queries2~sales('2012-01-01','2012-03-31')
would return the string
select sum(amount)
from sales
where invoicedate >= '2012-01-01'
and invoicedate <= '2012-03-31'
What do you think?
thanks Jon
Anonymous
My preferences: 1)standalone, not class specific, 2)subkeywords rather than %var_name, and 3)space delimited vs. comma delimited.
Questions re. implementation: does the data that follows the directive include the NL characters or is it a single blank-delimited string of words? How would the proposed 'binary' data be included?
Hi Gil,
I believe if it was implemented like ::constant then the user could decide whether it was class specific or floating
I'm not sure how subkeywords would work. Can you give an example?
Would it be
I never intended the % to be taken literaly. Any text that you wanted as a target for substitution could be there, for instance
could be retrieved by ?~sentence('jump','brown','fox','dog','lazy')
I would say that the data that follows includes the NL characters except the last one. Alternatively the results could be returned as an array, like with the method method.
All the applications I can think of would want the NLs respected, but maybe that is just my limited imagination?
Binary data - good question. Two suggestions
1) only allow Ascii (or whatever the sourcefile is encoded in) - the user can then convert using X2C
2) just store whatever is there up to the end of file or next directive. The user has to use their ingenuity to get the data into the sourcefile.
Jon
From the Ref: "The ::CONSTANT directive creates methods that return constant values for a class and its instances." So making ::ASSET "floating" would require something more like floating methods, accessed via .METHODS[name]. That seems to be OK to me as I see an asset sort of like an attribute with only a GET method.
I was following up on Rony's comment about subkeywords so it seems that your PARMS example would work plus it would allow other subkeywords like: NONL (would take each line in the body and abut them to form a single string) and BASE64 (implies NONL but also specifies that the string is encoded).
I still have some reservations about substitution of parms in the body as it seems there could be some ambiguous cases.
Hi Rick,
thanks for taking this on. I'm sure it will be an 'asset' to the language
:->
Jon
On 29 June 2014 20:35, Rick McGuire bigrixx@users.sf.net wrote:
Related
Feature Requests:
#545::RESOURCE documented in revision [r10915].
Related
Commit: [r10915]
How would a Classic Rexx programmer like myself use this to, for instance,
retrieve 'boilerplate' code to insert into a new .rex file from THE?
Or, as another example, retrieve lines of HELP text, substitute variables and then be able to display the lines (somehow).
I currently do both of these using comment markers and sourceline(), but this idea might make it simpler!
parse arg arguments
if arguments = "" | arguments~strip~caselessEquals("--help") then
say .resources["USAGE"]~makeString
::resource usage
Usage:
commmand [options] file
::END
On Sat, Jun 13, 2015 at 11:18 PM, LesK vmrexx@users.sf.net wrote:
Related
Feature Requests:
#545Committed tests with revision [r11026]
Related
Commit: [r11026]