|
Post by dagnabitboy on Sept 5, 2019 17:40:07 GMT -5
I'm writing a gcode post processor and some files I work with have a CR as a line terminator, others have only a LF. The line input function (line input #handle, filename$) apparently only uses CR to detect a line end. I've tried using the INPUTTO$(#h, c$) function by specifying the LF as a terminator, and it works, but it's incredibly slow. Does anyone know of a work around or a speedier method? Thanks!! Almost forgot: using LB 4.5.1. And although the forum says I'm a new member, I've been using LB for at least 15 years now, so, not a noob!
|
|
|
Post by metro on Sept 5, 2019 19:31:42 GMT -5
Plenty of people smarter than me on here will have better options, I use this to detect linux line endings because I use lb4.5.1 on linux HTH CR$= chr$(13): LF$=chr$(10): EOL$= CR$+LF$ ' make them global SUB FixLineEnd fileName$
open fileName$ for input as #1 entire$ = input$(#1, lof(#1)) close #1 fnd= INSTR(entire$,EOL$) if fnd= 0 then print "Linux Line endings" entire$=SwapLineEnd$(entire$) end if open fileName$ for output as #1 #1 entire$ close #1 END SUB
FUNCTION SwapLineEnd$( i$) r$ ="" FOR j =1 TO len( i$) ch$ =mid$( i$, j, 1) IF asc(ch$) = 10 THEN ch$= EOL$ r$ =r$+ch$ NEXT j SwapLineEnd$ =r$ END FUNCTION
Opps hit the wrong button and liked my own post
|
|
|
Post by Carl Gundel on Sept 5, 2019 20:30:33 GMT -5
I'm writing a gcode post processor and some files I work with have a CR as a line terminator, others have only a LF. The line input function (line input #handle, filename$) apparently only uses CR to detect a line end. I've tried using the INPUTTO$(#h, c$) function by specifying the LF as a terminator, and it works, but it's incredibly slow. Does anyone know of a work around or a speedier method? Thanks!! Almost forgot: using LB 4.5.1. And although the forum says I'm a new member, I've been using LB for at least 15 years now, so, not a noob! Hi, Cool on the GCode stuff. I used to write a lot of stuff like that in BASIC back in the 90's. I even wrote a special program in Liberty BASIC for generating GCode drilling patterns for polycarbonate circuitboard electrical test fixtures. I'm not sure why INPUTTO$() should be slow. Can you share some code?
|
|
|
Post by dagnabitboy on Sept 5, 2019 21:25:54 GMT -5
Hi Carl, In the process of cleaning up code to post here I realized why it was so slow. As each line was being input I was also outputting it (for debugging purposes) to the default text window that opens when you run code with 'nomainwin' commented out. With the output gone I now input a 6000 line gcode file in just 180 milliseconds! So, sorry for the unnecessary question, but the process of posting here and you asking for a look at the code solved it!!
Yeah, last year I got into 3d printing, but that lead me into CNC routers and I built my own, so now I'm doing the gcode thing!! Lots of fun!
Thank you!
|
|
|
Post by Carl Gundel on Sept 5, 2019 22:42:59 GMT -5
Hi Carl, In the process of cleaning up code to post here I realized why it was so slow. As each line was being input I was also outputting it (for debugging purposes) to the default text window that opens when you run code with 'nomainwin' commented out. With the output gone I now input a 6000 line gcode file in just 180 milliseconds! So, sorry for the unnecessary question, but the process of posting here and you asking for a look at the code solved it!! Yeah, last year I got into 3d printing, but that lead me into CNC routers and I built my own, so now I'm doing the gcode thing!! Lots of fun! Thank you! You're welcome. When I worked in the circuitboard factory there was an abandoned CNC drilling/routing machine at one end of the building. I learned later on that this was designed and built by the owner of the company (the late Robert Spain). A one-off machine that allowed the company to grow on a shoestring. I was so impressed. Later when the company grew they were able to buy a half dozen of the Excellon machines.
|
|