Jump to content

I need to replace a string that changes - help


Recommended Posts

I have been wrestling with this for several days and to make things worse the project changed part way into the analysis. I have the following code in an xml file:

<?xml version='1.0' encoding='UTF-8'?>
<ti:app xmlns:ti='http://ti.appcelerator.org'>
<!-- These values are edited/maintained by Titanium Developer -->
<id>MAC</id>
<name>MAC</name>
<version>2.2</version>
<publisher>MAC</publisher>
<url>http://www.MAC.com</url>
<icon>icon.png</icon>
<copyright>2011 by LLC</copyright>
<!-- Window Definition - these values can be edited -->
<window>
<id>initial</id>
<title>MAC Merchant</title>
<url>app://index.html</url>
<width>620</width>
<max-width>3000</max-width>
<min-width>0</min-width>
<height>500</height>
<max-height>3000</max-height>
<min-height>0</min-height>
<fullscreen>false</fullscreen>
<resizable>true</resizable>
<chrome scrollbars="true">true</chrome>
<maximizable>true</maximizable>
<minimizable>true</minimizable>
<closeable>true</closeable>
</window>
</ti:app>

I have posted about this before but again the file format changed and I cannot wrap my mind around how to do the following.

I have 2 windows that asks for 2 items, $CustomerID and $CustomerPin. The end result I am looking for is this:

<url>app://index.html</url>

needs to look like this:

<url>https://www.MAC.com/merchant/poslogin.php?key=$CustomerID_$CustomerPin</url>

I posted my source in the other thread but here it is again:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=MacIcon.ico
#AutoIt3Wrapper_outfile=IDPinChange.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>

$xmlfile = FileOpen(@ProgramFilesDir & "\MAC Merchant\tiapp.xml", 0)

If $xmlfile = -1 Then ; Check if file opened for reading OK
    MsgBox(0, "Error", "Unable to open tiapp.xml")
    Exit
EndIf

While 1
    $chars = FileRead($xmlfile) ;reads the xml file and adds it to $chars
    $CustomerID = InputBox("Customer ID", "Please enter your 9 digit Customer ID found on your My Area Card invoice. If you need assistance, please visit http://www.MAC.com or contact your MAC Sales Representative.", "", " M9")
    If @error = 1 Then Exit
    $IDLen = StringLen($customerID)
        If $IDLen < 8 Then
            Do
            $iButton = MsgBox(1, "Customer ID Length Error", "This field requires 9 digits. If you dont have a 9 digit number to enter then add zero's to the front.")
                If $iButton = 2 then Exit
            $CustomerID = InputBox("Customer ID", "Please enter your 8 digit Customer ID found on your My Area Card invoice. If you need assistance, please visit http://www.MAC.com or contact your My Area Card Sales Representative.", "", " M9")
                If @error = 1 Then Exit
            Until StringLen($CustomerID) = 9
        EndIf
    $CustomerPin = InputBox("Customer Pin", "Please enter your 3 digit Pin Number which is also on your invoice.", "", " M4")
        If @error = 1 Then Exit
    $PinLen = StringLen($customerPin)
        If $PinLen < 4 Then
            Do
            $iButton2 = MsgBox(1, "Customer Pin Length Error", "This field requires 4 digits. If you dont have a 4 digit number then add zero's to the front.")
                If $iButton2 = 2 then Exit
            $CustomerPin = InputBox("Customer ID", "Please enter your 4 digit Pin Number which is also on your invoice.", "", " M4")
                If @error = 1 Then Exit
            Until StringLen($CustomerPin) = 4
        EndIf

    $sString = StringRegExpReplace($chars, "(?m:^)(?i)(<url.+.com)(</url>)", "$1poslogin.php?key=" & $CustomerID & "_" & $CustomerPin & "$2")
    FileOpen(@ProgramFilesDir & "\MAC Merchant\tiapp.xml", 2) ;Opens the xml file and sets it to write mode
    FileWrite(@ProgramFilesDir & "\MAC Merchant\tiapp.xml", $sString)
    FileClose($xmlfile)
    Exit
