Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 9 Monaten, 2 Wochen
Letzter Beitrag:
vor 9 Monaten, 2 Wochen
Beteiligte Autoren:
Sam Asid, DerekT, Peter Holemans

How to Store Structure Variable into table

Startbeitrag von Sam Asid am 09.11.2016 08:06

Hello All,

I have defined a variable structure in WD21 as ffs;

MyStruct is Structure
Fld1 is string
Fld2 is Int
Fld3 is Numeric
END

WorkStruct is MyStruct

Assignments go like this
WorkStruct: Fld1="name_of_person"
WorkStruct: Fld2=3
WorkStrcut:Fld3=1843.29

If I have done about 50 assignments as per above, is there a way I can save to a table/file if the 'Fld"s are the same as found in the table?

I am looking at something similar to HCopyRecord

Any other way to do this would also be appreciated.

Sam

Antworten:

Hi,

Yes this is possible using GetDefinition of the structure, looping through all elements of the structure and assigning them via indirection to the record fields.

Don't forget to do the assignment in a 'WHEN EXCEPTION' block resetting exception handling using ExceptionEnable() whenever the assignment failed. This is like a 'try' block in Java or .Net.

Alternative to a structure you could use a class with the record structure defined as members. Here, you can use 'FileToMemory' and 'MemoryToFile' to auto-assign matching field names. On top of that you can declare even members with their own names and use the 'mapping' keyword to assign it to a specific field in a table.

Cheers,

Peter Holemans

von Peter Holemans - am 09.11.2016 09:51
Thanks Peter. I would have a go at it.

I do appreciate it.

Sam.

von Sam Asid - am 09.11.2016 11:37
Sam

If going down the 'mapping' option as suggested by PH the make yourself a quick project and create a Form and Window (in that order) from the MVP RAD option.

If you have WD v20 then there are examples already available.

t.b.h. not all of it works as it should straight out of the box but the principles are all there if you study the classes that are created.
Only operational for WD unfortunately.

von DerekT - am 09.11.2016 16:58
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.