Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1
  • 2

TOPIC:

For loop syntax. 27 Sep 2019 13:42 #10888

  • alanbourke
  • alanbourke's Avatar
  • Topic Author



Just having a quick initial look at the 2.07 public release and VFP syntax therein.

It seems to not like for\endfor, which is legal VFP, and insists on for\next. Is that by design ?

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

For loop syntax. 27 Sep 2019 13:44 #10889

  • robert
  • robert's Avatar


  • Posts: 3585
  • 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
    XSharp Development Team
    The Netherlands

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

    For loop syntax. 27 Sep 2019 13:49 #10891

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    Robert

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

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

    For loop syntax. 27 Sep 2019 14:00 #10892

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    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.

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

    For loop syntax. 27 Sep 2019 14:41 #10893

    • lumberjack
    • lumberjack's Avatar


  • Posts: 721
  • 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?
    #include "c:\Program Files (x86)\xsharp\include\FoxProCmd.xh"
    ______________________
    Johan Nel
    Boshof, South Africa

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

    Last edit: by lumberjack.

    For loop syntax. 27 Sep 2019 14:56 #10894

    • lumberjack
    • lumberjack's Avatar


  • Posts: 721
  • Hi Alan,

    alanbourke wrote: I chose 'FoxPro Console Application' when creating the project.

    Using VS 2017 Community I did and modified as follows:
    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.
    ______________________
    Johan Nel
    Boshof, South Africa

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

    Last edit: by lumberjack.

    For loop syntax. 27 Sep 2019 15:22 #10897

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    OK here's what I have, VS 2019 Community:
    #include "c:\program files (x86)\xsharp\include\foxprocmd.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.

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

    Last edit: by alanbourke.

    For loop syntax. 27 Sep 2019 16:37 #10898

    • FoxProMatt
    • FoxProMatt's Avatar



    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
    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	

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

    Last edit: by FoxProMatt.

    For loop syntax. 27 Sep 2019 17:14 #10902

    • FoxProMatt
    • FoxProMatt's Avatar



    BTW, in X# you can use either:
    EndFor

    or
    End For

    (notice space between the words.

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

    For loop syntax. 30 Sep 2019 15:28 #10971

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    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

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

    For loop syntax. 30 Sep 2019 16:21 #10973

    • Chris
    • Chris's Avatar


  • Posts: 3973
  • alanbourke wrote: 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


    Do you mean that the editor does not highlite it (which is indeed a known problem), or does the compiler not accept it either when building? Tested it here and seems to work ok.
    XSharp Development Team
    chris(at)xsharp.eu

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

    For loop syntax. 30 Sep 2019 16:23 #10974

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    It doesn't highlight it, and it throws a compiler error XS1003, Syntax Error, 'NEXT' expected.

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

    For loop syntax. 30 Sep 2019 16:29 #10976

    • Chris
    • Chris's Avatar


  • Posts: 3973
  • Could you please zip the solution folder and send it so we can have a look?
    XSharp Development Team
    chris(at)xsharp.eu

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

    For loop syntax. 30 Sep 2019 16:30 #10977

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    Can do

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

    For loop syntax. 30 Sep 2019 19:07 #10989

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • Guys,

    Didn´t notice it before, but this code - with the dialect setting <VO> or <Foxpro> - compiles and runs. To see what´s going on i compiled the source with the -ppo+ -showincludes+ -nostddefs+ settings - and the ppo file content still shows "END FOR". I´ve looked at the X# Help but i didn´t find any hint that "END FOR" is a legal statement - but it is :-)

    BTW. I´m pretty sure that Alan didn´t select in VS the <Foxpro> dialect, so a not preproccessed "ENDFOR" throws the XS1003, Syntax Error, 'NEXT'
    FUNCTION Start( ) AS VOID
    LOCAL i  AS INT 
    
    
    	FOR i := 1 TO 3 
    		
    		? i 
    		
    	END FOR  // <----
    
    	
    	
    	FOREACH VAR c IN  { "one" , "two" , "three" }
    		
    		? c 
    		
    	END FOR  // <---
    			
    	
    RETURN
    

    regards
    Karl-Heinz

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

    For loop syntax. 01 Oct 2019 10:19 #10994

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    "BTW. I´m pretty sure that Alan didn´t select in VS the <Foxpro> dialect,"

    I ran the Visual Studio wizard to create a Foxpro Console Application, which sets the dialect automatically.

    'End For' might be valid in other dialects, but it's not valid Visual Foxpro.

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

    For loop syntax. 01 Oct 2019 10:32 #10995

    • FFF
    • FFF's Avatar


  • Posts: 1419
  • Alan,
    VS17 community on W8.1/64 German, 2.07 FoxVersion.
    New project / FoxPro Console app
    modified to
    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
    // endfor
    END FOR
    WAIT
    RETURN

    CTRL-F5 compiles and runs in all three "closing" versions.
    Regards
    Karl (X# 2.15.0.3; Xide 2.15; W8.1/64 German)

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

    For loop syntax. 01 Oct 2019 10:48 #10996

    • lumberjack
    • lumberjack's Avatar


  • Posts: 721
  • Hi Alan,

    alanbourke wrote: "BTW. I´m pretty sure that Alan didn´t select in VS the <Foxpro> dialect,"
    I ran the Visual Studio wizard to create a Foxpro Console Application, which sets the dialect automatically.
    'End For' might be valid in other dialects, but it's not valid Visual Foxpro.

    Run the Wizard? I assume you mean File/New/Project, Select Foxpro Console Application and Next button to create?
    ______________________
    Johan Nel
    Boshof, South Africa

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

    For loop syntax. 01 Oct 2019 11:10 #10997

    • alanbourke
    • alanbourke's Avatar
    • Topic Author



    Right, at the link below is a 5MB MP4 screen recording showing installation of XSharp and then what I'm doing in Visual Studio.

    Demo

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

    For loop syntax. 01 Oct 2019 11:14 #10998

    • robert
    • robert's Avatar


  • Posts: 3585
  • Alan,
    Thanks for the video. I am looking into this

    Robert
    XSharp Development Team
    The Netherlands

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

    • Page:
    • 1
    • 2