WEnd

Func _Exit()
    Exit
EndFunc

What happens is that after the code is changed the first time, the end user might need to modify it again. If they need to do that the code will go from initially looking like this:

<url>app://index.html</url>

to this:

<url>https://www.MAC.com/merchant/poslogin.php?key=000000000_0000</url>

and finally to this:

<url>https://www.MAC.com/merchant/poslogin.php?key=111111111_0000</url>

How can I code this to take into account the possibility of the end user changing their $CustomerID and $CustomerPin?

Relevant details:

1. The tiapp.xml is installed by an external application installer.

2. I can delete the entire contents as part of my script.

3. CustomerID needs to be 9 characters in length in all cases and the CustomerPin needs to be 4 characters long in all cases.

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

Link to comment
Share on other sites

This should do the replacements on the stock file as well as update new customer numbers and pins. I added StringFormat() lines an removed the StringLen() loops...if the number is not long enough, the respective number of zeroes are added.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=MacIcon.ico
#AutoIt3Wrapper_Outfile=IDPinChange.exe
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>

Local $sString
$xmlfile = FileOpen(@ProgramFilesDir & "\MyAreaCard Merchant\tiapp.xml", 0)

If $xmlfile = -1 Then ; Check if file opened for reading OK
    MsgBox(0, "Error", "Unable to open tiapp.xml")
    Exit
EndIf

While 1
    $Chars = FileRead($xmlfile) ;reads the xml file and adds it to $chars
    $CustomerID = InputBox("Customer ID", "Please enter your 9 digit Customer ID found on your My Area Card invoice. If you need assistance, please visit http://www.myareacard.com or contact your My Area Card Sales Representative.", "", " M9")
    If @error = 1 Then Exit
    $CustomerID = StringFormat("%09u", $CustomerID) ;Add preceeding zeros to make 9 digits

    $CustomerPin = InputBox("Customer Pin", "Please enter your 3 digit Pin Number which is also on your invoice.", "", " M4")
    If @error = 1 Then Exit
    $CustomerPin = StringFormat("%04u", $CustomerPin) ;Add preceeding zeros to make 4 digits

    If StringRegExp($Chars, "(?m:^)(?i)(<url>.+\.com)(</url>)", 0) Then ;line starts with "<url> and ends with ".com</url>"
        $sString = StringRegExpReplace($Chars, "(?m:^)(?i)(<url.+\.com)(</url>)", "$1poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$2") ;If you don't want this cahange, change "$sString" INSIDE next lines SRE to "$Chars"?
    ElseIf StringRegExp($Chars, "(?m:^)(?i)(<url>.+\.com.+=).+(</url>)", 0) Then ;line is "<url>, some characters, .com, some characters then =", some characters, and ends with </url>"
        $sString = StringRegExpReplace($Chars, "(?m:^)(?i)(<url>.+\.com.[^=]+).+(</url>)", "$1=" & $CustomerID & Chr(95) & $CustomerPin & "$2")
    EndIf

    
    If StringRegExp($sString, "(?m:^)(?i)(<url>)(.+\.html)(</url>)", 0) Then ;line is "<url>app://index.html</url>"
        $sString = StringRegExpReplace($sString, "(?m:^)(?i)(<url>)(.+\.html)(</url>)", "$1https://www.myareacard.com/merchant/poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$3")
    ElseIf StringRegExp($sString, "(?m:^)(?i)(<url>)https://.+=", 0) Then ;line starts with "<url>https://"
        $sString = StringRegExpReplace($sString, "(?m:^)(?i)(<url>https://[^=]+).+(</url>)", "$1=" & $CustomerID & Chr(95) & $CustomerPin & "$2")
    EndIf

    FileOpen(@ProgramFilesDir & "\MyAreaCard Merchant\tiapp.xml", 2) ;Opens the xml file and sets it to write mode
    FileWrite(@ProgramFilesDir & "\MyAreaCard Merchant\tiapp.xml", $sString)
    FileClose($xmlfile)
    Exit
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

