This proved to be too much of a hassle.
I am returning the value as a hex string (one C# expression) and a subroutine in C# to reverse the process when I send it back via CSE.
This gives me added benefits: with a slight modification (simply add the prefix 0x to the return string from two pathways), the values I am returning fit Microsoft SQL Server VARBINARY and GEOGRAPHY data types.
I am turning the return string "\u0001\u0001\0\0\0\u001a???\a[??\0??\u007f??I@" to either 0x0101000000716048C8E88452C04EB35460CC0D4440 (VARBINARY) or 0xE6100000010C4EB35460CC0D4440716048C8E88452C0 (GEOGRAPHY) (or both).
The hex representation of the string is 0101000000716048C8E88452C04EB35460CC0D4440 (no 0x prefix) and that needs to be re-converted when used as an argument from APL+Win.
Strings like 0x0101000000716048C8E88452C04EB35460CC0D4440 can be stored in native files, or APL arrays, or component files (with or without the prefix). (or in SQL Server when the prefix is present).
By way of an explanation of my present objective, I am exploring spatial calculations from APL+Win using https://www.nuget.org/packages/Microsof ... ver.Types/ As this is a .NET assembly (no Interop), I need to use the C# Script Engine.
The complication of nightmare proportions is that APL+Win has its own data types, the NET assembly has its own data types, and C# has its own data types. From APL+Win the round trip of APL+Win to C# via []CSE to the .NET assembly requires very careful and intricate management (they do NOT coerce using explicit casting/conversion) Hence the threads in the forum - with the expectation that someone might have solved the issues already.This is a session (it might provide more clarification)
- Code: Select all
∇ APL2000
[1] ⍝ @ Ajay Askoolum
[2] CreatePoint ¯74.07670790737194 40.10779956947104 ⍝ This is APL2000's location
[3] ⎕cse 'ExecStmt' 'var binary = APL2000.Serialize().Value;'
[4] ⎕cse 'ExecStmt' 'string hexString = "0x" + BitConverter.ToString(binary).Replace("-", "");'
[5] ⍝ ⎕cse 'ExecStmt' 'SqlGeography ajay = (SqlGeography) hexString;'
[6] ⍝ GEOGRAPHY
[7] ⎕cse 'GetValue' 'hexString' ⍝ Direct assignment in SSMS & can write it to SQL Server Column Type geography;
[8] ⎕cse 'ExecStmt' 'var binary2 = (byte[])APL2000.STAsBinary().Value;'
[9] ⍝ WKB or VARBINARY
[10] ⎕cse 'ExecStmt' 'string hexString = "0x" + BitConverter.ToString(binary2).Replace("-", "");'
[11] ⎕cse 'GetValue' 'hexString' ⍝ Write to SQL Server column type VARBINARY(MAX)
[12]
[13] ⍝ See ToSQLSServer for more detailed notes
∇
APL2000
0
0
0
0xE6100000010C4EB35460CC0D4440716048C8E88452C0
0
0
0x0101000000716048C8E88452C04EB35460CC0D4440
⍝ The 0's are ⎕cse return codes - need to sink them.
Just to complete the picture, compare the results with those in the attached screenshot of a SQL Server session.