• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting Hex to binary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting Hex to binary


  • Subject: Re: Converting Hex to binary
  • From: Barry Wainwright <email@hidden>
  • Date: Sun, 09 Jan 2005 23:31:35 +0000

On Jan 8, 2005, at 2:40 PM, Bernardo Hoehl wrote:

> Hi List!
>
> I know that I over work my scripts all the time.
>
> But this is common to newbyes. Ins't it?
>
> I have this script that aparently is functional:
>
> set theInput to "0309"
>
> set HexList to every character of ("0123456789ABCDEF")
>
> set binList to {"0000", "0001", "0010", "0011", "0100", "0101",
> "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101",
> "1110", "1111"}
> set ConvertedBin to ""
>
> repeat with i from 1 to the count of theInput
>     repeat with ii from 1 to the count of HexList
>         if item i of theInput is item ii of HexList then
>             set ConvertedBin to ConvertedBin & item ii of binList
>         end if
>     end repeat
> end repeat
> return ConvertedBin --returns "0000001100001001"
>
>
> Please:
>
> Could you comment my script?
>
> I bet you would write it in a shorter way.


do shell script "echo \"2 i 16 o " & theInput & " p\" | dc"

(if you want the leading zeros you will have to add them...)


--
Barry



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Converting Hex to binary (From: deivy petrescu <email@hidden>)

  • Prev by Date: Re: Reading a pdf text file
  • Next by Date: Re: Reading a pdf text file
  • Previous by thread: Re: Converting Hex to binary
  • Next by thread: Re: Converting Hex to binary
  • Index(es):
    • Date
    • Thread