Stacker Posted November 16, 2015 Share Posted November 16, 2015 Hi all,i'm newi have cad file like this:......# *** COMPONENTS ***C00 CAP233 'CodeC01 1206 'SizeC02 1uF 10% 50V SMD 1206 X7R 'Description#C00 CAP32C01 0805C02 330nF 20% 50V SMD 0805 Y5VSo i need to search for "# *** COMPONENTS ***" then read C00/C01/C02 and put in array like a[0][0] = C00, a[0][1]=C01 a[0][2] = C02.Read file not to EOF but when string # *** REFERENCEPOINTS *** occurnext step is to organize data and write new file ( but is next step) Thx all for suggestions Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2015 Developers Share Posted November 16, 2015 Welcome: That shouldn't be too hard. Anything you already tried that you have question about?Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Stacker Posted November 16, 2015 Author Share Posted November 16, 2015 For moment only thisCan you explain me how ? Link to comment Share on other sites More sharing options...
water Posted November 16, 2015 Share Posted November 16, 2015 What to do depends on the filesize.For smaller files I suggest you have a look at FileReadToArray. Then loop through the resulting array. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2015 Developers Share Posted November 16, 2015 Here is a very basic script to get you going:#include <array.au3> $fh = FileOpen("test.txt") $FndData = False $Cnt = 0 Global $Data[100][3] While 1 $rec = FileReadLine($fh) If @error Then ExitLoop ; EOF encountered If StringInStr($rec, "# *** COMPONENTS ***") Then $FndData = True EndIf ; only process when start string encountered If $FndData Then If StringLeft($rec, 3) = "C00" Then $Cnt += 1 $Data[$Cnt][0] = StringMid($rec, 4) ElseIf StringLeft($rec, 3) = "C01" Then $Data[$Cnt][1] = StringMid($rec, 4) ElseIf StringLeft($rec, 3) = "C02" Then $Data[$Cnt][2] = StringMid($rec, 4) EndIf EndIf WEnd _ArrayDisplay($Data) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Stacker Posted November 16, 2015 Author Share Posted November 16, 2015 Thank you jos.now i'm at work. When i have one moment i try your code Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2015 Developers Share Posted November 16, 2015 Saw I missed the test for the end marker:#include <array.au3> $fh = FileOpen("test.txt") $FndData = False $Cnt = 0 Global $Data[100][3] While 1 $rec = FileReadLine($fh) If @error Then ExitLoop ; EOF encountered ; Start processing when End marker encountered If StringInStr($rec, "# *** COMPONENTS ***") Then $FndData = True EndIf ; Stop processing when End marker encountered If StringInStr($rec, "# *** REFERENCEPOINTS **") Then ExitLoop EndIf ; Only process when start string encountered If $FndData Then If StringLeft($rec, 3) = "C00" Then $Cnt += 1 $Data[$Cnt][0] = StringMid($rec, 4) ElseIf StringLeft($rec, 3) = "C01" Then $Data[$Cnt][1] = StringMid($rec, 4) ElseIf StringLeft($rec, 3) = "C02" Then $Data[$Cnt][2] = StringMid($rec, 4) EndIf EndIf WEnd _ArrayDisplay($Data)Enjoy,Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Stacker Posted November 16, 2015 Author Share Posted November 16, 2015 I try your code, work great but i have to ask 2 things.the first is: you set array $data to [100][3] but if i don't know the dimension of row " [100] "another things is possible to have prompt to select the filethxs so much Link to comment Share on other sites More sharing options...
Stacker Posted November 16, 2015 Author Share Posted November 16, 2015 File open dialog SOLVED Link to comment Share on other sites More sharing options...
Stacker Posted November 16, 2015 Author Share Posted November 16, 2015 Solvedi Redim array by $cnt at the end...... 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