Page 1 of 1

Regarding using

PostPosted: May 30th, 2015, 11:07 am
by Ajay Askoolum
If I start with:
Code: Select all
⎕cself←'cs' ⎕cse 'Init' 'System'
and then load an assembly
Code: Select all
⎕cse 'LoadAssembly' 'C:\oraclexe\app\oracle\product\10.2.0\server\BIN\Oracle.DataAccess.dll'
and then execute
Code: Select all
⎕cse 'ExecStmt' 'using  Oracle.DataAccess.Client;'
Am I still
Code: Select all
using System;
I'd appreciate a quick response, please.

Re: Regarding using

PostPosted: June 3rd, 2015, 1:43 pm
by Tech Support
No. This is corroborated by the following passage appearing on page 172 in the current APL+Win C# Script Engine Manual:

"Just as with the CSE ‘Init’ method, the ‘LoadAssembly’ method does not add a ‘using’ statement for a namespace associated with the loaded assembly."

The 'using System;' namespace must be added with an Exec or ExecStmt method.

Re: Regarding using

PostPosted: June 3rd, 2015, 2:26 pm
by Ajay Askoolum
I think you miss my point.

On the very first line of code, the 'Init' line has 'System': I presume that this is implicitly adding 'using System'.

On the second line of code, I am loading the assembly.

On the third line of code, as it states in the manual, I am adding the 'using' {namespace} (But, I am not repeating 'using System').

My question was: do I need to add 'using System' again or does the implicit usage on the very first line persist i.e. survive?

My experience suggests that it does not persist but I am not sure: hence the question.

Re: Regarding using

PostPosted: June 3rd, 2015, 2:41 pm
by Davin Church
I'm certainly no expert on the subject, but from their response above I think that you were perhaps making an incorrect initial assumption. If I may shorten their quote from the manual:
...the CSE ‘Init’ method does not add a ‘using’ statement...

which sounds to me like you never had a Using System in the first place, does it not?

Re: Regarding using

PostPosted: June 3rd, 2015, 2:50 pm
by Tech Support
Davin is correct. The 'using System' statement must be explicitly executed, which was not previously done in your earlier example. If you were under the impression that this was performed implicitly in the execution of the Init method, then that was incorrect.