Machsupport Forum

Mach Discussion => Mach Screens => Screen designer tips and tutorials => Topic started by: Busellato on June 17, 2019, 01:27:17 AM

Title: 2 lines of "VB" message to show
Post by: Busellato on June 17, 2019, 01:27:17 AM
We are designing a screenset for a customer and would like to show more than 1 line of VB messages from LastErrors.txt file.
Just wondering if it's possible and how do we change the format of the Error label for it to display 2 lines of messages.

Thank you in advance.
Title: Re: 2 lines of "VB" message to show
Post by: TPS on June 17, 2019, 03:36:35 AM
don't know a possibility to Show more than one line in Standard errorlabel.

but you can run a small code in macropump and Show Messages N and N-1 in two userlabels

Code: [Select]
Open "C:\Mach3\Lasterrors.txt" For Input As #2 ' Open to read file.
Do While Not EOF(2)
Line Input #2, FileData ' Read a line of data.
SetUserLabel(151,GetUserlabel(150)) ' save message N-1 to userlabel151
SetUserLabel(150,FileData)                ' save message N   to userlabel150
Loop
Close #2
Title: Re: 2 lines of "VB" message to show
Post by: Busellato on June 17, 2019, 05:42:21 AM
Thank you for a quick reply,  :)
We got it working, but it reads through the file and flickers everything on the screen until it gets to the last line. We'll see if we can get it to just display the last 2 lines.

We'll post back with results sometime next week.
Title: Re: 2 lines of "VB" message to show
Post by: TPS on June 17, 2019, 05:46:23 AM
this should work without filckering

Code: [Select]
Open "C:\Mach3\Lasterrors.txt" For Input As #2 ' Open to read file.
Do While Not EOF(2)
Line Input #2, FileData ' Read a line of data.
LineN_1 = GetUserlabel(150)
LineN = FileData
Loop
Close #2
SetUserLabel(151,LineN_1)
SetUserLabel(150,LineN)   



Title: Re: 2 lines of "VB" message to show
Post by: Busellato on June 18, 2019, 10:39:28 AM
Thank you again for the reply TPS, the flickering is gone but both lines display the same line.

I've searched around for ways of counting the number of lines in a text file and need to experiment reading the last and second last lines into memory so it can be displayed.

Getting a bit late so will continue tomorrow.

Your solution looks less cumbersome, unfortunately my knowledge of VBA is very limited for me to change your script to it work.

Thank you again for your help.
Title: Re: 2 lines of "VB" message to show
Post by: TPS on June 18, 2019, 10:47:34 AM
sorry my fault, not tested

Code: [Select]
Open "C:\Mach3\Lasterrors.txt" For Input As #2 ' Open to read file.
Do While Not EOF(2)
Line Input #2, FileData ' Read a line of data.
LineN_1 = LineN
LineN = FileData
Loop
Close #2
SetUserLabel(151,LineN_1)
SetUserLabel(150,LineN) 
Title: Re: 2 lines of "VB" message to show
Post by: Busellato on June 19, 2019, 03:25:30 AM
Thank you so much  :). That worked like a charm. Besides the help it also teaches us a few tricks as well. :)