Jump to content

StringInStr - can this script be faster? (texts files included)


Recommended Posts

Hi guys, sorry for no feedback yet, but i am sick... 39 fever and i almost see pink dancing elephants in my room :/ 

I see there are many answers... i will look better for them (and i will reply) next days when i will be fine. Thx to everybody, much appreciated and greetings from italy! :)

Link to comment
Share on other sites

Yes. But I believe that the OP wants the complete concerned lines in standard.txt to be returned, because if they want only the (Director, Year) part then using Scripting.Dictionary on the 2 arrays1D would be a better way

yes :)

I admit that I'm trying your code but it does not show any result... i guess it must be a problem on my side but I can't understand where. I am using SciTE-Lite  Version 3.5.4 and I have both sqlite.au3 and array.au3

Building arrays = 0.0068 seconds
SQLite global work = 0.0761 seconds
Formatting = 0.0000 seconds
Total time = 0.0831 seconds
+>19:10:28 AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 1.798

 

it's what i get, but i suppose that i should get the results in the final arraydisplay, which does not appear at all...  

Now i try to understand what is wrong in my configuration but being sick is little more complicated than usual :D

 

Edited by Italiano
Link to comment
Share on other sites

Download SQLite:

http://www.sqlite.org/2016/sqlite-dll-win32-x86-3100000.zip
http://www.sqlite.org/2016/sqlite-dll-win64-x64-3100000.zip

Unzip, copy and rename!
Change code, run and check:
 

If @AutoItX64 Then
    _SQLite_Startup(@ScriptDir & "\SQLite3_x64.dll")
Else
    _SQLite_Startup(@ScriptDir & "\SQLite3.dll")
EndIf
If @error Then
    MsgBox(0, "SQLite Error", "SQLite3.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

 

Edited by Trong

Regards,
 

Link to comment
Share on other sites

Only the one shipped with AutoIt, is guaranteed to be supported by the AutoIt team.

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

That's the beauty of SQLite, backwards compatibility. As long as you're using the same or higher version, the commands should be the same, and the database files should always be readable backwards.

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 Gude
How 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

Italiano,
Once you are sure that you have SQLite.dll, please check the path of both txt files. In my code there is no path because I placed them in the script folder  ;)

Amazing! this is FAST!:blink: if i think that i was doing that horrible script, i feel really dumb :D Now i am studying that logic, but i trust and i almost sure the results are what i needed )))

Seriously, i had no idea this could be done so quickly!

If i should compile the script, I suppose i should embed just the dll file, right? :)

Thank you Mykell and thanks to everybody gave their time to help. I hope someday i will be good enough to help too ;)

Link to comment
Share on other sites

 

#include <Array.au3>

$t0 = TimerInit()
Local $aStandard = StringRegExp(FileRead(@ScriptDir & '\standard.txt'), "(?m)^(.*)\(([^\)]+).*$", 3)
;_ArrayDisplay($aStandard)
Local $aStandard2D[UBound($aStandard)/2][2]
For $i = 0 to UBound($aStandard)-1 step 2
   $aStandard2D[$i/2][0] = $aStandard[$i]
   $aStandard2D[$i/2][1] = $aStandard[$i+1]
Next
;_ArrayDisplay($aStandard2D)

 

Ehm, sorry to bump this :)  I played with your great code, but i need again help cause i am not sure to understand the stringregexp :( I updated the code according to my needs and something little changed about what is inside textfile "standard.txt"

before it looked like this:

-2: Livello Del Terrore (Khalfoun, 2007)
... Altrimenti Ci Arrabbiamo! (Fondato, 1974)

and the regex above was great... now it little changed to this:

-2: Livello Del Terrore (Khalfoun, 2007)|3571968
... Altrimenti Ci Arrabbiamo! (Fondato, 1974)|195145

So basically, after the year, i have a code which i need too :/ i would like to have in the array also a third value, after title and the "director, year"... just i am not sure how to get it... any help, pls?

If i'm understanding quite fine autoit commands, i admit that regexp is like chinese to me...

Sorry for my bad english :)

Link to comment
Share on other sites

OK  :D
So if you have a standard.txt file like this

-2: Livello Del Terrore (Khalfoun, 2007)|3571968
something! (Author, 1965) ; lets say there is no code here
... Altrimenti Ci Arrabbiamo! (Fondato, 1974)|195145

Then you can use a slightly modified regex and array formatting :

#include <Array.au3>

Local $aStandard = StringRegExp(FileRead(@ScriptDir & '\standard.txt'), "(?m)^(.*)\((.+)\)\|?(\d*).*$", 3)
;_ArrayDisplay($aStandard)
Local $aStandard2D[UBound($aStandard)/3][3]
For $i = 0 to UBound($aStandard)-1 step 3
   $aStandard2D[$i/3][0] = $aStandard[$i]
   $aStandard2D[$i/3][1] = $aStandard[$i+1]
   $aStandard2D[$i/3][2] = $aStandard[$i+2]
Next
_ArrayDisplay($aStandard2D)

Edit
Apparently you are healed and healthy now  :)

Edited by mikell
Link to comment
Share on other sites

Thx Mikell, as usual :)  I hope someday I will manage to understand regex better than now... at the moment it's very foggy in my mind... i understood just now that I must put every "group" inside ()

Hopefully i will not need again to bump this thread ;)

Yes, I am healthy now, but my english still sucks :D 

 

 

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

×
×
  • Create New...