Jump to content

Variable output to variable but skipping X amount of characters from left


Recommended Posts

How do you get the data from a variable and transfer the data to another variable while knocking off the first 2 characters? For example if the variable data is 0x12345678 how can I make a new variable that only has the 12345678 part and removed the initial 0x

Thanks

Link to comment
Share on other sites

Assuming that its a string

$a = "0x12345678"
$b = StringRight($a,StringLen($a)-2)
MsgBox(0,"",$b)

Edit, some other method can b

StringSplit

StringReplace

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

If variable data is string type it`l work

$a = "0x12345678"
$b = 0x12345678
MsgBox(0,$a,$b)

$a = 0x12345678
$b = StringRight($a,StringLen($a)-2)
$c = "0x12345678"
$d = StringRight($c,StringLen($c)-2)
MsgBox(0,$b,$d)
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • Moderators

Some more examples.

$a = 0x12345678
$b = hex($a)

$c = "0x12345678"
$d = StringTrimLeft($c, 2)

MsgBox(0,"Results","$b = " & $b & @CRLF & "$d = " & $d )

Hex() would probably work on the string as well.

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

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...