Jump to content

Replace All Zero's On Left Hand Side


Recommended Posts

  • Moderators

Here you go...

MsgBox(0, '', _RemoveDigit("018FE", 0))
Func _RemoveDigit($v_String, $i_Digit)
    If StringInStr($v_String, String($i_Digit)) Then
        For $i_count = 1 To StringLen($v_String)
            If StringMid($v_String, $i_count, 1) <> $i_Digit Then Return StringTrimLeft($v_String, $i_count - 1)
        Next
    EndIf
    Return $v_String
EndFunc

Edit:

Damn I'm slow today!

Edit2:

Had to modify mine, so it counted the number as a string.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Larry's should work, but here's an alternative.

$input = "000018FE"
$output = StringFormat ("%X", Dec($input))

MsgBox(0, "Result", $output)

;Similar to Larry's

Func _shorterFunction($input)
    Local $i
    For $i = 1 to StringLen($input)
        If StringMid($input, $i, 1) = "0" Then ContinueLoop
        Return StringMid($input, $i)
    Next
EndFunc

Edit: made $i Local for correctness...

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...