LetsAuto Posted November 6, 2012 Posted November 6, 2012 Hi everyone! (again).. I am trying to cross-reference user input with a .txt file.. or at least thats what the plan is.. before i get way too heavily involved.. is it possible to have the user input a date (November 6 2012) and then search a .txt file that has "November 6 2012 : xxxxx:xxxxx:xxxxx" and pull out the xxxxx:xxxxx:xxxxx, and use that as a string? OR, should i transfer that data into a global array? THANKS@
DicatoroftheUSA Posted November 6, 2012 Posted November 6, 2012 Yes both methods of what you ask for is possible read the help file about "FileReadLine" However depending on the search frequency and the size of the file, you may be better off just using file read, then splitting the string into a 2darray so that a binary search can be performed. If the file is huge, then I would suggest looking into sqlite. Statism is violence, Taxation is theft. Autoit Wiki
guinness Posted November 6, 2012 Posted November 6, 2012 You could also look at using FileRead and StringRegExp. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
LetsAuto Posted November 7, 2012 Author Posted November 7, 2012 okay, so say if i want to display the xxxxx:xxxxx:xxxxx from the November 6 2012 ... line, should I use FileRead and then use StringRegExp A to match the date with the Novmeber 6 2012, then display lineX(x being the line with the correct information)... but how do i tell FileRead to only print out 1 line?
DicatoroftheUSA Posted November 7, 2012 Posted November 7, 2012 (edited) Fileread and filereadline are different. The help file gives examples of use. Yes stringregex can be used, by default it searches each line as a segment. Hit the help file and make a rough draft, and we can give more specific advice. Edited November 7, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki
DicatoroftheUSA Posted November 7, 2012 Posted November 7, 2012 Here is an example script #include $sFile='November 6 2012 : xxxxx:xxxxx:xxxxx'&@crlf&'November 7 2012 : xxxxx:xxxxx:xxxxx' $sMonth='November' $iDay=6 $iYear=2012 $sSearchDay='('&$sMonth&" "&$iDay&" "&$iYear&'.*)' $aResult=StringRegExp($sFile,$sSearchDay,3) _ArrayDisplay($aResult) MsgBox(0,"test",$aResult[0]) Statism is violence, Taxation is theft. Autoit Wiki
LetsAuto Posted November 7, 2012 Author Posted November 7, 2012 ;;;; Global $gArrayOne [0][0] = "Jul" Global $gArrayOne [0][1] = "xxxxxxxxxxxxxxxxxxxxxxx=" Global $gArrayOne [1][0] = "Aug" Global $gArrayOne [1][1] = "xxxxxxxxxxxxxxxxxxxxxxx=" Global $gArrayOne [2][0] = "Sep" Global $gArrayOne [2][1] = "xxxxxxxxxxxxxxxxxxxxxxx=" ;;;; Global $gArrayTwo [0][0] = "1 Server" Global $gArrayTwo [0][1] = "ffffffffffffffffffffffff=" Global $gArrayTwo [1][0] = "5 Servers" Global $gArrayTwo [1][1] = "ffffffffffffffffffffffff=" Global $gArrayTwo [2][0] = "10 Servers" Global $gArrayTwo [2][1] = "ffffffffffffffffffffffff=" Global $gArrayTwo [3][0] = "20 Servers" Global $gArrayTwo [3][1] = "ffffffffffffffffffffffff=" ;;;; $example = InputBox("one", "Please enter month(Jan, Feb, Mar...): ") if $example == $gArrayOne[0][0] Then MsgBox("","july code", $gArrayOne[0][1]) endif so this isnt using StringRegExp.. but do you think that even doing this would work? something simple, if the user input = = gArray[0][0] then display gArray[0][1].. but its saying something is wrong at the end of Global $gArrayOne... line.
LetsAuto Posted November 7, 2012 Author Posted November 7, 2012 mainly becausae i need to be able to search the user input, and i need to display only the code, the xxxxxxxxxxxxxxxx or the ffffffffffffffffff part. and on my GUI, depending on which button the user presses it will either search the x's for the f's which is easy enough to do.
BrewManNH Posted November 7, 2012 Posted November 7, 2012 You're redeclaring the array with every line, destroying it's contents in the process, not adding information into it. Declare the array once with Global, then add the information into the elements. Also, unless you're only expecting the information from the inputbox to be typed exactly the same as the information in the array, don't use "==", that is used for a case sensitive string comparison, and not a normal comparison. 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
DicatoroftheUSA Posted November 7, 2012 Posted November 7, 2012 (edited) You only define a variable global variable once, and in defining it, give it its scale and dimensions. ie Global $gArrayOne [$maxrows][$maxcolums] $gArrayOne [0][0] = "Jul" $gArrayOne [0][1] = "xxxxxxxxxxxxxxxxxxxxxxx=" $gArrayOne [1][0] = "Aug" ... See the help file under autoit -> language reference -> datatypes/variables Edited November 7, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki
LetsAuto Posted November 7, 2012 Author Posted November 7, 2012 Awesome, thanks guys! i got the global arrays to work, I think for simplicity's sake, im going to use the arrays, granted its a lot of lines, it works and i know how to use them now
DicatoroftheUSA Posted November 7, 2012 Posted November 7, 2012 Awesome, thanks guys! i got the global arrays to work, I think for simplicity's sake, im going to use the arrays, granted its a lot of lines, it works and i know how to use them nowFrom the look of your arrays, you might also look into the INI functions. It may be easier to manager. Statism is violence, Taxation is theft. Autoit Wiki
LetsAuto Posted November 7, 2012 Author Posted November 7, 2012 okay thanks.. also this is completely off topic... how do i save the user's choice for a radio button for later reference, and the later reference is a different file completely, (i told autoIt to run another autoit script) but i need that radio button information in order for most of this to work properly
DicatoroftheUSA Posted November 7, 2012 Posted November 7, 2012 If it's off topic another thread should be started so that people who have the same questions as you won't get confused. But to be honest, I don't get what you are asking for. Statism is violence, Taxation is theft. Autoit Wiki
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