EDIT: I found out that if I have a backreference in quotes and it is followed by a variable that is a number, the number(s) are combined backreference to make it a different backreference. For example:

If $CustomerID = 000000001, Then

"$1" & $CustomerID
is evaluated as
"$1000000001"
the backreference becomes 1,000,000,001...I did not know that.

EDIT EDIT:There is probably a more efficient way to do this, but RE's are tough for me. I think you could sequence the SRER's so that you do not need the If...Then and SRE lines.

Edited by Varian
Link to comment
Share on other sites

  • Moderators

computergroove,

Here is my version of how you might do it:

$chars = "<?xml version='1.0' encoding='UTF-8'?>" & @CRLF & _
        "<ti:app xmlns:ti='http://ti.appcelerator.org'>" & @CRLF & _
        "<!-- These values are edited/maintained by Titanium Developer -->" & @CRLF & _
        "<id>com.skyaim.merchantapp</id>" & @CRLF & _
        "<name>MyAreaCard Merchant</name>" & @CRLF & _
        "<version>2.2</version>" & @CRLF & _
        "<publisher>MyAreaCard</publisher>" & @CRLF & _
        "<url>http://www.myareacard.com</url>" & @CRLF & _
        "<icon>icon.png</icon>" & @CRLF & _
        "<copyright>2011 by SkyAim Media LLC</copyright>" & @CRLF & _
        "<!-- Window Definition - these values can be edited -->" & @CRLF & _
        "<window>" & @CRLF & _
        "<id>initial</id>" & @CRLF & _
        "<title>MyAreaCard Merchant</title>" & @CRLF & _
        "<url>app://index.html</url>" & @CRLF & _
        "<width>620</width>" & @CRLF & _
        "<max-width>3000</max-width>" & @CRLF & _
        "<min-width>0</min-width>" & @CRLF & _
        "<height>500</height>" & @CRLF & _
        "<max-height>3000</max-height>" & @CRLF & _
        "<min-height>0</min-height>" & @CRLF & _
        "<fullscreen>false</fullscreen>" & @CRLF & _
        "<resizable>true</resizable>" & @CRLF & _
        "<chrome scrollbars='true'>true</chrome>" & @CRLF & _
        "<maximizable>true</maximizable>" & @CRLF & _
        "<minimizable>true</minimizable>" & @CRLF & _
        "<closeable>true</closeable>" & @CRLF & _
        "</window>" & @CRLF & _
        "</ti:app>"

$CustomerID = 123456789
$CustomerPin = 1234

; First test the base code with no ID/PIN
If StringInStr($chars, "app://index.html") Then
    ConsoleWrite("Simple replace" & @CRLF)
    ; If the basic line exists replace it - this is simple as we know exactly what the text to replace is
    $sString = StringReplace($chars, "app://index.html", "https://www.myareacard.com/merchant/poslogin.php?key=" & $CustomerID & "_" & $CustomerPin)
Else
    ; If not, then we need to change existing ID and Pin - this requires an SRE
    $sString = StringRegExpReplace($chars, "(.*)key=(.*)\d{9}_\d{4}(.*)(.*)", "$1" & "key="  & $CustomerID & "_" & $CustomerPin & "$2")
EndIf
; Did it work?
ConsoleWrite($sString & @CRLF & @CRLF)

; Now we copy the modified text and test changing the ID/PIN if they exist
$chars = $sString
$CustomerID = 987654321
$CustomerPin = 9876


If StringInStr($chars, "app://index.html") Then
    ; If the basic line exists replace it - this is simple as we know exactly what the text to replace is
    $sString = StringReplace($chars, "app://index.html", "https://www.myareacard.com/merchant/poslogin.php?key=" & $CustomerID & "_" & $CustomerPin)
