|
Hi Jon, The why behind this... The C-function I'm talking about is recv() and is used to receive bytes from a sockets connection. All this is buffered internally in my program by means of a variable length field. Now instead of passing another buffer to the recv() function, and concatenating this afterwards to the varying field, I wanted to avoid moving buffers around (string manipulation in RPG is way to costly). Since I don't know in advance how many bytes I will be receiving (this is the result of the C-function), and since the destination is not the beginning of the varying length field, I just calculated a pointer to the correct offset in the varying field (in the test example I gave I had a based buffer, but this was only for demonstration). Once the recv() function completed, I could then do a %Len(Var) = %Len(Var) + rc ... but this went wrong. Anyway, solved it via a based of a 5U 0 field on the varying length field. Kind regards, Paul -----Original Message----- From: Jon Paris [mailto:Jon.Paris@partner400.com] Sent: 03 June, 2002 23:42 To: rpg400-l@midrange.com Subject: Help... %Len initializing field ? ... Paul - the other answers you received are correct in that you need to set the length before you start. My question to you is why one earth do you want to do this much work? If you need to pass a string pointer to a C function use the Options(*String) on the proto and the compiler does the work for you. If (as seems to be the case here) you are simply passing a pointer and the function places a string in that location, then all you need to do is use %Str to de-reference the pointer and you can load the data into a fixed or variable length field. In your case: Buffer = %Str(pFixed); appears to be what you need. Is there a reason why this won't work for you? Jon Paris Partner400 ------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it. ==============================================================================
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.