Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 4 Jahren
Letzter Beitrag:
vor 4 Jahren
Beteiligte Autoren:
Joel, Alexandre Leclerc, Arie, Konrad Filser

How to get list of item Name and an Item's data in a record

Startbeitrag von Joel am 04.08.2014 16:04

Hi All -

I'm trying to code something, that I'm sure is very simple, but I can't find what I need in the help section.
s = string
FinalString = string
For Each Record of HFfile where...

For Each Item of Record //this part would create a string of all the items in the record with the data
s = fieldName+"fieldvalue"
FinalString = FinalString+s




Re: How to get list of items in a record

Hi Joel,
HListItem() is your friend and the help even has an example of exactly your case.

von Arie - am 04.08.2014 16:19

Re: How to get list of items in a record

Thanks Arie -

But can't get it to work - I think it expects me to know something that I don't - but I'll keep beating on it - you pointed me in the right direction!

von Joel - am 04.08.2014 16:33

Re: How to get list of items in a record

OK - I think so far that this procedure wants to give me:


I need:

ItemName=ItemValue for each record.

Do I understand this right?

von Joel - am 04.08.2014 16:51

Re: How to get list of items in a record


you can try this (Code of older WD Versions, but it works)

cTable is string = "CUSTOMER"
cListItem is string = Upper(HListItem({cTable},hLstDetailPlus)) // Read Tablestructure
cItem is string
cItemName is string
cString is string
i is int

i = i + 1
cItem = ExtractString(cListItem, i, CR)

cItemName = ExtractString(cItem, 1, TAB) // Fieldname
cString += cItemName + " :" + {cTable+"."+cItemName}" + CR

Konrad Filser

von Konrad Filser - am 04.08.2014 16:57

Re: How to get list of items in a record

Hi Joel,

I don't know what you try to achieve (because much better solutions could probably be found instead of building a string with field=value) but you can also use:

- HListItem() in parallel with HRetrieveRecord();
- In version 19, use a Record variable to pass data along;
- Use HRecordToXML();
- Use databinding to copy records to a structure or class in a single operation;
- ...

It all depends what you need to do. (But maybe in your case this is the only solution to what you try to achieve. In that case, the code Konrad Filser made is a good start for you to work with and optimize - because there is room for that.)

Best regards,
Alexandre Leclerc

Edit 1: Fixed typo.

von Alexandre Leclerc - am 04.08.2014 17:55

Re: How to get list of items in a record

Hi Alexandre -

I'm going to look into your code. I did figure out how to do it though... Here's the code I came up with ( I figured I'd put it out there in case others are struggling with something similar):

PROCEDURE Invoice_GetActive(par_FileName, par_Param1, par_Param2)

sItemNameList is string = HListItem(HFInvoices)
sItem is string = "Start"
iItemNameRank is int
//sItemType is string
sFileName is string = par_FileName
sItemValue is string
sEntireRecordData is string
sEntireFileData is string

FOR EACH {sFileName,indFile} WHERE "b1ActiveItem=1 AND HFInvoices.bDeleted = 0 and Hfinvoices.bVoid=0"
sEntireRecordData = ""
WHILE sItemNameList ""
sItem = ExtractString(sItemNameList,iItemNameRank,CR)
sEntireRecordData = sEntireRecordData + sItem+"="+sItemValue+"|"
sEntireFileData = sEntireFileData + sEntireRecordData + CRLF

RESULT = sEntireFileData

I'm trying to get data passed from different projects to each other. Each project has it's own analysis so I need a way to send for the data. Fabrice recommended that I use HttpRequest and create a webservice. I have that working, but it does require making long data strings that then have to be "decoded". I was wondering if "DeclareExternal" or something else might be easier, but I am not well versed in WebDev and WL.

von Joel - am 05.08.2014 13:38

Re: How to get list of items in a record

Hi Joel,

Then I would recommend to either use:
- HRecordToXML() and it's counterpart to import (or at least you also have the opportunity to use the XML functions of WinDev and WebDev to parse the XML file and import manually);
- Structures/Classes and Serialize/Deserialize (json or XML depending of the portability you need) to pass this data.

This will be the easiest way to implement quickly your solution and be very portable with not only your system but others, without reinventing the wheel, so to speak.

Your code will work. Its just that usually I try to use the tools readily available. Usually it pays to go that way, even if things are not always as optimized as we would like them to be.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 05.08.2014 13:46
Thanks again Alexandre -

I do too, I just don't know enough of the WebDev built in functions and such. I've been working with WebDev about 5 years now and still don't know all it's capabilities. I have lots more to learn!


von Joel - am 05.08.2014 14:01
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.