PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WEBDEV 2024 → How to address a table fieldname with a variable ?
How to address a table fieldname with a variable ?
Débuté par Stef, 05 juin 2013 16:35 - 4 réponses
Membre enregistré
45 messages
Posté le 05 juin 2013 - 16:35
Hi all,

In webdev 17 I need to loop through all fields in a certain row of a table. Looping through columns is no problem, but the issue is that TABLENAME.variableInsteadOfFieldname is not accepted so I cannot point to a specific cell.

So the basic question here is how to replace a fieldname by a variable.

Thx
Posté le 05 juin 2013 - 16:56
Hi Stefan

what you are looking for is called "indirection"... Look it up in the help.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

New web site (EXPERIMENTAL) http://www.fabriceharari.eu
(More information on http://www.fabriceharari.com)


On 6/5/2013 8:35 AM, Stef wrote:
Hi all,

In webdev 17 I need to loop through all fields in a certain row of a
table. Looping through columns is no problem, but the issue is that
TABLENAME.variableInsteadOfFieldname is not accepted so I cannot point
to a specific cell.

So the basic question here is how to replace a fieldname by a variable.

Thx
Membre enregistré
45 messages
Posté le 05 juin 2013 - 17:55
Thank you again Fabrice, i will try and see whether the help can help me out :) with indirection
Membre enregistré
45 messages
Posté le 06 juin 2013 - 12:40
No success in tackling this issue :(

I thought the indirection
{TableName+"."+FieldName+"..VALUE"} =FieldValue
as you can see in the code below would create a usuable variable containing the text value of a certain cell so I can send its value to another procedure, but execution of this line generates an error
'fs_detail.numero..VALUE' element unknown.

gsXMLdoc=""
gsXMLName=Today()+Now()
TableName, TableFieldName, FieldName, FieldValue are strings
column is int
SequenceNumber is int = 1
TableName = "fs_detail"

FOR column = 1 TO TableCount(TABLE_XML98_BiblioElements,toColumn)
FieldName=TableEnumColumn(TABLE_XML98_BiblioElements,column)
TableFieldName= TableName+"."+FieldName
{TableName+"."+FieldName+"..VALUE"} =FieldValue
DataToService("c","00","FS_ASI",TableFieldName,FieldValue,SequenceNumber)
SequenceNumber++
END
...

Help would be immensely apprciated as this is really a showstopper for my project !!!
Message modifié, 06 juin 2013 - 12:43
Posté le 06 juin 2013 - 15:28
Hi Stefan

you are nearly there...

the ..property should NOT be part of the indirection, as the indirection
is there for the variable/control

So you should have something like
{TableName+"."+FieldName,TypeOfItem}..VALUE =FieldValue

the TypeOfItem information is optional, but allows the interpreter to
swift through only part of the tables, and therefore clearly increases
the speed.

best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

New web site (EXPERIMENTAL) http://www.fabriceharari.eu
(More information on http://www.fabriceharari.com)


On 6/6/2013 4:40 AM, Stef wrote:
No success in tackling this issue :(

I thought the indirection {TableName+"."+FieldName+"..VALUE"} =FieldValue
as you can see in the code below would create a usuable variable
containing the text value of a certain cell so I can send its value to
another procedure, but execution of this line generates an error
'fs_detail.numero..VALUE' element unknown.

gsXMLdoc=""
gsXMLName=Today()+Now()
TableName, TableFieldName, FieldName, FieldValue are strings
column is int
SequenceNumber is int = 1
TableName = "fs_detail"

FOR column = 1 TO TableCount(TABLE_XML98_BiblioElements,toColumn)
FieldName=TableEnumColumn(TABLE_XML98_BiblioElements,column)
TableFieldName= TableName+"."+FieldName
{TableName+"."+FieldName+"..VALUE"} =FieldValue
DataToService("c","00","FS_ASI",TableFieldName,FieldValue,SequenceNumber)
SequenceNumber++
END
..

Help would be immensely apprciated as this is really a showstopper for
my project !!!