Sign in to follow this  
Followers 0
computergroove

How do I StringReplace a value that changes?

4 posts in this topic

I have an xml file with the string "/merchant/poslogin.php?key=20000209_432</url>" and my script changes the value of 20000209_432. If I need to change it again I want to search for the string "/merchant/poslogin.php?key=" and tell autoit to count 27 characters from the string and replace the next 12 digits with my inputbox value. How can I tell StringReplace to start 27 digits from the string being replaced?

$NewCustomerID = StringReplace($chars, "2000293", $CustomerID) <-- Here
    $NewCustomerPin = StringReplace($NewCustomerID, "432", $CustomerPin)
    FileOpen("tiapp.xml", 2)
    FileWrite("tiapp.xml", $NewCustomerPin)
    FileClose($xmlfile)
    Exit

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites



I believe the StringTrimRight() function will do some good here.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

OK that worked out good. Here is my final code:

$NewCustomerID = StringReplace($chars, 553, $CustomerID) ;Repaces the Customer ID in tiapp.xml
    $NewCustomerData = StringReplace($NewCustomerID, 562, $CustomerPin) ;NewCustomerData hold the properly modified xml data
    FileOpen("tiapp.xml", 2)
    FileWrite("tiapp.xml", $NewCustomerData)
    FileClose($xmlfile)
    Exit
Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

heres another way.

#include <String.au3>

$sString = "/merchant/poslogin.php?key=20000209_432</url>"
$sID = _StringBetween($sString,"key=","</url>")
$sNewString = StringReplace($sString,$sID[0],"newKey")
MsgBox(0,"",$sNewString)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
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
Sign in to follow this  
Followers 0