WHat sort of practical use would such a function offer?
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Announcement
Collapse
No announcement yet.
Pack() function Equivalent in PB6?
Collapse
X
-
Sounds like the Pack function is really making a dynamic TYPE
structure.
I'm not sure how easy or practical it would be to attempt writing
a function in PB that can accept variable numbers of parameters that
can be of any type.
But if you have a specific list (or list specification), you should
be able to write a custom function. Ie:
Code:FUNCTION PackNnna( BYVAL One AS LONG, _ BYVAL Two AS INTEGER, _ BYVAL Three AS INTEGER, _ BYVAL Four AS STRING) AS STRING FUNCTION = MKL$( One) + MKI$( Two) + MKI$( Three) + Four END FUNCTION
get the idea.
------------------
Bernard Ertl
Leave a comment:
-
FYI Lance, The documentation for the pack (and unpack) function can be found at: http://www.perl.com/pub/doc/manual/h...func/pack.html
John
[This message has been edited by John Krahn (edited February 28, 2001).]
Leave a comment:
-
No problem, but I don't know if this will help much. Here's the code a put in my Perl script:
Code:$buffer = pack("Nnna*", 1, 1, length("RyanCross"), "RyanCross"); print $buffer;
" RyanCross"
-or more readable format: (numbers represent Ascii numbers of characters that cannot be seen)
"(0)(0)(0)(1)(0)(1)(0)(9)RyanCross"
Hopefully that helped and didn't hender. Hehe.
------------------
Thank you,
Ryan M. Cross
Webmaster FlexiFish Inc. UK
Likuid Creations Inc.
[This message has been edited by RyanCross (edited February 27, 2001).]
Leave a comment:
-
What does the resultant "packed byte list" look like? In other words, can you show us some "before" and "after" results?
Thanks!
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
Pack() function Equivalent in PB6?
Ok in Perl there is a function called "pack".
Code:pack(TEMPLATE, LIST);
Takes an array or list of values and packs it into a binary structure, returning the string containing the structure. The TEMPLATE is a sequence of characters that gives the order and type of values.
Code:$buffer = pack("Nnna*", 1, 1, length($nickname), $nickname);
------------------
Thank you,
Ryan M. Cross
Webmaster FlexiFish Inc. UK
Likuid Creations Inc.
[This message has been edited by RyanCross (edited February 27, 2001).]Tags: None
Leave a comment: