computergroove Posted January 6, 2011 Share Posted January 6, 2011 I have a string in an xml file: <url>/merchant/poslogin.php?key=20000209_432</url> The 20000209 and 432 are like user names and passwords. I want my script to read this data from the xml when it starts and if it is the original generic string then I want the program to prompt the user to add a new user name and password. If it isn't the generic user name and password then I want the program to ignore it. Basically the user will only need to enter their user name and password once and from that point on, there will be no more need for this part of the program. I can change the string to say anything by default if that helps auto it identify that part of the script. 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 More sharing options...
Moderators Melba23 Posted January 6, 2011 Moderators Share Posted January 6, 2011 computergroove,Read the file with FileRead and see if the string "merchant/poslogin.php?key=20000209_432" (or the essential part of it) exists - StringInStr will do that for you.If the string does not exist then carry on. If it does exist, then use 2 InputBoxes to get the new values, insert them in the file text using StringReplace and finally rewrite the file with FileWrite.That should be enough to get you started. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
computergroove Posted January 7, 2011 Author Share Posted January 7, 2011 OK I'm stuck. Here's what I have so far: $xmlfile = FileOpen("tiapp.xml", 0) ; Check if file opened for reading OK If $xmlfile = -1 Then MsgBox(0, "Error", "Unable to open file") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($xmlfile) ;reads the xml file and adds it to $chars $result = StringInStr($chars, "20000209_432") MsgBox(0, "Search result:", $result) FileClose($xmlfile) Wend The above creates a msgbox that returns a value of 553. I was expecting it to return 20000209_432. What am I doing wrong? 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 More sharing options...
jvanegmond Posted January 7, 2011 Share Posted January 7, 2011 (edited) OK I'm stuck. Here's what I have so far: $xmlfile = FileOpen("tiapp.xml", 0) ; Check if file opened for reading OK If $xmlfile = -1 Then MsgBox(0, "Error", "Unable to open file") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($xmlfile) ;reads the xml file and adds it to $chars $result = StringInStr($chars, "20000209_432") MsgBox(0, "Search result:", $result) FileClose($xmlfile) Wend The above creates a msgbox that returns a value of 553. I was expecting it to return 20000209_432. What am I doing wrong? 553 means that StringInStr counted 553 characters from the beginning of the string to the point where 20000209_432 was found. You can use this value to remove unwanted characters from the beginning of the string with the function StringTrimLeft (trimming the left side of the string). Edited January 7, 2011 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now