AppleScript: convert string to integer

on string_2_int(num_string, base)
    set r to 0
    set digit_string to "0123456789ABCDEF"
    set c_list to every character of num_string
    set c_list_length to count c_list
    repeat with x from c_list_length to 1 by -1
        set curr to item (c_list_length - x + 1) of c_list
        set r to r + ((offset of curr in digit_string) - 1) * (base ^ (x - 1))
    end repeat
    return r / 1
end string_2_int