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

TOPIC:

using parentheses to access array elements 22 Oct 2021 21:23 #20089

  • kevclark64
  • kevclark64's Avatar
  • Topic Author


  • Posts: 123
  • The release notes for the version 2.9 include that you added the ability to use parentheses to access array elements, which is great. However, it looks like parentheses can currently only be used on the right side of an equation.
    arrayhold(1)=ofstr  //this generate an error: The left-hand side of an assignment must be a variable, property or indexer
    ofstr=arrayhold(1)  //this works

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

    using parentheses to access array elements 23 Oct 2021 09:24 #20090

    • Chris
    • Chris's Avatar


  • Posts: 3856
  • Kevin, how have you declared arrayhold in this case?
    XSharp Development Team
    chris(at)xsharp.eu

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

    using parentheses to access array elements 23 Oct 2021 15:06 #20091

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • Hi Chris,

    it seems there´s also a function named arrayHold() involved. When i add such a function i see the "left-hand" compiler error. Try this with /FOX2 enabled / disabled

    FUNCTION Start() AS VOID
    dimension arrayHold(3)
    
    	arrayhold(1) = 12 
    
    	RETURN
    
    FUNCTION arrayHold(n)
    	
    	RETURN 1 

    regards
    Karl-Heinz

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

    Last edit: by Karl-Heinz. Reason: added the wrong description

    using parentheses to access array elements 23 Oct 2021 17:40 #20092

    • Chris
    • Chris's Avatar


  • Posts: 3856
  • Hi Karl-Heinz,

    This seems to compile and run fine on my machine. Do you get any errors?

    .
    XSharp Development Team
    chris(at)xsharp.eu

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

    Last edit: by Chris.

    using parentheses to access array elements 23 Oct 2021 17:52 #20093

    • FFF
    • FFF's Avatar


  • Posts: 1398
  • Using the FP Sample from Xide, (with no additional /Fox2) i see the error. It dissappears, when i add the switch
    Regards
    Karl (X# 2.14.0.4; Xide 1.33; W8.1/64 German)

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

    using parentheses to access array elements 23 Oct 2021 18:00 #20094

    • Chris
    • Chris's Avatar


  • Posts: 3856
  • Yeah, indeed /fox2 is indeed necessary for this feature to work. It's mentioned in the What's New document.
    XSharp Development Team
    chris(at)xsharp.eu

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

    using parentheses to access array elements 23 Oct 2021 18:45 #20096

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • Hi Chris,

    Does this mean that you never see the "left-hand" compile error ?

    When /Fox2 is disabled i see the "left-hand" compile error because in this case the function arrayhold() is meant and not the array. Now "arrayhold(1) = 12" means that i want to assign 12 to the return value of the arrayhold() function, so the error is imo correct.

    A - fox independed - sample to enforce a "left-hand" compile error:

    12:Tostring() += "34"

    Before Kevin isn´t back to explain what excatly he´s doing i have no other explanation why he gets the "left-hand" error

    regards
    Karl-Heinz

    ok, alles klar ;-) - after a refresh i see the the other replies.

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

    Last edit: by Karl-Heinz.

    using parentheses to access array elements 23 Oct 2021 18:51 #20097

    • Chris
    • Chris's Avatar


  • Posts: 3856
  • Hi Karl-Heinz,

    I do get the error when /fox2 is disabled, and this is by design.

    .
    XSharp Development Team
    chris(at)xsharp.eu

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

    using parentheses to access array elements 25 Oct 2021 17:38 #20113

    • kevclark64
    • kevclark64's Avatar
    • Topic Author


  • Posts: 123
  • I think I understand what happened now. I've been testing a large FoxPro procedure file to see what generates errors. I had the /fox2 switch on, but the array was not declared. The array in the original Foxpro code was declared using EXTERNAL ARRAY, which I think is not supported in XSharp currently. I had commented that out since it was giving an error, but that meant that the array wasn't declared. When I add DIMENSION arrayhold(10) then I can use parentheses with the array. Sorry for the confusion.

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

    using parentheses to access array elements 25 Oct 2021 19:07 #20115

    • Chris
    • Chris's Avatar


  • Posts: 3856
  • That's fine of course Kevin, thanks for your feedback!
    XSharp Development Team
    chris(at)xsharp.eu

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

    • Page:
    • 1