Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
10
Erster Beitrag:
vor 2 Jahren, 4 Monaten
Letzter Beitrag:
vor 2 Jahren, 4 Monaten
Beteiligte Autoren:
Michael Drechsel, Bart VDE, Piet van Zanten, Stefan Bentvelsen, Fabrice Harari

[WD20] Generic tableaddline

Startbeitrag von Michael Drechsel am 06.10.2015 10:01

Hi,

for some reasons I need a generic "tableaddline". In the notes section of the table columns I save the content at design time. Like:

content=myarray[1].name

another column:

content=myarray[1].age

A program reads the notes and build a string like

MyTableladdlinestring="myarray[1].name,myarray[1].age"

and final

tableaddline(mytable,mytableaddlinestring)

But it doesn´t work because it shows the complete "mytableaddlinestring" in column1 .

I need any indirection ... but I have no idea :confused:

Antworten:

Hi Michael

to do that, you need to:
- make sure that none of your variable contains a TAB
- build your string as you are doing now but TAB separated
- use tableadd instead of tableaddline

Best regards

von Fabrice Harari - am 06.10.2015 10:16
Hi Fabrice,

works not really. And I can´t be sure that no TABs in my fields.

It´s pity, I have a large treeviewtable and I can´t use the data binding because some columns must be in master and childfile and I can define only once in the 7 TAB.

von Michael Drechsel - am 06.10.2015 15:51
Hi Michael,

may be, you can build the string like you do now and execute it by using Compile() or ExecuteCode() ?

von Stefan Bentvelsen - am 06.10.2015 17:59
Hi,

I agree with Stefan, and I would try with ExecuteCode:

sName is string = "John"
nAge is int = 21
sCode is string

sCode=StringBuild("TableAddLine(table1,""%1"",""%2"")",sName,nAge)

ExecuteCode(sCode)

von Bart VDE - am 06.10.2015 19:48
Hi Michael,

Perhaps something like this:
TableAddline(MyTable) //add empty line
nLine is int=Tablecount(MyTable) //get row #
For i=1 to TableCount(MyTable,toColumn)
Table[nLine,nCol]=Extractstring(MyTableAddLineString,nCol,Separator)......
end

Not tested

Regards,
Piet

von Piet van Zanten - am 06.10.2015 19:52
Hi Stefan+Bart,

Yes, I tried this hours ago. And also "EvaluteExpression"
ExecuteCode() fails with "Control not found". (Yes I put it in quotes like the help says)

EvaluteExpression works, but it fills only the first element of my array in all table rows. It looks like the compiler ignors "n" in myarray[n].name.

von Michael Drechsel - am 06.10.2015 19:52
Hi Piet,

yes, I do something similar.

The Problem is here

Table[nLine,nCol]=Extractstring,MyTableAddLineString,nCol,Separator)......


perhaps extractstring gives back= "Myarray[n].name"

so we have

Table[nLine,nCol]= "Myarray[n].name"

and not the value of that ...

von Michael Drechsel - am 06.10.2015 19:56
Hi,

A different approach may be to define an array of structure and use this array as a datasource for your table

You can add new records to your array, and after that a simple TableDisplay to show it in your table

Bart

von Bart VDE - am 07.10.2015 07:47
Hi Bart,

its a Treeviewtable and I need to define the first Column with the result of the file1 (as master) and also as child with the result from file2.

Have no idea how to do that with direct databinding form a structure array

von Michael Drechsel - am 07.10.2015 07:56
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.