fbpx

Help with converting StrEvaluate to X#

More
1 year 3 months ago #1 by Boonnam S
Help with converting StrEvaluate to X# was created by Boonnam S
This is our VO code:
SELF:oNetClnt:SetFilter( StrEvaluate('MTYPE=="&cType"') )

This line wouldn't compile under X# with VO dialect, but this line does comppile:
SELF:oNetClnt:SetFilter( &('MTYPE=="&cType_OpenServers"') )

It took runtime error. I know I can fix it by changing to:
SELF:oNetClnt:SetFilter('MTYPE=="' + cType + '"')

We have several other lines that are more complicated. Is there a better way fix this in X#?

Thanks,

Boonnam

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #2 by Robert van der Hulst
Replied by Robert van der Hulst on topic Help with converting StrEvaluate to X#
Boonnam,
What is cType here?
- a Local
- a MemVar/Private/Public
- a Database field ?

Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #3 by Boonnam S
Replied by Boonnam S on topic Help with converting StrEvaluate to X#
In VO, cType is MEMVAR, but since MEMVAR isn't supported under X#, I changed it to global. I know that this code, "SELF:oNetClnt:SetFilter('MTYPE=="' + cType + '"')" works, but we need to get this to work with scripting.

Thanks

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #4 by Robert van der Hulst
Replied by Robert van der Hulst on topic Help with converting StrEvaluate to X#
Boonnam,

Automatic expansion of memvars inside strings with StrEvaluate is not supported by the Vulcan Runtime because Vulcan does not know memvars.
And it does not support this for globals as well, as far as I know.
If you open the Vulcan runtime with reflector you will see that the contents of the StrEvaluate function is empty. It returns the original string.
Most likely you have seen a warning for the Obsolete function (or did you disable these warnings?)

// VulcanRTFuncs.Functions
[Obsolete("'StrEvaluate()' is not supported", true)]
public static string StrEvaluate(string s)
{
return s;
}

We have planned to add support for StrEvaluate to our runtime.
For now the syntax you suggest is the only thing that works.

Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #5 by Boonnam S
Replied by Boonnam S on topic Help with converting StrEvaluate to X#
Yes I saw the warnings about MEMVAR. That's why I changed them to GLOBAL. Any idea when new runtime will be released? Thanks.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #6 by Robert van der Hulst
Replied by Robert van der Hulst on topic Help with converting StrEvaluate to X#
Boonnam,

The runtime is planned before christmas. At least the Vulcan compatible part.
I am not sure if we will succeed to also add Memvar support at the same time.
Memvar support also requires a change in the compiler: functions/methods that use memvars will get a special prologue and epilogue code to declare the memvars in the symbol table and to release them from the symbol table when the function/method is finished.

Using memvars will therefore have a little overhead. Also because they are always of the type USUAL.

We cannot declare them as normal locals, since the visibility rules for memvars make them also visible from within code that is called by the code that declared the memvar.
And (of course) memvars will be of type USUAL just like in VO.

Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #7 by Otto Christiaanse
Replied by Otto Christiaanse on topic Help with converting StrEvaluate to X#
Sounds like memvars will make an app a lot slower than in VO.
I guess it is needed for a smooth transition from VO to .NET, but not very helpful further.

What I read in the help and Programmers Guide about memvars I don't see why I would want it in my programs in VO, and now especially not anymore in .NET.

Isn't it possible to device a tool to 'convert' the memvar 'automatically' to another concept?

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #8 by Robert van der Hulst
Replied by Robert van der Hulst on topic Help with converting StrEvaluate to X#
Otto,

I do not think it will make apps a lot slower. Maybe somewhat slower but not a lot.
The compiler can detect if a method/function uses memvars
When it does it will introduce a (compiler generated) local that remembers the top of the memvar stack at the start of the function/method
And at the end of the function it will clear all memvars that have been added based on the value of this local.
The memvar itself is simply a symbol/usual pair.


Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #9 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Help with converting StrEvaluate to X#
Hi Otto,

in some macro evaluation engines memvars are very helpful - I'm using them in my report engine. And this was the main cause why I have not ported that one to Vulcan or X#.

Wolfgang

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #10 by Chris Pyrgas
Replied by Chris Pyrgas on topic Help with converting StrEvaluate to X#
Not to mention that maybe it's a good idea to introduce a compiler option to allow MEMVARs or not, like there's an option for allowing late bound calls etc. So when that option is off, there should be zero performance decrease.

Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #11 by Robert van der Hulst
Replied by Robert van der Hulst on topic Help with converting StrEvaluate to X#
Chris,
My current thinking is to only allow it in dialects where it is expect, in other words not in Vulcan and not in Core.

Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #12 by Chris Pyrgas
Replied by Chris Pyrgas on topic Help with converting StrEvaluate to X#

Robert van der Hulst wrote: Chris,
My current thinking is to only allow it in dialects where it is expect, in other words not in Vulcan and not in Core.


Yeap, absolutely agreed!

Chris

ps. that's my first attempt to properly quote someone in the forums world, let's see if I did that properly :)

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #13 by Otto Christiaanse
Replied by Otto Christiaanse on topic Help with converting StrEvaluate to X#
agreed, seems best solution.

Please Log in or Create an account to join the conversation.