Skip to content
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_BEGIN-CHECKED.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<para styleclass="Heading1">Purpose</para>
<para styleclass="Body Text">The <text style="font-weight:bold;">BEGIN</text> (<text style="font-weight:bold;">UN</text>)<text style="font-weight:bold;">CHECKED</text> and <text style="font-weight:bold;">END</text> (<text style="font-weight:bold;">UN</text>)<text style="font-weight:bold;">CHECKED</text> keywords mark a block of statements that are compiled with overflow checking enabled or disabled.</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Code with box">BEGIN CHECKED<br/> &#160; statements<br/>END CHECKED<br/><br/>BEGIN UNCHECKED<br/> &#160; statements<br/>END CHECKED</para>
<para styleclass="Code with box">BEGIN CHECKED<br/> &#160; statements<br/>END CHECKED<br/><br/>BEGIN UNCHECKED<br/> &#160; statements<br/>END UNCHECKED</para>
<para styleclass="Heading1">Arguments</para>
<para styleclass="Body Text"></para>
<para styleclass="List"><text style="font-style:italic;">statements</text>&#32;<tab />One or more statements or expressions that are compiled with the specified overflow checking</para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_BEGIN-USING.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<para styleclass="Heading1"><text styleclass="Body Text">The </text><text styleclass="Body Text" style="font-weight:bold;">BEGIN USING</text><text styleclass="Body Text"> and </text><text styleclass="Body Text" style="font-weight:bold;">END USING</text><text styleclass="Body Text"> keyword declare a block of code that ensures the correct use of disposable objects.</text></para>
<para styleclass="Normal"></para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Code with box">BEGIN USING <text style="font-style:italic;">declaration</text><br/> &#160; <text style="font-style:italic;">statements</text><br/>END USING</para>
<para styleclass="Code with box">BEGIN USING [AWAIT] <text style="font-style:italic;">declaration</text><br/> &#160; <text style="font-style:italic;">statements</text><br/>END [USING]</para>
<para styleclass="Heading1">Arguments</para>
<para styleclass="List">declaration<tab />Declaration of a variable and assignment that is visible only inside the statement block between BEGIN and END</para>
<para styleclass="List"><text styleclass="" style="font-family:&apos;Times New Roman&apos;; font-size:12pt; font-style:italic; color:#000000;">statements</text><text styleclass="" style="font-family:&apos;Times New Roman&apos;; font-size:12pt; color:#000000;">&#32;</text><tab />Code including one or more statements that may contain unsafe code.</para>
Expand Down
1 change: 1 addition & 0 deletions docs/Help/Topics/command_DELEGATE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<para styleclass="Normal"><tab />[([&lt;<text styleclass="Italic">idParam</text>&gt; [AS | REF|OUT|IN &lt;<text styleclass="Italic">idType</text>&gt;] [, ...])] </para>
<para styleclass="Normal"><tab />[AS &lt;<text styleclass="Italic">idType</text>&gt;]</para>
<para styleclass="Normal"><tab />[TypeparameterConstraints]</para>
<para styleclass="Normal"><tab />[&lt;<text styleclass="Italic">idConvention</text>&gt;]</para>
<para styleclass="Heading1">Arguments</para>
<para styleclass="List"><snippet src="__IncludeMethodModifiers" inline="false"/></para>
<para styleclass="List">&lt;<text styleclass="Italic">idDelegate</text>&gt;<tab />A valid identifier name for the delegate. Delegate names must be unique within a namespace.</para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_DO_WHILE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<para styleclass="Normal"><tab />&lt;<text styleclass="Italic">Statements</text>&gt;...</para>
<para styleclass="Normal">[LOOP]</para>
<para styleclass="Normal"><tab />&lt;<text styleclass="Italic">Statements</text>&gt;...</para>
<para styleclass="Normal">END[DO]</para>
<para styleclass="Normal">END [DO | WHILE] | ENDDO</para>
<para styleclass="Heading1">Arguments</para>
<para styleclass="List">&lt;lCondition&gt;<tab />The logical control expression for the DO WHILE loop.</para>
<para styleclass="List"></para>
Expand Down
4 changes: 2 additions & 2 deletions docs/Help/Topics/command_ENUM.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<para styleclass="Normal">Declare an enumeration to the compiler.</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Normal"><tab />[attributes] [Modifiers] </para>
<para styleclass="Normal"><tab />ENUM &lt;idEnumName&gt; [AS type] &#160; </para>
<para styleclass="Normal"><tab /><tab />memberName [:= value]</para>
<para styleclass="Normal"><tab />ENUM &lt;idEnumName&gt; [AS | INHERIT type] &#160; </para>
<para styleclass="Normal"><tab /><tab />[Attributes] [MEMBER] memberName [:= value]</para>
<para styleclass="Normal"><tab /><tab /> &#160;[...]</para>
<para styleclass="Normal"><tab />END [ENUM]</para>
<para styleclass="Normal"></para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_FOR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<para styleclass="Heading1">Purpose</para>
<para styleclass="Normal">Executes a block of statements a specified number of times.</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Code with box">FOR [&lt;idCounter&gt; := &lt;nStart&gt; | VAR &lt;idCounter&gt; := &lt;nStart&gt; | LOCAL &lt;idCounter&gt; := &lt;nStart&gt; AS &lt;idType&gt; ] [TO | UPTO | DOWNTO] &lt;nEnd&gt; [STEP &lt;nDelta&gt;]<br/> &#160; &lt;Statements&gt;...<br/> &#160; [EXIT]<br/> &#160; &lt;Statements&gt;...<br/> &#160; [LOOP]<br/>NEXT</para>
<para styleclass="Code with box">FOR &lt;idCounter&gt; := &lt;nStart&gt; | [LOCAL] IMPLIED &lt;idCounter&gt; := &lt;nStart&gt; | VAR &lt;idCounter&gt; := &lt;nStart&gt; | LOCAL &lt;idCounter&gt; := &lt;nStart&gt; [AS &lt;idType&gt;] TO | UPTO | DOWNTO &lt;nEnd&gt; [STEP &lt;nDelta&gt;]<br/> &#160; &lt;Statements&gt;...<br/> &#160; [EXIT]<br/> &#160; &lt;Statements&gt;...<br/> &#160; [LOOP]<br/>NEXT | ENDFOR</para>
<para styleclass="Heading2"><text style="color:#0000ff;">Note</text></para>
<para styleclass="Normal">In the FoxPro and Xbase++ dialect, ENDFOR is allowed as alternative for NEXT</para>
<para styleclass="Heading1">Arguments</para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_FOREACH.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<para styleclass="Heading1">Purpose</para>
<para styleclass="Normal">Executes a block of statements for all elements in a collection.</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Code with box">FOREACH &#160;[IMPLIED &lt;idElement&gt; | VAR &lt;idElement&gt; | &lt;idElement&gt; AS &lt;idType&gt;] IN &lt;container&gt;<br/> &#160; &lt;Statements&gt;...<br/> &#160; [EXIT]<br/> &#160; &lt;Statements&gt;...<br/> &#160; [LOOP]<br/>NEXT</para>
<para styleclass="Code with box">FOREACH [AWAIT] IMPLIED &lt;idElement&gt; | VAR &lt;idElement&gt; | &lt;idElement&gt; [AS &lt;idType&gt;] IN &lt;container&gt;<br/> &#160; &lt;Statements&gt;...<br/> &#160; [EXIT]<br/> &#160; &lt;Statements&gt;...<br/> &#160; [LOOP]<br/>NEXT | ENDFOR</para>
<para styleclass="Heading2"><text style="color:#0000ff;">Note</text></para>
<para styleclass="Normal">In the FoxPro dialect, FOR EACH is also allowed as two separate words.</para>
<para styleclass="Normal">In the FoxPro and Xbase++ dialect, ENDFOR is allowed as an alternative for NEXT.</para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_IF.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<para styleclass="Heading1">Purpose</para>
<para styleclass="Normal">Conditionally executes a block of statements.</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Code with box">IF &lt;<text style="font-style:italic;">lCondition</text>&gt; [THEN]<br/><tab />&lt;<text style="font-style:italic;">Statements</text>&gt;...<br/>[ELSEIF &lt;<text style="font-style:italic;">lCondition</text>&gt;]<br/><tab />&lt;<text style="font-style:italic;">Statements</text>&gt;...<br/>[ELSE]<br/><tab />&lt;<text style="font-style:italic;">Statements</text>&gt;...<br/>END[IF]</para>
<para styleclass="Code with box">IF &lt;<text style="font-style:italic;">lCondition</text>&gt; [THEN]<br/><tab />&lt;<text style="font-style:italic;">Statements</text>&gt;...<br/>[ELSEIF &lt;<text style="font-style:italic;">lCondition</text>&gt;]<br/><tab />&lt;<text style="font-style:italic;">Statements</text>&gt;...<br/>[ELSE]<br/><tab />&lt;<text style="font-style:italic;">Statements</text>&gt;...<br/>END [IF] | ENDIF</para>
<para styleclass="Heading1">Arguments</para>
<para styleclass="List">[THEN]<tab />The THEN keyword is optional and has been added because Visual FoxPro allows this keyword.</para>
<para styleclass="List"></para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_NOP.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<para styleclass="Heading1"><text>Purpose</text></para>
<para styleclass="Body Text">The NOP statement inserts an empty statement in the code</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Code with box">NOP</para>
<para styleclass="Code with box">NOP [()]</para>
<para styleclass="Heading1">Remarks</para>
<para styleclass="Body Text">The NOP statement is an empty statement. It can be used to indicate that a certain code section is left intentionally empty</para>
<para styleclass="Heading1">Examples</para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_RETURN.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<para styleclass="Heading1">Purpose</para>
<para styleclass="Normal">Terminates a routine by returning control to the calling routine or operating system if executed from the Start() routine.</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Normal">RETURN [&lt;<text styleclass="Italic">uValue</text>&gt;]</para>
<para styleclass="Normal">RETURN [VOID | &lt;<text styleclass="Italic">uValue</text>&gt;]</para>
<para styleclass="Heading1">Arguments</para>
<para styleclass="List">&lt;uValue&gt;<tab />May be specified in a function or method definition to designate its return value. Procedure definitions do not allow &lt;uValue&gt; as part of the RETURN statement. See the FUNCTION and METHOD entries in this guide for information about default return values if &lt;uValue&gt; is not specified.</para>
<para styleclass="Heading1">Description</para>
Expand Down
2 changes: 1 addition & 1 deletion docs/Help/Topics/command_WITH.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<para styleclass="Heading1">Purpose</para>
<para styleclass="Normal">Specifies multiple properties for an object.</para>
<para styleclass="Heading1">Syntax</para>
<para styleclass="Code with box">WITH ObjectName<br/> &#160; [cStatements] or<br/><tab />[:Statements]<br/>END WITH</para>
<para styleclass="Code with box">WITH ObjectName [AS &lt;idType&gt;]<br/> &#160; [cStatements] or<br/><tab />[:Statements]<br/>END [WITH] | ENDWITH</para>
<para styleclass="Heading1">Arguments</para>
<para styleclass="List">ObjectName <tab />Specifies the name of the object. ObjectName can be the name of the object or a reference to the object.</para>
</body>
Expand Down
53 changes: 44 additions & 9 deletions src/Runtime/XSharp.RT/Functions/CompilerSupport.prg
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,33 @@ FUNCTION __FieldGetWa( area AS USUAL, fieldName AS STRING ) AS USUAL
/// <exclude />
[NeedsAccessToLocals(FALSE)];
FUNCTION __FieldGetWa2(wa AS STRING, fldName AS STRING, lAllowUndeclared AS LOGIC) AS USUAL
LOCAL nArea := VoDbGetSelect(wa) AS DWORD
LOCAL nArea := VoDbGetSelect(wa) AS DWORD
LOCAL err := NULL as Error
Comment on lines +118 to +119
IF nArea != 0
RETURN __FieldGetWa(wa, fldName)
ENDIF
IF XSharp.MemVar.LocalFind(wa, out var uLocal, out var _)
return IVarGet(uLocal, fldName)
ENDIF
local ok as LOGIC
local ex := NULL as Exception
IF XSharp.MemVar.LocalFind("SELF", out uLocal, out var _)
local oLocal := uLocal as object
try
var ivar := (OBJECT) IVarGet(oLocal, wa)
// we do not use IVarGet because we also want to support static fields and properties
var res := _GetValue(ivar:GetType(), ivar)
if ok
return res
endif
catch as Exception
nop
if ok
return res
endif
err := Error{EG_NOVAR, nameof(fldName), ErrString(EG_NOVAR) + ": " + fldName}
err:FuncSym := __function__
err:ArgNum := 2
err:Args := <OBJECT>{wa, fldName}
THROW err

catch e as Exception
ex := e
end try
ENDIF
if (lAllowUndeclared)
Expand All @@ -154,14 +162,26 @@ LOCAL nArea := VoDbGetSelect(wa) AS DWORD
IF Globals.Get(wa, OUT var uGlobal)
return IVarGet(uGlobal, fldName)
ENDIF
if ex != null
throw ex
endif

VAR err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa}
err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa}
err:FuncSym := __function__
err:ArgNum := 2
err:Args := <OBJECT>{wa, fldName}
THROW err
LOCAL FUNCTION _GetValue(oType as System.Type, oObject as object) as USUAL
ok := TRUE
if oObject is IDynamicProperties var oDynamic
try
return oDynamic:NoIvarGet(fldName)
CATCH as Exception
ok := FALSE
RETURN NIL
end try
endif