Else
    ; If not, then we need to change existing ID and Pin - this requires an SRE
    ConsoleWrite("SRE" & @CRLF)
    $sString = StringRegExpReplace($chars, "(.*)key=(.*)\d{9}_\d{4}(.*)(.*)", "$1" & "key="  & $CustomerID & "_" & $CustomerPin & "$2")
EndIf

; Did it work?
ConsoleWrite($sString & @CRLF)

Basically do a simple StringReplace the first time and only use a SRE if there is already an ID/PIN there. :idiot:

Edit: Rereading I am not sure that I was clear enough. You need only run the If...EndIf loop with the StringReplace and SRER once in your script - it will decide which action to take depending on the content of the text you feed into it. It runs twice in the example to show it working in both situations. :)

You do not need all that StringLen stuff either - you can use StringFormat to pad the results:

$CustomerID = InputBox("Customer ID", "Please enter your 9 digit Customer ID found on your My Area Card invoice. If you need assistance, please visit http://www.myareacard.com or contact your My Area Card Sales Representative.", "", " M9")
If @error = 1 Then Exit
$CustomerID = StringFormat("%09i", $CustomerID)
$CustomerPin = InputBox("Customer Pin", "Please enter your 3 digit Pin Number which is also on your invoice.", "", " M4")
If @error = 1 Then Exit
$CustomerPin = StringFormat("%04i", $CustomerPin)

ConsoleWrite($CustomerID & " - " & $CustomerPin & @CRLF)

Please ask if anything is unclear. ;)

M23

Edit:

Hi Varian.

I ran into the same problem with the capturing group notation and it baffled me completely for a while. That is why I added "key=" to the pattern.

I agree about SREs - they make my brain bleed, but they are useful! :idiot:

Edit: Clarity - I hope! :D

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Please ask if anything is unclear. :)

M23

Edit:

Hi Varian.

I ran into the same problem with the capturing group notation and it baffled me completely for a while. That is why I added "key=" to the pattern.

I agree about SREs - they make my brain bleed, but they are useful! ;)

Yeah, that's were my new nugget of knowledge came in! Looking at your way, I realized why I was so bothered by (the length) of my solution. I think I can do it in 3 lines to capture everything (thanks to your idea of capturing the customer id and customer pin).

$Chars = StringRegExpReplace($Chars, "(?m:^)(?i)(<url.+\.com)(</url>)", "$1poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$2") ;change "<url>http://www.myareacard.com</url>" 
$Chars = StringRegExpReplace($Chars, "(?m:^)(?i)(<url>)(.+\.html)(</url>)", "$1https://www.myareacard.com/merchant/poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$3")    ;change "<url>app://index.html</url>"
$sString = StringRegExpReplace($Chars, "(?m:^)(?i)(<url>[^=]+)(=\d+_\d+)(</url>)", "$1=" & $CustomerID & Chr(95) & $CustomerPin & "$3") ;change CustomerID and CustomerPin if exists
Edited by Varian
Link to comment
Share on other sites

First I want to thank you both for your efforts. It looks like I was able to successfully challenge you both. I am glad for that. I have looked at both of your scripts and I have decided to take pieces from both. I like the idea of having the entire xml file in my script so I don't need to rely on any data from the program installing the tiapp.xml initially. I am just going to add a line that has the proper format in it from the get go.

Varian I think here that you did not know that I needed the first <url>*</url> to stay in tact

$Chars = StringRegExpReplace($Chars, "(?m:^)(?i)(<url.+\.com)(</url>)", "$1poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$2") ;change "<url>http://www.MAC.com</url>" 
$Chars = StringRegExpReplace($Chars, "(?m:^)(?i)(<url>)(.+\.html)(</url>)", "$1https://www.myareacard.com/merchant/poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$3")    ;change "<url>app://index.html</url>"
$sString = StringRegExpReplace($Chars, "(?m:^)(?i)(<url>[^=]+)(=\d+_\d+)(</url>)", "$1=" & $CustomerID & Chr(95) & $CustomerPin & "$3") ;change CustomerID and CustomerPin if exists

