ptrex Posted June 16, 2006 Share Posted June 16, 2006 This example shows an other application using ADOR.Recordset. Sorting a text file using this approach : Save this as a TXT file e V B A d c And sort the content using the following script. expandcollapse popupConst $adVarChar = 200 Const $MaxCharacters = 255 Const $ForReading = 1 Const $ForWriting = 2 Const $Col = "Name" $DataList = ObjCreate("ADOR.Recordset") $DataList.Fields.Append ($Col, $adVarChar, $MaxCharacters) $DataList.Open() $objFSO = ObjCreate("Scripting.FileSystemObject") $objFile = $objFSO.OpenTextFile("C:\Test.txt", $ForReading) Do $strLine = $objFile.ReadLine $DataList.AddNew() $DataList.Fields($Col).Value = $strLine Msgbox(0,"Debug",$strLine) $DataList.Update() Until $objFile.AtEndOfStream() $objFile.Close() $DataList.Sort = $Col If Not $DataList.Bof Then $DataList.MoveFirst() EndIf Do Local $strText $strText &= $DataList.Fields($Col).Value & @CRLF Msgbox(0,"Debug",$strText) $DataList.MoveNext() Until $DataList.EOF() $objFile = $objFSO.OpenTextFile("C:\Test.txt", $ForWriting) $objFile.WriteLine ($strText) $objFile.Close() Enjoy. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
erifash Posted June 16, 2006 Share Posted June 16, 2006 Nice, but couldn't you just read the file with FileRead() then StringSplit() it and put it into the recordset? That way you wouldn't have to have one character per line. My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
randallc Posted June 17, 2006 Share Posted June 17, 2006 Hi @ptrex, Thanks again for that new approach! Can you describe the likely usefulness in terms of A. speed and B. practicality? eg vs. 1. Autoit File read to array/ Arraysort/ FileWriteFromArray. 2. dos file sort. 3. vbs file sort? Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
randallc Posted June 17, 2006 Share Posted June 17, 2006 btw,I get this error when reading back from the database to make the text file;Does it need error checking for a large file, or too big a string, or too big a data entry, or similar? ?write line by line?randall>Running:(3.1.1.124):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Programs\SearchEngine\SortPtrexAdor.au3" C:\Programs\SearchEngine\SortPtrexAdor.au3 (46) : ==> The requested action with this object has failed.: $DataList.Fields($Col).Value = $strLine $DataList.Fields($Col).Value = $strLine^ ERROR!>AutoIT3.exe ended.rc:2147483647 ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
ptrex Posted June 17, 2006 Author Share Posted June 17, 2006 @erifash Nice, but couldn't you just read the file with FileRead() then StringSplit() it and put it into the recordset? Yes I could but this is just a quick VBS converted script as you can see. The purpose of this example is only to show the possibilities of what ADOR.RecordSet can do. I am very much into ADOR and ADODB these days :"> @Randallc Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
randallc Posted June 17, 2006 Share Posted June 17, 2006 (edited) Hi, The error was in your script when I read a file; fixed it with "Const $MaxCharacters = 511" as the file had lines >255. But it is 20x slower than a DOS sort [7Mb test file; not much difference if<300Kb]; I suppose it may have interest as a method, but I can't see an application when it is so slow?... Best, Randall Edited June 17, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW 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