APL+Win v16 CSE - Value Substitution ExecStmt GetValue

General discussions related to using the C# Script Engine in APL+Win.

Moderators: Tech Support, phpbb_admin

APL+Win v16 CSE - Value Substitution ExecStmt GetValue

Postby joe_blaze » April 27th, 2016, 3:03 am

In APL+Win v16 the value substitution feature applicable to the CSE ExecStmt and GetValue methods has been enhanced.
The prior version of the CSE assumed that when an APL+Win text vector value was to be substituted into a C# executable expression, that value was to be considered a C# string.
In the APL+Win v16 the CSE does not make that assumption, so that it is now possible to substitute either a string or the name of a previously-defined C# variable into a C# executable expression.
The APL+Win programmer must now indicate which of these options applies.
Explicit quotation marks in either the C# executable expression or in the APL+Win text vector indicate that the substituted value from APL+Win should be considered a C# string.
This is documented in the CSE manual, but here are some examples illustrating these options:

⎕cself←'cse'⎕cse 'Init' 'System'
⎕cse 'ExecStmt' 'using System; Int32 I = 1234;' ⍝ Define a C# variable called I
0
⎕cse 'ExecStmt' 'Int32 Add10(Int32 I){return I+10;}' ⍝ Define a C# method called Add10
0
⎕cse 'GetValue' 'Add10({0})' 'I' ⍝Pass a variable name, I, to the C# Add10 method from APL+Win using value substitution
1244
⎕cse 'ExecStmt' 'string AddABC(string s){return s+"ABC";}' ⍝ Define another C# method called AddABC
0
⎕cse 'ExecStmt' 'string s = "PQR";' ⍝ Define another C# variable called s
0
⎕cse 'GetValue' 'AddABC("{0}")' 'RST' ⍝Pass an APL+Win text vector as a C# string into the C# AddABC method using value substitution with quotation marks in the C# executable expression
RSTABC
⎕cse 'GetValue' 'AddABC({0})' '"RST"' ⍝Pass an APL+Win text vector as a C# string into the C# AddABC method using value substitution with quotation marks in the APL+Win text vector
RSTABC
⎕cse 'GetValue' 'AddABC({0})' 's' ⍝Pass a C# variable name, s, into the C# AddABC method from APL+Win using value substitution
PQRABC
joe_blaze
 
Posts: 385
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Return to APL+Win & The C# Script Engine

Who is online

Users browsing this forum: No registered users and 1 guest

cron