and I am relatively new at this but I am reading the above to mean change both lines of <url>*</url>.

I cannot believe how much this compressed the final result. Here is what my final code looks like fully tested. Thanks again.

$chars = "<?xml version='1.0' encoding='UTF-8'?>" & @CRLF & _
        "<ti:app xmlns:ti='http://ti.appcelerator.org'>" & @CRLF & _
        "<!-- These values are edited/maintained by Titanium Developer -->" & @CRLF & _
        "<id>com.skyaim.merchantapp</id>" & @CRLF & _
        "<name>MAC Merchant</name>" & @CRLF & _
        "<version>2.2</version>" & @CRLF & _
        "<publisher>MAC</publisher>" & @CRLF & _
        "<url>http://www.myareacard.com</url>" & @CRLF & _
        "<icon>icon.png</icon>" & @CRLF & _
        "<copyright>2011 by LLC</copyright>" & @CRLF & _
        "<!-- Window Definition - these values can be edited -->" & @CRLF & _
        "<window>" & @CRLF & _
        "<id>initial</id>" & @CRLF & _
        "<title>MAC</title>" & @CRLF & _
        "<url>https://www.MAC.com/merchant/poslogin.php?key=000000000_0000</url>" & @CRLF & _
        "<width>620</width>" & @CRLF & _
        "<max-width>3000</max-width>" & @CRLF & _
        "<min-width>0</min-width>" & @CRLF & _
        "<height>500</height>" & @CRLF & _
        "<max-height>3000</max-height>" & @CRLF & _
        "<min-height>0</min-height>" & @CRLF & _
        "<fullscreen>false</fullscreen>" & @CRLF & _
        "<resizable>true</resizable>" & @CRLF & _
        "<chrome scrollbars='true'>true</chrome>" & @CRLF & _
        "<maximizable>true</maximizable>" & @CRLF & _
        "<minimizable>true</minimizable>" & @CRLF & _
        "<closeable>true</closeable>" & @CRLF & _
        "</window>" & @CRLF & _
        "</ti:app>"

$CustomerID = 000000000
$CustomerPin = 0000

While 1
    $CustomerID = InputBox("Customer ID", "Please enter your 9 digit Customer ID found on your MAC invoice. If you need assistance, please visit http://www.MAC.com or contact your My Area Card Sales Representative.", "", " M9")
        If @error = 1 Then Exit
    $CustomerID = StringFormat("%09i", $CustomerID)

    $CustomerPin = InputBox("Customer Pin", "Please enter your 3 digit Pin Number which is also on your invoice.", "", " M4")
        If @error = 1 Then Exit
    $CustomerPin = StringFormat("%04i", $CustomerPin)

    $sString = StringRegExpReplace($chars, "(.*)key=(.*)\d{9}_\d{4}(.*)(.*)", "$1" & "key="  & $CustomerID & "_" & $CustomerPin & "</url>" & "$2")
    $xmlfile = FileOpen(@ProgramFilesDir & "\MAC Merchant\tiapp.xml", 2) ;Opens the xml file and sets it to write mode
    FileWrite(@ProgramFilesDir & "\MAC Merchant\tiapp.xml", $sString) ;Replaces all data to = $sString
    FileClose($xmlfile)
    Exit
WEnd
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

Link to comment
Share on other sites

First I want to thank you both for your efforts. It looks like I was able to successfully challenge you both. I am glad for that. I have looked at both of your scripts and I have decided to take pieces from both. I like the idea of having the entire xml file in my script so I don't need to rely on any data from the program installing the tiapp.xml initially. I am just going to add a line that has the proper format in it from the get go.

Varian I think here that you did not know that I needed the first <url>*</url> to stay in tact

