jchd Posted February 6, 2014 Share Posted February 6, 2014 Layer numbers are off, line numbers are off. There are way too many conflicting scopes for variables. If I were you, I'd split the gcode into various parts: 0) header 1 to N) each individual layer N+1) footer Turn these parts into as many array of lines, which you can now easily manage at will. Writing back the final modified file is as easy as as many ArrayToString and FileWrites. This way you don't have any more to worry about line numbers. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
tonycst Posted February 6, 2014 Author Share Posted February 6, 2014 Easy for you to say. With my level of knowledge i dont even understand what you mean by all this. Arrays are not something i am familiar with, that why i came here for help. But i will try to do some clean up and see what i can do. I will make things go into more functions rather then in the loop, that should help me navigate thru easier and identify errors. Will post when done. Thanks Link to comment Share on other sites More sharing options...
kylomas Posted February 7, 2014 Share Posted February 7, 2014 Hi tonycst, As jchd said, your line numbers appear to be wrong. layer 0 is at line 27. You seem to be misunderstanding the use of the "assign" function and are using it to increment a variable. This may be working but is difficult to read (therefore maintain). EX; $Found = $Found + 1 or $Found += 1 will increment $Found by 1. Currently you are using "Assign ("Found",$Found+1)". Same with "Assign ("CurrentLine",$CurrentLine+1)". To correct the line sync problem try this: - change "Assign ("Found",1)" to "Assign ("Found",0)" - change "$NewItem = GUICtrlCreateListViewItem("RAFT Layer" & $i & "|" & $aLineNumber[$i], $ListView)" to "$NewItem = GUICtrlCreateListViewItem("RAFT Layer" & $i+1 & "|" & $aLineNumber[$i], $ListView)" - change "$Item = GUICtrlCreateListViewItem("Layer " & $Found & "|" & $aLineNumber[$i], $ListView)" to "$Item = GUICtrlCreateListViewItem("Layer " & $Found & "|" & $aLineNumber[$i]+1, $ListView)" There may be other places were you are not synchronized. As far as arrays go you are already using them, eg, filereadtoarray and arrayfindall. Good Luck, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted February 7, 2014 Share Posted February 7, 2014 Are layers numbers always starting at 0 and consecutive? As kylomas said, you don't need Assign. Already removed. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kylomas Posted February 7, 2014 Share Posted February 7, 2014 (edited) Are layers numbers always starting at 0 and consecutive? Good point, did not check that. Better to get the layer number from the hit, not the line number. edit: in the sample data they are consecutive starting at 0...still better to get them from the matched data... Edited February 7, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
tonycst Posted February 7, 2014 Author Share Posted February 7, 2014 layers always start from 0. Cant change Assign ("Found",1) to Assign ("Found",0) It will lead to 1st layer be 0 which its not. I did try to do it with 1 and adding +1 to [$i] but it still makes layer 0 displayed as 0 and i need it to be 1 Here is what you maybe confusing your self with. CURA (3d slicing/printing program) generates this code. It generates 1st layer as Layer 0, but in the viewport its shown as Layer 1. Thats why i have Found 1 instead of Found 0. I need that extra 1 to match layer numbers with CURA. Layer numbering is not what i worry about. I worry about speed it takes to identify comments made by my program when INI reads SearchAtOpen=Yes. Everything else is fine so far. Link to comment Share on other sites More sharing options...
kylomas Posted February 7, 2014 Share Posted February 7, 2014 layer #1 is NOT at line 26 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
tonycst Posted February 7, 2014 Author Share Posted February 7, 2014 No, its not. Layer 0 is at line 26. CURA displays layer 0 as layer 1, that the problem. Well not a problem, but something to keep in mind. Link to comment Share on other sites More sharing options...
tonycst Posted February 10, 2014 Author Share Posted February 10, 2014 (edited) Ok this is all i could do with the script. Source.zip Use attached TEST.gcode file to open because there are changes since previous one. To disable my slow search feature, click Options and uncheck Autosearch (Slow) There are no problems in the script from what i understand. It works as i expect it to work and needs no change other then getting Autosearch work faster. Here is the autosearch code isolated If IniRead($INI, "Settings", "SearchAtOpen", "") = "Yes" Then $localIndex = _GUICtrlListView_MapIDToIndex($ListView, $Item) For $s = 1 To 14 ;read 10 lines ahead because i only have 10 parameters that would create 10 lines max $c2MSG = GUIGetMsg() If $c2MSG = $CANCEL Then ExitLoop 2 $SearchLine = FileReadLine($Source, $aLineNumber[$i] + $s) If $SearchLine = ";G-Code Modifier DATA Start" Then _GUICtrlListView_SetItemText($ListView, $Found - 1, $aLineNumber[$i] + $s, 2) ;Item index is -1 from found count. GUICtrlSetImage($localIndex, $Warning) EndIf If $SearchLine = ";G-Code Modifier DATA End" Then _GUICtrlListView_SetItemText($ListView, $Found - 1, $aLineNumber[$i] + $s, 3) ;Item index is -1 from found count. GUICtrlSetImage($localIndex, $Warning) EndIf Next EndIf Edited February 10, 2014 by tonycst 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