I was wondering if it is possible to create a FIFO view using the editorGadget? What I want to do is display the last "n" entries made into the gadget in a FIFO fashion. This is for a serial port monitor/logger. Each line sent gets displayed in an editorGadget then logged to a file - line by line. Visually in the editor gadget I really only want to be able to see the last 100 lines or so. Also since this monitor will run for days I don't want the editorGadget to get overloaded and fail. Right now I'm counting the lines in the gadget and just deleting all of them when they reach a certain amount.
It's not obvious to me if I can do this with the editorGadget.
Just a word of praise for PB - I've been using it for only a week and have accomplished more than I did with VB in 6 months. I'm very impressed with the available functionality and easy of use.
Thanks,
Jeff E.
FIFO view using an editorGadget?
First thing that springs to mind is to use an array and keep the strings in that using a fifo approach, actually using a pointer to the next entry and rotating it, so with an array of 100 strings you would put the next strings into 1,2,3 etc upto 98,99,100 and then back to 0.
From this array you could just keep displaying the strings in an editor gadget but this is where the problem lies as you would have to clear and refill the gadget with all 100 lines each time you get a new string.
Perhaps using a different kind of gadget would be preferable.
From this array you could just keep displaying the strings in an editor gadget but this is where the problem lies as you would have to clear and refill the gadget with all 100 lines each time you get a new string.
Perhaps using a different kind of gadget would be preferable.
Welcome to PB JElliott
Maybe I'm missing the point, but how about something like this...

Maybe I'm missing the point, but how about something like this...
Code: Select all
If OpenWindow(0, 0, 0, 400, 400, "FIFO EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
EditorGadget(0, 5, 5, 390, 250)
ButtonGadget(1, 5, 300, 100, 25, "Add line")
For a = 1 To 100
AddGadgetItem(0, -1, "Line "+Str(a))
Next
totalCount = 100
SendMessage_(GadgetID(0), #EM_SCROLLCARET, 0, 0)
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget And EventGadget() = 1
totalCount + 1
AddGadgetItem(0, count-1, "Line " + Str(totalCount))
SendMessage_(GadgetID(0), #EM_SCROLLCARET, 0, 0)
SendMessage_(GadgetID(0), #EM_SCROLL, #SB_PAGEDOWN, 0)
count = CountGadgetItems(0)
If count > 100
RemoveGadgetItem(0, 0)
EndIf
EndIf
Until event = #PB_Event_CloseWindow
EndIf
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1