EXIT in FOR Loop

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

lagraf
Posts: 450
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Re: EXIT in FOR Loop

Post by lagraf »

Ok, thank you Chris,
pls keep me informed if the #pragma works.

Is there another way to compile user defined formulas?

Franz
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: EXIT in FOR Loop

Post by robert »

Guys,

I think the pragma should be

Code: Select all

#pragma options ("memvars", on)
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
lagraf
Posts: 450
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Re: EXIT in FOR Loop

Post by lagraf »

Hi Robert,
I did the #pragma options ("memvars", on) at the beginning and the #pragma options ("memvars", default) at the end of the method. Compiling shows same errors as without #pragma!

Compiler switch at Properties, Compiler, /memvar works but I get other errors at MCompile / MExec in these methods:

Code: Select all

cVal := MCompile(_aVor[nPos,4])	// => error XS0029: Cannot implicitly convert type 'XSharp._Codeblock' to 'string'
cReturn := AsString(MExec(cVal))	// => error XS1503: Argument 1: cannot convert from 'string' to 'codeblock'
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: EXIT in FOR Loop

Post by Chris »

Robert,

Actually both "memvar" and "memvars" are accepted as an option in the pragma! Looks like a bug, isn't it. But both still result to a parser error on the MEMVAR. Will open a detailed ticket.

Franz, this is a difference between X# and VO, it would not be possible in .Net to return the result of MCompile() in a string, instead it is returned as a codeblock. Also for the same reason MExec() needs a codeblock argument. So please change you var declaration to CODEBLOCK and it will work:

LOCAL cVal AS CODEBLOCK
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: EXIT in FOR Loop

Post by robert »

Chris,

I see what is happening.
The compiler option /memvar (/memvars is also supported) enables a part of the parser that recognizes the PRIVATE keyword.
At this moment, you MUST set the compiler option globally (as command line argument).
The /memvar compiler option also controls if the compiler produces special code to keep track of the lifetime of private and public variables.
That can be enabled / disabled with a pragma.
I will see if I can make the detection of the PRIVATE and PUBLIC statements also dependent of the pragma

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
lagraf
Posts: 450
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Re: EXIT in FOR Loop

Post by lagraf »

Hi Chris,
I edited it to Codeblock and now it compiles.
Franz
Post Reply