Adam Shelly wrote:
> On 1/28/08, Michael W. Ryder <_mwryder / worldnet.att.net> wrote:
>> Robert Klemme wrote:
>>> 2008/1/28, Michael W. Ryder <_mwryder / worldnet.att.net>:
>>>> On a related note, is there any way to create a string from a hex number
>>>> other than separating each two digits and using .chr to convert them to
>>>> a number and adding them to the string?  If I have a string such as
>>>> 0x7FFFFFFFFFFF I have to use something like str1 = 0x7F.chr followed by
>>>> 5 str1 << 0xFF.chr which seems to be unnecessarily clumsy.
>> The reason I asked is that sometimes it is easier for me to think in hex
>> when creating masks for logical operations.  Plus, I learned the PCL
>> codes for printing using hex and it is easier for me to use them that
>> way.  In Business Basic to enter a group of hex characters into a string
>> I just use A$=$1B2C062C$ to create a 4 character string.  No need to
>> enter each character individually.
> 
> Are you looking for something like this?
> 
> irb(main):010:0> ["414243"].pack('H*')
> => "ABC"
> irb(main):011:0> ["7FFFFFFFFFFF"].pack('H*')
> => "\177\377\377\377\377\377"
> irb(main):012:0> A=['1B2C062C'].pack('H*')
> => "\e,\006,"
> 
> -Adam
> 

That is much better, I will have to read up on pack and template strings 
now but at least I have a starting point.  It's not as concise as what I 
am used to but it is usable.  Thank you for pointing this out.