using parentheses to access array elements

This forum is meant for questions about the Visual FoxPro Language support in X#.

Post Reply
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

using parentheses to access array elements

Post by kevclark64 »

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.

Code: Select all

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
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

using parentheses to access array elements

Post by Chris »

Kevin, how have you declared arrayhold in this case?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am

using parentheses to access array elements

Post by Karl-Heinz »

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

Code: Select all

FUNCTION Start() AS VOID
dimension arrayHold(3)

	arrayhold(1) = 12 

	RETURN

FUNCTION arrayHold(n)
	
	RETURN 1 
regards
Karl-Heinz
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

using parentheses to access array elements

Post by Chris »

Hi Karl-Heinz,

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

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
FFF
Posts: 1521
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

using parentheses to access array elements

Post by FFF »

Using the FP Sample from Xide, (with no additional /Fox2) i see the error. It dissappears, when i add the switch
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

using parentheses to access array elements

Post by Chris »

Yeah, indeed /fox2 is indeed necessary for this feature to work. It's mentioned in the What's New document.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am

using parentheses to access array elements

Post by Karl-Heinz »

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.
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

using parentheses to access array elements

Post by Chris »

Hi Karl-Heinz,

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

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

using parentheses to access array elements

Post by kevclark64 »

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.
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

using parentheses to access array elements

Post by Chris »

That's fine of course Kevin, thanks for your feedback!
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply