Stacker Posted November 16, 2015 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
Developers Jos Posted November 16, 2015 Developers 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.
Stacker Posted November 16, 2015 Author Posted November 16, 2015 For moment only thisCan you explain me how ?
water Posted November 16, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Developers Jos Posted November 16, 2015 Developers 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.
Stacker Posted November 16, 2015 Author Posted November 16, 2015 Thank you jos.now i'm at work. When i have one moment i try your code
Developers Jos Posted November 16, 2015 Developers 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.
Stacker Posted November 16, 2015 Author 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
Stacker Posted November 16, 2015 Author Posted November 16, 2015 Solvedi Redim array by $cnt at the end......
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