Post by donnybowers on Feb 25, 2019 2:08:23 GMT -5
EDITED:
I made my first GUI in LB5-347 alpha. I used the new freeform to create the GUI.
I found a couple of bugs which I will explain, but here's the working code I came up with. It utilizes a listbox, a textbox, a texteditor and a button. It lists files from a file named "dir.txt". You double click on a file and it places it in the texteditor:
Now for the bug. You'll notice that when I place the text from the file in the texteditor I'm using the following two commands:
print #main.edit, "!cls"
print #main.edit, txt$
I originally used:
#main.edit, "!contents txt$"
It gave me a syntax error, so I changed it to:
print #main.edit, "!contents txt$"
Here's the error log from that:
Another issue I found in alpha 347 is that if you select an item in a listbox and press enter, it acts more or less like the tab key taking you to the next control. In this case the textbox, then the texteditor. Being that this program uses a default button, it would normally be the same as double clicking the listbox item.
Anyway, it's a little GUI program that works with LB5 alpha 347 on Linux. It also works with LB 4.04 in Windows XP. I'm curious to get feedback on how it works for you on other systems.
LB5 ALIVE!!!
I made my first GUI in LB5-347 alpha. I used the new freeform to create the GUI.
I found a couple of bugs which I will explain, but here's the working code I came up with. It utilizes a listbox, a textbox, a texteditor and a button. It lists files from a file named "dir.txt". You double click on a file and it places it in the texteditor:
' NOTE: you have to place a file named dir.txt into the same directory with this program.
' dir.txt has to contain the names of at least one of the files in your directory.
' TO DO: use the FILES command instead of this "dir.txt" file
dim file$(1000)
open "dir.txt" for input as #1
numfiles=0
while eof(#1)=0
numfiles=numfiles+1
line input #1, file$(numfiles)
wend
close #1
nomainwin
WindowWidth = 550
WindowHeight = 420
UpperLeftX = 1
UpperLeftY = 1
listbox #main.open, file$(, [open], 10, 46, 224, 300
statictext #main.st1, "Choose File", 26, 16, 88, 20
textbox #main.fname, 330, 15, 208, 25
statictext #main.st2, "File Name", 254, 16, 74, 20
texteditor #main.edit, 254, 46, 280, 300
button #main.default, "Open", [open], UL, 10, 350, 60, 30
open "First LB5 Freeform GUI" for dialog as #main
print #main, "font ms_sans_serif 10"
[main.inputLoop] 'wait here for input event
wait
[open] 'Perform action for the listbox named 'open'
'notice "open"
print #main.open, "selection? fileName$"
if fileName$<>"" then
print #main.fname, fileName$
open fileName$ for input as #1
txt$=""
while eof(#1)=0
line input #1, r$
r$=r$+chr$(13)+chr$(10)
txt$=txt$+r$
wend
close #1
print #main.edit, "!cls"
print #main.edit, txt$
end if
wait
Now for the bug. You'll notice that when I place the text from the file in the texteditor I'm using the following two commands:
print #main.edit, "!cls"
print #main.edit, txt$
I originally used:
#main.edit, "!contents txt$"
It gave me a syntax error, so I changed it to:
print #main.edit, "!contents txt$"
Here's the error log from that:
==2019/2/25==1:23:55==BEGIN RUNTIME DIAGNOSTIC DUMP
Note: this file stored in VisualWorks #source (UTF-8) encoding
Cause of Dump: Unhandled exception: Message not understood: #contents:
Smalltalk Version: 'VisualWorks®, Pre-Release 8.3.2 (apr18.3) of April 20, 2018'
Object Memory versionId: #[172 40 76 176 83 2 3 4 172 47 76 176]
Class creating this dump: ErrorDumper
------------------------------------------------------------
Active Process
Process named: 'Unnamed Process'
Process priority: 50
Process identity hash: 2149
Context Stack:
[1] NomainwinIoPortal(Object)>>error:
[2] NomainwinIoPortal>>runtimeError:
[3] BranchingProgramDirector(Director)>>runtimeError:
[4] [] in BranchingProgramDirector>>innerDirect
[5] BlockClosure>>cull:
[6] MessageNotUnderstood(GenericException)>>performHandler:
[7] MessageNotUnderstood(GenericException)>>propagatePrivateFrom:
[8] MessageNotUnderstood(GenericException)>>propagateFrom:
[9] MessageNotUnderstood(GenericException)>>propagate
[10] MessageNotUnderstood(GenericException)>>raiseSignal
[11] optimized [] in Director>>direct:
[12] BlockClosure>>cull:
[13] MessageNotUnderstood(GenericException)>>performHandler:
[14] MessageNotUnderstood(GenericException)>>propagatePrivateFrom:
[15] MessageNotUnderstood(GenericException)>>propagateFrom:
[16] MessageNotUnderstood(GenericException)>>propagate
[17] MessageNotUnderstood(GenericException)>>raiseSignal
[18] LBTexteditor(Object)>>doesNotUnderstand:
[19] LBTexteditor>>writeItem:cr:
[20] LBTexteditor>>writeItemCr:
[21] PrintHandleFrame>>animate:
[22] optimized [] in [] in Director>>direct:
[23] OrderedCollection>>do:
[24] optimized [] in Director>>direct:
[25] BlockClosure>>on:do:
[26] Director>>direct:
[27] Director>>for:direct:
[28] IfThenClip>>animate:
[29] optimized [] in BranchingProgramDirector>>innerDirect
[30] BlockClosure>>on:do:
[31] BranchingProgramDirector>>innerDirect
[32] BranchingProgramDirector>>direct:
[33] BranchingProgramDirector(Director)>>for:direct:
[34] BranchingProgramDirector>>for:direct:
[35] Program>>runWithDirector:
[36] optimized [] in Program>>runForked
[37] BlockClosure>>on:do:
[38] optimized [] in Process class>>forBlock:priority:
------------------------------------------------------------
Unhandled Exception:
class: UnhandledException
creator: UnhandledException
errorString: Unhandled exception: Message not understood: #contents:
parameter: an Error
==2019/2/25==1:23:55==END RUNTIME DIAGNOSTIC DUMP
Another issue I found in alpha 347 is that if you select an item in a listbox and press enter, it acts more or less like the tab key taking you to the next control. In this case the textbox, then the texteditor. Being that this program uses a default button, it would normally be the same as double clicking the listbox item.
Anyway, it's a little GUI program that works with LB5 alpha 347 on Linux. It also works with LB 4.04 in Windows XP. I'm curious to get feedback on how it works for you on other systems.
LB5 ALIVE!!!