chachew Posted October 13, 2011 Share Posted October 13, 2011 (edited) I am pulling a version number from an embedded HTML window in an exe. Im trying to remove the last "." from the version number with StringTrimRight, but im having a problem. #Include <IE.au3> #Include <string.au3> $oIE=_IEAttach("App Setup","Embedded",1) ;attach to the application, the text is embedded HTML $var=_IEBodyReadHTML($oIE) $read=_StringBetween($var,"App ","<p>") MsgBox(0,"",$read[0]) $trim=StringTrimRight($read,1) MsgBox(0,"",$trim) First Msgbox returns: 9.50.4.0. i want to trim the LAST "." from the number Second Msgbox returns no text...what am i missing?? Edited October 13, 2011 by chachew Link to comment Share on other sites More sharing options...
BrewManNH Posted October 13, 2011 Share Posted October 13, 2011 $read is an array, you can't use a string function on an array, you need an array function such as _ArrayTrim, or use StringTrimRight($read[0], 1) instead. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 When i use StringTrimRight($read[0],1) i get the same result as MsgBox 1 If i use $trim=_ArrayTrim($read,1,1,0,0) then i get a result of "1" If i use $trim=_ArrayTrim($read[0],1,1,0,0) then i get a result of "0" Link to comment Share on other sites More sharing options...
Shaggi Posted October 13, 2011 Share Posted October 13, 2011 (edited) nvm Edited October 13, 2011 by Shaggi Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
pieeater Posted October 13, 2011 Share Posted October 13, 2011 use _ArrayToString() to turn it into a string then use that variable in the StringTrimRight() [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 (edited) use _ArrayToString() to turn it into a string then use that variable in the StringTrimRight() Thought this was going to work...but i get the same results for both variables $oIE=_IEAttach("App Setup","Embedded",1) ;attach to the application, the text is embedded HTML $var=_IEBodyReadHTML($oIE) $read=_StringBetween($var,"App ","<p>") $read2=_ArrayToString($read) MsgBox(0,"",$read[0]) $trim=StringTrimRight($read2,1) MsgBox(0,"",$trim) Edited October 13, 2011 by chachew Link to comment Share on other sites More sharing options...
pieeater Posted October 13, 2011 Share Posted October 13, 2011 (edited) it may have been because you didnt have #include <Array.au3> at the top maby i did this and it worked #include <Array.au3> Dim $read[3] = ["10.", "20.", "30."] $read2=_ArrayToString($read, "") MsgBox(0,"",$read2) $trim=StringTrimRight($read2,1) MsgBox(0,"",$trim) Edit: Problem Solved it was part of the syntax i forgot about Edited October 13, 2011 by pieeater [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
BrewManNH Posted October 13, 2011 Share Posted October 13, 2011 Are you 100% sure that the last character in that string is "."? If there's a space after it, you're deleting the space. Try using StringStripWS($Read[0], 2) just before you use the StringTrimRight line. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 it may have been because you didnt have #include <Array.au3> at the top maby i did this and it worked #include <Array.au3> Dim $read[3] = ["10.", "20.", "30."] $read2=_ArrayToString($read, "") MsgBox(0,"",$read2) $trim=StringTrimRight($read2,1) MsgBox(0,"",$trim) Edit: Problem Solved it was part of the syntax i forgot about Yes i have #include <Array.au3> Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 Are you 100% sure that the last character in that string is "."? If there's a space after it, you're deleting the space. Try using StringStripWS($Read[0], 2) just before you use the StringTrimRight line. Tried this and same result...damnit Link to comment Share on other sites More sharing options...
kylomas Posted October 13, 2011 Share Posted October 13, 2011 (edited) chachew, I would start by testing some return values after the function calls. _arraydisplay() is also handy for quickly displaying an array Kylomas Edited October 13, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
BrewManNH Posted October 13, 2011 Share Posted October 13, 2011 When i use StringTrimRight($read[0],1) i get the same result as MsgBox 1 If i use $trim=_ArrayTrim($read,1,1,0,0) then i get a result of "1" If i use $trim=_ArrayTrim($read[0],1,1,0,0) then i get a result of "0" What did you get in the array $read when you ran the first command? $trim is only going to be 1 or 0, the array is passed ByRef to the _ArrayTrim function. Try using a msgbox after the _ArrayTrim function to see what's in $read[0], something like this: #include <Array.au3> $read=_StringBetween($var,"App ","<p>") MsgBox(0,"",$read[0]) _ArrayTrim($read, 1,1) Msgbox(64, "", "|" & $read[0] & "|") ; I added the 2 "|" to make sure that the last and first characters are where you think they are If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 What did you get in the array $read when you ran the first command? $trim is only going to be 1 or 0, the array is passed ByRef to the _ArrayTrim function. Try using a msgbox after the _ArrayTrim function to see what's in $read[0], something like this: #include <Array.au3> $read=_StringBetween($var,"App ","<p>") MsgBox(0,"",$read[0]) _ArrayTrim($read, 1,1) Msgbox(64, "", "|" & $read[0] & "|") ; I added the 2 "|" to make sure that the last and first characters are where you think they are With this suggestion i get the image below.. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 13, 2011 Share Posted October 13, 2011 With this suggestion i get the image below.. That tells me that there's something after the number that's not displaying in the msgbox,probably a CR or LF or 2. Try putting a StringStripWS($Read[0], 8) in there just before the first MsgBox, and see if it returns the same. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 (edited) That tells me that there's something after the number that's not displaying in the msgbox,probably a CR or LF or 2. Try putting a StringStripWS($Read[0], 8) in there just before the first MsgBox, and see if it returns the same. Arrrgggg...still happens $read=_StringBetween($var,"App ","<p>") StringStripWS($Read[0], 8) MsgBox(0,"",$read[0]) _ArrayTrim($read, 1,1) Msgbox(64, "", "|" & $read[0] & "|") Edited October 13, 2011 by chachew Link to comment Share on other sites More sharing options...
kylomas Posted October 13, 2011 Share Posted October 13, 2011 chachew, At some point we are going to need to see this HTML source!!! Kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
BrewManNH Posted October 13, 2011 Share Posted October 13, 2011 Arrrgggg...still happens $read=_StringBetween($var,"App ","<p>") StringStripWS($Read[0], 8) MsgBox(0,"",$read[0]) _ArrayTrim($read, 1,1) Msgbox(64, "", "|" & $read[0] & "|") You need to start reading the help file a lot better, you have to assign the return of StringStripWS to a variable, try it using $read[0] = StringStripWS($Read[0], 8) ; you could substitute the 8 with 2 to just strip trailing WS instead of all of it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 chachew, At some point we are going to need to see this HTML source!!! Kylomas The html is embedded in the exe so here is the actuall HTML itself: <html> <font face="Arial, Helvetica, Geneva">Welcome to the installer for App 9.50.4.0. <p> <b><font color='red'>Please disconnect any scanners and connect any printers or cameras to your system before continuing.</font></b> <p> <font size=-2"> It is strongly recommended that you exit all Windows programs before continuing with this installation. <p> This installation will shut down any internet explorer windows that may be running before installation <p> If you have any other programs running, please click Cancel, close the programs, and run this setup again. <p> Otherwise, click Next to continue.</font></font> <//html> Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 You need to start reading the help file a lot better, you have to assign the return of StringStripWS to a variable, try it using $read[0] = StringStripWS($Read[0], 8) ; you could substitute the 8 with 2 to just strip trailing WS instead of all of it. Sweet, that works, now..i do see now where StringStripWS assigns to a variable This is now the working code! #Include <IE.au3> #Include <string.au3> #Include <array.au3> $oIE=_IEAttach("App Setup","Embedded",1) ;attach to the application, the text is embedded HTML $var=_IEBodyReadHTML($oIE) $read=_StringBetween($var,"App ","<p>") $read[0]=StringStripWS($read[0], 8) MsgBox(0,"",$read[0]) _ArrayTrim($read, 1,1) Msgbox(0, "",$read[0]) Link to comment Share on other sites More sharing options...
chachew Posted October 13, 2011 Author Share Posted October 13, 2011 Thanks for all the help Guys 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