Announcement

Collapse
No announcement yet.

Pack() function Equivalent in PB6?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    WHat sort of practical use would such a function offer?

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Bern Ertl
    replied
    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
    I'm not sure if the MKL$ & MKI$ use big endian or not, but you
    get the idea.



    ------------------
    Bernard Ertl

    Leave a comment:


  • John Krahn
    replied
    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:


  • RyanCross
    replied
    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;
    This outputs: (without quotes)

    "      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:


  • Lance Edmonds
    replied
    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:


  • RyanCross
    started a topic Pack() function Equivalent in PB6?

    Pack() function Equivalent in PB6?

    Ok in Perl there is a function called "pack".

    Code:
    pack(TEMPLATE, LIST);
    I'm wondering if there is a simlar function in PB or a way of doing somethign similar. For people not familar with Perl or this funciton in Perl he's the dicription of it:

    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.
    Here's the line of code I'm trying to convert to PB6:

    Code:
    $buffer = pack("Nnna*", 1, 1, length($nickname), $nickname);
    Tahnks for any help!

    ------------------
    Thank you,
    Ryan M. Cross
    Webmaster FlexiFish Inc. UK
    Likuid Creations Inc.

    [This message has been edited by RyanCross (edited February 27, 2001).]
Working...
X