AutoHotkey Community

It is currently May 27th, 2012, 11:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 11th, 2008, 10:05 am 
Offline

Joined: January 2nd, 2008, 4:47 am
Posts: 150
Location: Freenode IRC
Actually, I'm interested in this function because I'd like to modify it to use an arbitrary character table. Base 46 including all URL compatible "non-reserved' characters including the symbols " - _ . ! ~ * ' ( )

Consider how TinyURL or YouTube urls are constructed, but utilizing all of the valid symbols in a lookup table.

_________________
Image

Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2008, 2:07 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
It is still just two lines for unsigned numbers
Code:
ToBase(n,b) {  ; n >= 0, 1 < b < StrLen(t), t = digits
   Static t := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~"
   Return (n < b ? "" : ToBase(n//b,b)) . SubStr(t,mod(n,b)+1,1)
}
Change the static variable t to contain your desired digits in order.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2008, 3:27 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
OMG! Laszlo you rock!!!
i never imagine that base conversion can be done in just one line
totally amazing :shock: :shock: :shock: :shock: :shock: :shock: :shock:

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2008, 2:54 am 
heresy wrote:
i never imagine that base conversion can be done in just one line

It's just a translation of the elementary school routine you're already familiar with. You must have a relatively deep understanding of AHK to figure it out though.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Edd, Exabot [Bot], HotkeyStick, Yahoo [Bot] and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group