xsharp.eu • For loop syntax.
Page 1 of 3

For loop syntax.

Posted: Fri Sep 27, 2019 11:42 am
by Anonymous
Just having a quick initial look at the 2.07 public release and VFP syntax therein.

It seems to not like forendfor, which is legal VFP, and insists on fornext. Is that by design ?

For loop syntax.

Posted: Fri Sep 27, 2019 11:44 am
by robert
Alan,

Did you set the dialect to FoxPro ?
If you did then it should automatically include the file "FoxProCmd.xh" which translates ENDFOR to NEXT

Robert

For loop syntax.

Posted: Fri Sep 27, 2019 11:49 am
by alanbourke
Robert

I chose 'FoxPro Console Application' when creating the project.

For loop syntax.

Posted: Fri Sep 27, 2019 12:00 pm
by alanbourke
I've added the .xh file in manually, verified that the dialect 's 'FoxPro', still doesn't like it.
Also set the dialect to Core, rebuilt, then back to FoxPro to see if something would kick in, but no.

For loop syntax.

Posted: Fri Sep 27, 2019 12:41 pm
by lumberjack
Hi Alan,
alanbourke wrote:I've added the .xh file in manually, verified that the dialect 's 'FoxPro', still doesn't like it. Also set the dialect to Core, rebuilt, then back to FoxPro to see if something would kick in, but no.
Added manually, do you mean you added at the top of your start.prg file?

Code: Select all

#include "c:Program Files (x86)xsharpincludeFoxProCmd.xh"

For loop syntax.

Posted: Fri Sep 27, 2019 12:56 pm
by lumberjack
Hi Alan,
alanbourke wrote: I chose 'FoxPro Console Application' when creating the project.
Using VS 2017 Community I did and modified as follows:

Code: Select all

Using System
Using System.Collections.Generic
Using System.Linq
Using System.Text

Function Start() As Void Strict
	Local i
	For i = 1 To 10
		? "Hello World! Today is ",ToDay()
		WAIT
	endfor
Return	
Ran fine this side first time.
Also tested with VS 2019 Community and ran fine first time.

For loop syntax.

Posted: Fri Sep 27, 2019 1:22 pm
by alanbourke
OK here's what I have, VS 2019 Community:

Code: Select all

#include "c:program files (x86)xsharpincludefoxprocmd.xh"
using system
using system.collections.generic
using system.linq
using system.text


function start() as void strict
    
    ? "hello world! today is ",today()
	
    local x as int
	
    for x = 1 to 100
		    ? x
    next
    
    wait

return	

If I replace 'next' with 'endfor' it's a problem.

For loop syntax.

Posted: Fri Sep 27, 2019 2:37 pm
by FoxProMatt
I started a new "FoxPro Console Application" from X# templates in VS2019, and EndFor is working fine for me. Compiles and runs no problem.

VS 2019 Ver 16.3.1, /Net Framework 4.7.2, X# 2.07

Code: Select all

Using System
Using System.Collections.Generic
Using System.Linq
Using System.Text

Function Start() As Void Strict
    
    ? "hello world! today is ",today()
	
    Local x As Int
	
    For x = 1 To 100
	? x
    EndFor
    
    Wait

Return	

For loop syntax.

Posted: Fri Sep 27, 2019 3:14 pm
by FoxProMatt
BTW, in X# you can use either:

Code: Select all

EndFor
or

Code: Select all

End For
(notice space between the words.

For loop syntax.

Posted: Mon Sep 30, 2019 1:28 pm
by alanbourke
I created a new FoxPro console application and pasted Matt's code in, still doesn't like 'endfor'.

Seems happy with 'end for' though, but that's not valid VFP syntax