Hello Guest it is March 28, 2024, 07:15:19 AM

Author Topic: Total lines in the G Code for each file ??  (Read 5378 times)

0 Members and 1 Guest are viewing this topic.

Total lines in the G Code for each file ??
« on: February 29, 2012, 11:43:56 AM »
Hello

I would like to know if there is a Gcode or macro to give me the total numbers of the lines for each file I open in mach3 ??
In other words, I want a dro or input to show me the total lines for the file in the mach3 page.

Regards,
U.H

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Total lines in the G Code for each file ??
« Reply #1 on: February 29, 2012, 12:03:14 PM »
Hi UH,

If you double click on the program window it will append line numbers to the GCode lines and you can just scroll to the bottom line to read the total.

Tweakie.
PEACE
Re: Total lines in the G Code for each file ??
« Reply #2 on: February 29, 2012, 12:42:26 PM »
Thank you Tweakie ,

I want to put this macro in the open file button to give me the total lines in the file ( automatic) as a OemDro .
I will use it for percent program process.(which give me % of the job finished).

UH

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Total lines in the G Code for each file ??
« Reply #3 on: February 29, 2012, 01:19:58 PM »
I normally don't give out the secret handshake but try this is does what you need. You will need to change the output from a message to the UserDRo you need.


'Macro to assign Gcode Total Line count
Sub ReadStraightTextFile()
Dim LineofText As String
Dim rw As Long
rw = 0
Open "" & Filename() For Input As #1
Do While Not EOF(1)
Line Input #1, LineofText
rw = rw + 1
Loop
'Close the file
Close #1
Message ""& (RW+1)
End Sub

(;-) TP

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Total lines in the G Code for each file ??
« Reply #4 on: March 01, 2012, 02:20:34 AM »
My apologies UH - I did not read your question properly  ::)

Tweakie.
PEACE
Re: Total lines in the G Code for each file ??
« Reply #5 on: March 01, 2012, 02:44:14 AM »
Thank you BR549 , it works, (even it takes a long time to load the file), this is what I need. Fast solving problems.Thank you again.

UH
Re: Total lines in the G Code for each file ??
« Reply #6 on: March 01, 2012, 04:39:03 AM »
BR549, I only have one more question.

All my files are more than 300.000 lines, so when I put your code, it took about 2 minutes and 30 seconds to load the file, while when I open it without the code it takes only 11 seconds.
So what I mean is, is there any way that we can know the total lines for the file without counting them one by one as the code did, so it can take less time ??

And of course thank you for your help, and I appreciate it.


Regards,
UH
Re: Total lines in the G Code for each file ??
« Reply #7 on: March 01, 2012, 07:38:09 AM »
DRO 233 reports the total lines in a file.
DRO 240 reports the line number that I are currently running.
DRO 816 reports the line number your scrolling thru in the file if I am looking for something.

I have the DRO's on my main page I added them with machscreen but you can use screen4 I am sure.
Re: Total lines in the G Code for each file ??
« Reply #8 on: March 01, 2012, 08:29:20 AM »
YNN, where did you find 233 ?
It's not in any of the lists that I have.
Thanks,
Russ
Re: Total lines in the G Code for each file ??
« Reply #9 on: March 01, 2012, 08:50:43 AM »
Thank you Ya-Nvr-No ,
This is exactly what I need. Now I can open long files in the same time with a total line number which I will use it to give me a percentage of the finished work.
Thank you again, and I want to thank all the members for their help.

UH