curly
Full Member
Posts: 161
|
Post by curly on Aug 7, 2021 17:47:41 GMT -5
Hi, it's me again,
I have a problem displaying information. I have a simple array, Circuits$(10), that holds the circuits descriptions for the different circuits in a fuseboard, numbered 1 to 10. I am using a Text Editor window to display the circuits, one circuit per line. The use of tab keys would be handy to make columns line up? Each time a new circuit is created, the Text Editor window is cleared, and the circuits are displayed using a loop until process. The problem I have is that I need a button alongside each circuit to call a popup that has 4 options, 1. Move circuit up, 2. Move circuit down, 3. Insert spare circuit, and 4. Delete circuit. I'm OK manipulating data after the selection is made, but the Text Editor window doesn't allow buttons, and I'm a bit stuck moving forward? I suspect a Graphic Window may be the answer, but have little experience other than trying unsuccessfully to create one.
Am I seeking the impossible?
Kind regards,
David
ps I posted a newthread on this subject some hours ago, but can't find it? Maybe I failed to finish it correctly?
|
|
|
Post by Stefan Pendl on Aug 8, 2021 2:42:39 GMT -5
Instead of using a text editor window, use a regular window with a text editor control and add you buttons as you like. It is easy to setup a window utilizing FreeForm, which is shipping with LB.
|
|
|
Post by tsh73 on Aug 8, 2021 3:35:03 GMT -5
Do we have a way for knowing selected line in TextEditor? I think ListBox wil be better suited for this (single click selects double clibk opens for edit) (I disabled bottom editor. Else you should update items then switching to another line)
' Form created with the help of Freeform-J v.261006 ' Generated on Aug 08, 2021 at 10:35:56
nomainwin
WindowWidth = 568 WindowHeight = 515
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
listbox #main.listbox1, array$(, [listbox1DoubleClick], 26, 16, 272, 260 button #main.button2, "up", [button2Click], UL, 326, 16, 122, 25 button #main.button3, "down", [button3Click], UL, 326, 46, 122, 25 button #main.insert, "insert", [button4Click], UL, 326, 76, 122, 25 button #main.button5, "delete", [button5Click], UL, 326, 106, 122, 25 statictext #main.statictext6, "list", 30, 1, 144, 20 statictext #main.statictext7, "selected", 30, 281, 144, 20 texteditor #main.texteditor8, 22, 301, 528, 150 menu #main, "Edit" '<--- Texteditor Menu can be moved but not removed.
open "untitled" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
N=5 for i = 1 to N array$(i)="Item ";i;" ";int(100000*rnd(0));chr$(9);int(100000*rnd(0)) next #main.listbox1, "reload"
#main.listbox1,"singleclickselect [singleClick]" #main.texteditor8, "!disable"
wait
[quit.main] Close #main END
[singleClick] #main.listbox1, "selection? selected$" #main.texteditor8,"!cls" #main.texteditor8, selected$ wait
[listbox1DoubleClick] 'for edit #main.listbox1, "selectionindex? index" 'notice index if index =0 then wait 'nothing selected ret$=array$(index) prompt "Edit an item"; ret$ if ret$="" then wait 'Cancel or ESC array$(index)=ret$ #main.listbox1, "reload" #main.listbox1, "selectindex "; index goto [singleClick] 'update selection 'wait
[button2Click] 'up #main.listbox1, "selectionindex? index" 'notice index if index<=1 then wait tmp$=array$(index) array$(index)=array$(index-1) array$(index-1)=tmp$ #main.listbox1, "reload" #main.listbox1, "selectindex "; index-1 wait
[button3Click] 'down #main.listbox1, "selectionindex? index" 'notice index if index>=N then wait tmp$=array$(index) array$(index)=array$(index+1) array$(index+1)=tmp$ #main.listbox1, "reload" #main.listbox1, "selectindex "; index+1 wait
[button4Click] 'insert above selected 'do you have array big enough? Default is 10 items #main.listbox1, "selectionindex? index" 'notice index for i = N to index step -1 array$(i+1)=array$(i) next N=N+1 array$(index)="Item ";N #main.listbox1, "reload" #main.listbox1, "selectindex "; index goto [singleClick] 'update selection 'wait
[button5Click] 'delete selected if N<1 then wait 'nothing to delete #main.listbox1, "selectionindex? index" if index =0 then wait 'nothing selected 'notice index for i = index+1 to N array$(i-1)=array$(i) next array$(N)="" N=N-1 #main.listbox1, "reload" #main.listbox1, "selectindex "; index goto [singleClick] 'update selection 'wait
|
|
curly
Full Member
Posts: 161
|
Post by curly on Aug 8, 2021 7:28:32 GMT -5
Hi Stefan and Anatoly,
The demo was almost exactly what I wanted - having read up and studied your code, I have adapted it to my application, and it cannot be any more purrrrfect!
Thank you very much! David
|
|
|
Post by Walt Decker on Aug 8, 2021 18:29:18 GMT -5
Why go to all that trouble? Why not use a listbox with the LBS.SORT style?
The list will be automatically sorted (if done properly) and then all you have to do is insert an iterm or delete an item. One button is all you need on the form for inserting.
|
|
|
Post by Brandon Parker on Aug 8, 2021 18:56:09 GMT -5
Maybe the idea is to not always have them sorted from A-Z/Z-A or 1-10/10-1 ...
On a very large application that I wrote in LB, this functionality existed on a ListView which held information for watching data points in an OSISoft PI database and alarmed/sent notifications. The idea was that people could sort the list as they saw fit in real-time and in any order they wanted.
{:0)
Brandon Parker
|
|
|
Post by Rod on Aug 9, 2021 2:35:21 GMT -5
Sorting is a very powerful technique that helps data display and management, so I see where you are both coming from. However in this particular case the on site engineer is drawing what he finds, banks of circuits. The circuits may be in multiple banks and have spurs, they may have numbers but it is unlikely they will be in order and it is more likely they are named and are not in alpha order. So there is no data that can automatically be sorted. We are relying on the eye of the man on site and his judgement as to the order of display.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Aug 9, 2021 3:50:39 GMT -5
Hi All, thanks for your combined input, but I am lucky that I was able to learn from Anatly's code and modify it to achieve what I needed. The main circuit data is held in an array, CCU$(100,34). Each circuit has 34 items of data, and the array can hold up to 100 circuits. As the circuits are created, I wanted to display to the engineer all the circuits that had been created, as only the current circuit is displayed in the main area with all of its 34 items. Each time a circuit is added, the display is refreshed, and the array is interrogated to create the display with only essetial items shown, fuseboard reference, way number, circuit number and circuit description. Electricians made mistakes, (alhough I don't know any who would admit that), so I was looking for a way for them to insert, delete, or move a circuit. I've modified the demo provided by Anatoly and written the first routine (to insert) to manipulate the data in the CCU$ array when the appropriate button is clicked, before the display is refreshed to show the change. It works a treat thank you. I've even used a Stylebits Rod gave me to keep the display on top of everything until it is closed!
....but it is all the testing that is so time consuming and boring!
Kind regards,
David
|
|
|
Post by Walt Decker on Aug 9, 2021 9:05:39 GMT -5
Perfect for a sorted list box.
Now he talks about circuits of 100 X 34 which would be perfect for a list view; however, the latter is beyond his current capabilities. Oh, well.
|
|