$Chars = StringRegExpReplace($Chars, "(?m:^)(?i)(<url.+\.com)(</url>)", "$1poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$2") ;change "<url>http://www.myareacard.com</url>" 
$Chars = StringRegExpReplace($Chars, "(?m:^)(?i)(<url>)(.+\.html)(</url>)", "$1https://www.myareacard.com/merchant/poslogin.php?key=" & $CustomerID & Chr(95) & $CustomerPin & "$3")    ;change "<url>app://index.html</url>"
$sString = StringRegExpReplace($Chars, "(?m:^)(?i)(<url>[^=]+)(=\d+_\d+)(</url>)", "$1=" & $CustomerID & Chr(95) & $CustomerPin & "$3") ;change CustomerID and CustomerPin if exists

and I am relatively new at this but I am reading the above to mean change both lines of <url>*</url>.

I cannot believe how much this compressed the final result. Here is what my final code looks like fully tested. Thanks again.

$chars = "<?xml version='1.0' encoding='UTF-8'?>" & @CRLF & _
        "<ti:app xmlns:ti='http://ti.appcelerator.org'>" & @CRLF & _
        "<!-- These values are edited/maintained by Titanium Developer -->" & @CRLF & _
        "<id>com.skyaim.merchantapp</id>" & @CRLF & _
        "<name>MyAreaCard Merchant</name>" & @CRLF & _
        "<version>2.2</version>" & @CRLF & _
        "<publisher>MyAreaCard</publisher>" & @CRLF & _
        "<url>http://www.myareacard.com</url>" & @CRLF & _
        "<icon>icon.png</icon>" & @CRLF & _
        "<copyright>2011 by SkyAim Media LLC</copyright>" & @CRLF & _
        "<!-- Window Definition - these values can be edited -->" & @CRLF & _
        "<window>" & @CRLF & _
        "<id>initial</id>" & @CRLF & _
        "<title>MyAreaCard Merchant</title>" & @CRLF & _
        "<url>https://www.myareacard.com/merchant/poslogin.php?key=000000000_0000</url>" & @CRLF & _
        "<width>620</width>" & @CRLF & _
        "<max-width>3000</max-width>" & @CRLF & _
        "<min-width>0</min-width>" & @CRLF & _
        "<height>500</height>" & @CRLF & _
        "<max-height>3000</max-height>" & @CRLF & _
        "<min-height>0</min-height>" & @CRLF & _
        "<fullscreen>false</fullscreen>" & @CRLF & _
        "<resizable>true</resizable>" & @CRLF & _
        "<chrome scrollbars='true'>true</chrome>" & @CRLF & _
        "<maximizable>true</maximizable>" & @CRLF & _
        "<minimizable>true</minimizable>" & @CRLF & _
        "<closeable>true</closeable>" & @CRLF & _
        "</window>" & @CRLF & _
        "</ti:app>"

$CustomerID = 000000000
$CustomerPin = 0000

While 1
    $CustomerID = InputBox("Customer ID", "Please enter your 9 digit Customer ID found on your My Area Card invoice. If you need assistance, please visit http://www.myareacard.com or contact your My Area Card Sales Representative.", "", " M9")
        If @error = 1 Then Exit
    $CustomerID = StringFormat("%09i", $CustomerID)

    $CustomerPin = InputBox("Customer Pin", "Please enter your 3 digit Pin Number which is also on your invoice.", "", " M4")
        If @error = 1 Then Exit
    $CustomerPin = StringFormat("%04i", $CustomerPin)

    $sString = StringRegExpReplace($chars, "(.*)key=(.*)\d{9}_\d{4}(.*)(.*)", "$1" & "key="  & $CustomerID & "_" & $CustomerPin & "</url>" & "$2")
    $xmlfile = FileOpen(@ProgramFilesDir & "\MyAreaCard Merchant\tiapp.xml", 2) ;Opens the xml file and sets it to write mode
    FileWrite(@ProgramFilesDir & "\MyAreaCard Merchant\tiapp.xml", $sString) ;Replaces all data to = $sString
    FileClose($xmlfile)
    Exit
WEnd

Yeah, I wasn't sure that you wanted to keep the first one. Glad to be of assistance...I learned something myself, per usual.
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...