var mem := OOPHelpers.GetFieldOrProperty(oType, fldName)
if mem is FieldInfo var fld
if ! fld:IsPublic
Expand Down Expand Up @@ -215,6 +235,7 @@ FUNCTION __FieldSetWa( area AS USUAL, fieldName AS STRING, uValue AS USUAL ) AS
[NeedsAccessToLocals(FALSE)];
FUNCTION __FieldSetWa2(wa AS STRING, fldName AS STRING, uValue AS USUAL,lAllowUndeclared AS LOGIC) AS USUAL
LOCAL nArea := VoDbGetSelect(wa) AS DWORD
LOCAL err := NULL as Error
IF nArea != 0
LOCAL nOldArea := RuntimeState.CurrentWorkarea AS DWORD
TRY
Expand Down Expand Up @@ -252,6 +273,13 @@ FUNCTION __FieldSetWa2(wa AS STRING, fldName AS STRING, uValue AS USUAL,lAllowUn
catch as Exception
nop
end try
err := Error{EG_NOVAR, nameof(fldName), ErrString(EG_NOVAR) + ": " + fldName}
err:FuncSym := __function__
err:ArgNum := 2
err:Args := <OBJECT>{wa, fldName}
THROW err
Comment on lines +276 to +280



ENDIF
if (lAllowUndeclared)
Expand All @@ -271,13 +299,20 @@ FUNCTION __FieldSetWa2(wa AS STRING, fldName AS STRING, uValue AS USUAL,lAllowUn
IF Globals.Get(wa, OUT var uGlobal)
return IVarPut(uGlobal, fldName, uValue)
ENDIF

VAR err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa}
err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa}
err:FuncSym := __function__
err:ArgNum := 2
err:Args := <OBJECT>{wa, fldName}
THROW err
LOCAL FUNCTION _SetValue(oType as System.Type, oObject as object, uValue as USUAL) as LOGIC
if oObject is IDynamicProperties var oDynamic
TRY
oDynamic:NoIvarPut(fldName, uValue)
return true
CATCH as Exception
return false
END TRY
endif
var mem := OOPHelpers.GetFieldOrProperty(oType, fldName)
if mem is FieldInfo var fld
var oValue := OOPHelpers.ValueConvert(uValue, fld:FieldType)
Expand Down
Loading