dbzfanatic Posted July 28, 2007 Share Posted July 28, 2007 I feel like a complete idiot for not being able to figure this out but I've only been working in autoit for roughly a week. On a website I'm a member of there's a Points system and they call it gold. I want to get the amount of gold I have and it is displayed like "Gold: 2249" or whatever number you have. So far I have $oHtml = _IEBodyReadText($oIE) $oGold = StringRegExp($oHtml, '(Gold:\s\d)', 3) I have also tried many other variations of this but to no avail. I simply get a return value of 0 or 1 when what i want is the 2249 (from the example), in other words, the numerical value after "Gold: ". Please,any help would be GREATLY appreciated. I've been wracking my brains over this one... Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
GEOSoft Posted July 28, 2007 Share Posted July 28, 2007 I feel like a complete idiot for not being able to figure this out but I've only been working in autoit for roughly a week. On a website I'm a member of there's a Points system and they call it gold. I want to get the amount of gold I have and it is displayed like "Gold: 2249" or whatever number you have. So far I have $oHtml = _IEBodyReadText($oIE) $oGold = StringRegExp($oHtml, '(Gold:\s\d)', 3) I have also tried many other variations of this but to no avail. I simply get a return value of 0 or 1 when what i want is the 2249 (from the example), in other words, the numerical value after "Gold: ". Please,any help would be GREATLY appreciated. I've been wracking my brains over this one...Post a copy of an actual line that you are trying to read. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 28, 2007 Moderators Share Posted July 28, 2007 #include <array.au3>;only for _arraydisplay() this is not needed $sPattern = '(?s)(?i)Gold: (\d+)' $aArray = StringRegExp($sString, $sPattern, 3) _ArrayDisplay($aArray) 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 More sharing options...
dbzfanatic Posted July 28, 2007 Author Share Posted July 28, 2007 (edited) Swords and Sunflowers (Logout) Gold: 982 The amount changes depending on what the user does, such as posting in the forums. I am about to try the suggested code and I will edit this post to let you know if it works. Update: The code SmOke_N suggested will indeed gather the value but it will not store it to a variable as i need it to. _ArrayDisplay will show the 982 but when I simply change it to MsgBox with all the appropriate tags the box is empty. Is there a way to extract that line from the array and store just the numerical value? Edited July 28, 2007 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 28, 2007 Moderators Share Posted July 28, 2007 Swords and Sunflowers (Logout) Gold: 982 The amount changes depending on what the user does, such as posting in the forums. I am about to try the suggested code and I will edit this post to let you know if it works. Update: The code SmOke_N suggested will indeed gather the value but it will not store it to a variable as i need it to. _ArrayDisplay will show the 982 but when I simply change it to MsgBox with all the appropriate tags the box is empty. Is there a way to extract that line from the array and store just the numerical value?LOL... you need to know that is returning an array, I assumed since you were using StringRegExp() already, that you understood that. You are probably using... MsgBox(0, 'Title', $aArray) which it will indeed return a blank value. Try:MsgBox(0, 'Title', $aArray[0])[0] contains the "first" Gold: found... if there were more it would go to [1], [2] etc... 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 More sharing options...
dbzfanatic Posted July 28, 2007 Author Share Posted July 28, 2007 der *slaps forehead* thank you. I just woke up maybe 20 minutes ago so I'm still a lil loopy. That and arrays were never my strongpoint in ANY programming language:P. I knew it was returning an array I just couldn't think of how to tell it...so...yeah I'm an idiot,sorry. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
dbzfanatic Posted August 10, 2007 Author Share Posted August 10, 2007 Hello again. Hate to double post but since I already had a thread about this I thought I should just post my question here. The website has changed their layout and now instead of something like 4862 it's now displayed as 4,862. Using the code that was already provided works perfectly up to 1,000 but as soon as the comma is introduced StringRegExp only returns the first digit. I tried $sPattern = '(?s)(?i)Gold: (\d+).(\d+)' $aArray = StringRegExp($sString, $sPattern, 3) but to no avail. Please, I know I'm not great with this function that's why I'm turning to the people here who have more experience. Any help would be very much appreciated. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 10, 2007 Share Posted August 10, 2007 Hi, cannot test it biut : (?s)(?i)(?<=Gold: )\d+(,)*\d+ So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
dbzfanatic Posted August 10, 2007 Author Share Posted August 10, 2007 (edited) Hey, sorry to say but it doesn't work. I tried '(?s)(?i)(?<=)Gold: (\d+),(*\d+)' '(?s)(?i)(?<=Gold: )(\d+),(*\d+)' '(?s)(?i)(?<=)Gold: (\d+)(,)(*\d+)' '(?s)(?i)(?<=Gold: )\d+(,)*\d+' and none of them seem to work. Thank you for trying though. Edited August 10, 2007 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 10, 2007 Moderators Share Posted August 10, 2007 '(?s)(?i)Gold: (\d+,*\d*)' 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 More sharing options...
dbzfanatic Posted August 10, 2007 Author Share Posted August 10, 2007 (edited) Thank you very much. It now reads the number but won't store it as a numerical value for some reason,probably the comma. Would you happen to have suggestions on that? I'd figure it out myself but I probably won't have a net connection for much longer and I won't have time to test. Edit: it will store it as a numerical value,sorry for accidentally lying but if the number has a comma it won't store anything after it. I need to find a way to do that so I can accurately calculate the amount of gold someone has earned or has. I may have my connection for a bit longer but I'm not sure so a speedy response would be appreciated. Thank you for all your help so far and any you may give in the future. Post Edit: I found a way to do what I need to do and I'll post the code here for reference for anyone who may need help. $sString = _IEBodyReadText($oIE) $sPattern = '(?s)(?i)Gold: (\d+,*\d*)' $aArray = StringRegExp($sString, $sPattern, 3) if StringInStr($aArray[0],",") Then $aArray2 = StringSplit($aArray[0],",") $aArray[0]= $aArray2[1]*1000 + $aArray2[2] EndIf Edited August 11, 2007 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] 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