Is there a way, either in Foxpro dialect or the core dialect, to indirectly reference a field name? In FoxPro I can do this:
replace (field(1)) with "somevalue"
-or-
cfieldname="myfield"
replace (cfieldname) with "somevalue"
Is there anyway to do that currently in XSharp?
indirect reference to field name
- kevclark64
- Posts: 127
- Joined: Thu Aug 15, 2019 7:30 pm
- Location: USA
indirect reference to field name
This presently fails at compile time... It complains about the wrapping parens:
Another similar construct in VFP syntax is this, it doesn't compile either:
They have a listing of current VFP support here: https://www.xsharp.eu/itm-help/foxpro-c ... ility-list
Is shows that REPLACE command is implemented, but apparently it needs further tweaking to get there all the way.
Code: Select all
Replace (cfieldname) with "somevalue"
Another similar construct in VFP syntax is this, it doesn't compile either:
Code: Select all
Replace &cFieldName With "somevalue"
They have a listing of current VFP support here: https://www.xsharp.eu/itm-help/foxpro-c ... ility-list
Is shows that REPLACE command is implemented, but apparently it needs further tweaking to get there all the way.
indirect reference to field name
Kevin,
If you want to do it the "command" way then we need to tweak the commands a bit.
Function based it already works like this (and this is what VO people are used to)
becomes
and
becomes either:
or
if you want to add a cursor name.
Don't worry if the help says that the fieldname has to be a symbol. The compiler will automatically convert the string to a symbol for you, because there is an implicit conversion between a symbol and a string and vice versa.
Robert
If you want to do it the "command" way then we need to tweak the commands a bit.
Function based it already works like this (and this is what VO people are used to)
Code: Select all
replace (field(1)) with "somevalue"
Code: Select all
FieldPut(1, "somevalue")
Code: Select all
cfieldname="myfield"
replace (cfieldname) with "somevalue"
Code: Select all
cfieldname="myfield"
FieldPutSym(cFieldName, "Somevalue)
Code: Select all
FieldPutSelect("Customers", cFieldName, "SomeValue)
Don't worry if the help says that the fieldname has to be a symbol. The compiler will automatically convert the string to a symbol for you, because there is an implicit conversion between a symbol and a string and vice versa.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
indirect reference to field name
Robert said
Don't forget this version of it:
And even this is valid in VFP:
And this is valid:
Yes sir, we definitely need the Command version.If you want to do it the "command" way then we need to tweak the commands a bit.
Don't forget this version of it:
Code: Select all
cFieldName = "SomeField"
Replace &cFieldName With "somevalue"
Code: Select all
lcFieldRef = "Cursor1.AppName"
Replace &lcFieldRef with "MyApp"
Code: Select all
lcCursor = "TsqlQuery"
lcField = "App"
Replace &lcField With "MyApp" In &lcCursor
-
- Posts: 200
- Joined: Wed Oct 09, 2019 6:51 pm
indirect reference to field name
FoxProMatt_MattSlay wrote: And even this is valid in VFP:
Code: Select all
lcFieldRef = "Cursor1.AppName"
Replace &lcFieldRef with "MyApp"
Code: Select all
lcCursor = "TsqlQuery"
lcField = "App"
Replace &lcField With "MyApp" In &lcCursor
indirect reference to field name
@ mainhatten - Yep, I understand the issue you are referring to, and I'm not offering examples posted here as best-practices, I'm just trying to help the X# Dev Team be aware of every possible code construct they may face in VFP code bases, even hacky ones.