fbpx
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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • 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's Avatar

  • robert


  • Posts: 1846
  • 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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • 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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • 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's Avatar

  • lumberjack


  • Posts: 693
  • 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
    George, 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's Avatar

  • lumberjack


  • Posts: 693
  • 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
    George, 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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • 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's Avatar

  • FoxProMatt


  • Posts: 409
  • 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's Avatar

  • FoxProMatt


  • Posts: 409
  • 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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • 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's Avatar

  • Chris


  • Posts: 2110
  • 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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • 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's Avatar

  • Chris


  • Posts: 2110
  • 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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • Can do

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

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

  • Karl-Heinz's Avatar

  • Karl-Heinz


  • Posts: 585
  • 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's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • "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's Avatar

  • FFF


  • Posts: 995
  • 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.5b; Xide 1.25; 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's Avatar

  • lumberjack


  • Posts: 693
  • 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
    George, South Africa

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

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

  • alanbourke's Avatar

  • alanbourke

  • Topic Author


  • Posts: 20
  • 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's Avatar

  • robert


  • Posts: 1846
  • 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