Thanks for the function.
Sorry for being dense but I don't get how to pass the hex string to
the function and then "set the selection to the output of the
function."
Are you implying that I should be able to invoke this function from
within BBEdit or do I just call this function from another
AppleScript?
Thanks,
Ken P.
At 8:06 PM -0400 6/1/06, David Livesay wrote:
This AppleScript function should convert hex strings to decimals:
on fromHex(str)
set n to 0
set i to 1
repeat with a in reverse of every text item of str
if a is greater than 9 or a is less than 0 then
set a to ASCII number of a
if a is greater than 70 then
set a to a - 87
else
set a to a - 55
end if
end if
set n to n + a * i
set i to i * 16
end repeat
return n
end fromHex
You can use find to find and select the hex strings, then set the
selection to the output of the function, then find next. Make sure
you start at the top and don't loop.
On Jun 1, 2006, at 9:23 AM, Kenneth Prager wrote:
Hi All,
I am receiving some status reports with numbers that are in hex
format. I was planning to use BBEdit to reformat the report to
make it more readable and would like to convert the hex numbers to
decimal using BBEdit, rather than writing an external program.
I know how to find the hex numbers, using grep, but at am at a loss
regarding the best way to convert them. I figure that one way is
to send the numbers to an external script but am not sure how to
set this up. Is this the best way to proceed or can the conversion
be done within BBEdit? (I read through the manual but didn't see
anything in the text conversion section that looked like it would
work.) Any suggestions would be appreciated.
TIA,
Ken Prager
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>