|
Post by chmod777 on Aug 22, 2022 18:01:40 GMT -5
Hello --
Question:
1) Liberty Basic v4.5.1 is loaded. 2) The following code is entered: print "Hello, world" 3) The "Run" button is clicked
The results are displayed in a popup window, as (hopefully) viewable in the enclosed image file.
That window, where the results of the aforementioned code is displayed...
Does that window have a name?
It's almost akin to a terminal user interface through which output and input can be done (as an alternative to a GUI based interface).
My reason for asking: I'd like to explore configuring the background color of that output window, as well as the font color. I'm not sure if it's possible?
Thank you for your help and patience. ^Stephen
Attachments:
|
|
|
Post by chmod777 on Aug 22, 2022 18:20:45 GMT -5
The only real lead that I have comes from the Liberty BASIC tutorial.
Under "Lesson Four, More GUI Programming" - the following option exists: + Using NOMAINWIN
And it says, in part:
"The default text window that opens with each Liberty BASIC program we create can be optionally turned off. This can be desirable when we don't want our application to be operated out of a text window. The statement that accomplishes this effect is NOMAINWIN. Simply include NOMAINWIN in your program's source code anywhere at all."
So, to perhaps further clarify my question:
I *want* my proposed application to be operated out of the "text window" that's mentioned above.
My question is: can I modify the background color and font color of the "text window" though which my proposed application will be operated out of?
Right now, it appears the default color scheme is "white" background with "black" text.
I'm wondering whether, perhaps via "Stylebits" or some other mechanism, I might be able to modify the "text window" background color and font color?
Thanks again for any hints, guidance, or feedback.
^Stephen
|
|
|
Post by chmod777 on Aug 22, 2022 18:40:40 GMT -5
For even further clarity, it *does* hypothetically seem as though the term for the window I'm describing might be "mainwin" -- for example, the following code successfully adjusts the "text window" that I'm attempting to describe:
mainwin 40 12 print "Hello world!"
Based on the above code snippet, it would appear as though the "mainwin" command/name/label with the accompanying numerical inputs successfully adjust the width and height of the "text window" where the results of the code snippet are displayed.
I'm hypothesizing there might plausibly be a...
mainwin backgroundcolor="green" fontcolor="black"
(or similar)
...mechanism to adjust the "mainwin" ("text window") background color and font color?
^Stephen
|
|
|
Post by chmod777 on Aug 22, 2022 19:10:42 GMT -5
I discovered this useful comment from Rod (link: libertybasiccom.proboards.com/post/12179/) -- "You will find the mainwin a bit cluncky as it has not got much functionality built in. You can change the number of col and rows but not much else." This comment from Brandon also struck me as useful (link: libertybasiccom.proboards.com/post/12187/) -- "Normally, the MainWin is used for debugging purposes or the simple output of a program." That said, both comments also went into extreme depth and detail as to how it might be plausible to "move" the MainWin and position it on the computer screen in various ways. That gives me *some* modicum of hope that it might be plausible to adjust the "background" color of "MainWin" and/or to adjust the "font color" within "MainWin" as well. ^Stephen
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Aug 22, 2022 19:37:44 GMT -5
No color for the mainwin but I have a model for doing a mainwin like app in a graphics window so you can have color, you can also use large font if your eyes are as old as BASIC ;-))
A nice feature of mainwin is that you can copy and paste from it!
|
|
|
Post by chmod777 on Aug 22, 2022 20:12:25 GMT -5
No color for the mainwin but I have a model for doing a mainwin like app in a graphics window so you can have color, you can also use large font if your eyes are as old as BASIC ;-)) Thank you for the reply, and yes, I know what you mean regarding having a larger font size! :-) While my eyes aren't quite as old as BASIC itself, I do fear that over time I've developed what could be classified as farsightedness.
Alright, so it appears no color adjustments for "mainwin" are possible. Speaking of eyesight, it was actually an effort on my part to make the background of "mainwin" black and the font color "gray" in an effort to minimize eye strain.
I'm exploring whether "mainwin" might inherit various default settings established by the Windows operating system, in which case, I might be able to modify my vector of attack in an effort to obtain the result I'm seeking.
^Stephen
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Aug 22, 2022 20:27:05 GMT -5
Best you bite the bullet and learn LB way of graphics window, very well established GUI and can do multiple Windows at a time.
If you come from a QB bckground here is a Template I use to get an app started with a bunch of routines for doing this and that in JB / LB:
'JB Library.txt for Just Basic v1.01 [B+=MGA] 2016-11-11 'added Atan2 '2016-10-28 add extra pixel to end of aline, box, fbox for bug fix
' notes: template code for graphics window
global Xmax, Ymax, Pi, Deg, Rad Xmax = 660 Ymax = 660 Pi = acs(-1) Deg = 180 / Pi Rad = Pi / 180
nomainwin
WindowWidth = Xmax + 8 WindowHeight = Ymax + 32 UpperLeftX = (DisplayWidth - Xmax) / 2 'or delete if Xmax is 1200 or above UpperLeftY = (DisplayHeight - Ymax) / 2 'or delete if Ymax is 700 or above
open "Graphic Title" for graphics_nsb_nf as #gr '<======================= title #gr "setfocus" #gr "trapclose quit" #gr "when leftButtonUp lButtonUp" #gr "when characterInput charIn" #gr "down" #gr "fill black" '============================== main code note: to text need min 10 in y value, text width(6-16) height 16 call back 255,0,255 call fore 255,0,0 b$ = "" for i=1 to 10 b$ = b$ + str$( rand(5,10) );" " next call stext 10,30, b$ b$ = "" call ctext 240, "testing 1,2,3... wait for continue..." call pause 3000 call ftriangle 250,250,0,500,500,500 call fore 255, 255, 255 call box 100, 100, Xmax-100, Ymax-100 'this draws a white box frame inside screen
'============================== sets drawing #gr "flush" wait
'JB Library of procedures ====================================================== 'notes: arrays are global limited in dimensions, no constants, no imports, no declares... 'must "call" subs no ()! not even in definitions and must use () for parameterless functions
sub midpoint x1, y1, x2, y2, fraction, byref midx, byref midy midx = (x2 - x1) * fraction + x1 midy = (y2 - y1) * fraction + y1 end sub
function distance(x1, y1, x2, y2) distance = ( (x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5 end function
function rand(lo, hi) rand = int((hi - lo + 1) * rnd(0)) + lo end function
sub hue r, g, b 'fore and back #gr "color ";r;" ";g;" ";b #gr "backcolor ";r;" ";g;" ";b end sub
sub fore r, g, b #gr "color ";r;" ";g;" ";b end sub
sub back r, g, b 'backcolor is used for fills #gr "backcolor ";r;" ";g;" ";b end sub
sub QBcolr colrNum select case colrNum case 0 : #gr "color black" case 1 : #gr "color darkblue" case 2 : #gr "color brown" case 3 : #gr "color darkcyan" case 4 : #gr "color darkred" case 5 : #gr "color darkpink" case 6 : #gr "color darkgreen" case 7 : #gr "color lightgray" case 8 : #gr "color darkgray" case 9 : #gr "color blue" case 10 : #gr "color green" case 11 : #gr "color cyan" case 12 : #gr "color red" case 13 : #gr "color pink" case 14 : #gr "color yellow" case 15 : #gr "color white" end select end sub
sub pset x, y #gr "set ";x;" ";y end sub
sub aline x0, y0, x1, y1 #gr "line ";x0;" ";y0;" ";x1+1;" ";y1+1 'add 1 to end point end sub
sub box x0, y0, x1, y1 #gr "place ";x0;" ";y0 #gr "box ";x1+1;" ";y1+1 'add pixel at end end sub
sub fbox x0, y0, x1, y1 #gr "place ";x0;" ";y0 #gr "boxfilled ";x1+1;" ";y1+1 end sub
sub circ x, y, radius #gr "place ";x;" ";y;"; circle ";radius end sub
sub fcirc x, y, radius #gr "place ";x;" ";y;"; circlefilled ";radius end sub
sub ellips x, y, w, h '< no e on end! #gr "place ";x;" ";y;"; ellipse ";w;" ";h end sub
sub fellipse x, y, w, h #gr "place ";x;" ";y;"; ellipsefilled ";w;" ";h end sub
'ink the color that is percent between the first color and 2nd color
sub midInk r1, g1, b1, r2, g2, b2, frac dr = (r2 - r1) * frac : dg = (g2 - g1) * frac : db = (b2 - b1) * frac #H$ "color ";r1 + dr;" ";g1 + dg;" ";b1 + db #H$ "backcolor ";r1 + dr;" ";g1 + dg;" ";b1 + db end sub
'Fast Filled Triangle Sub by AndyAmaya Sub ftriangle x1, y1, x2, y2, x3, y3 'triangle coordinates must be ordered: where x1 < x2 < x3 If x2 < x1 Then x = x2 : y = y2 : x2 = x1 : y2 = y1 : x1 = x : y1 = y 'swap x1, y1, with x3, y3 If x3 < x1 Then x = x3 : y = y3 : x3 = x1 : y3 = y1 : x1 = x : y1 = y 'swap x2, y2 with x3, y3 If x3 < x2 Then x = x3 : y = y3 : x3 = x2 : y3 = y2 : x2 = x : y2 = y If x1 <> x3 Then slope1 = (y3 - y1) /(x3 - x1) 'draw the first half of the triangle length = x2 - x1 If length <> 0 Then slope2 = (y2 - y1)/(x2 - x1) For x = 0 To length #gr "Line ";int(x + x1);" ";int(x * slope1 + y1);" ";int(x + x1);" ";int(x * slope2 + y1) Next End If 'draw the second half of the triangle y = length * slope1 + y1 : length = x3 - x2 If length <> 0 Then slope3 = (y3 - y2) /(x3 - x2) For x = 0 To length #gr "Line ";int(x + x2);" ";int(x * slope1 + y);" ";int(x + x2);" ";int(x * slope3 + y2) Next End If call aline x1, y1, x2, y2 call aline x2, y2, x1, y1 call aline x2, y2, x3, y3 call aline x3, y3, x2, y2 call aline x1, y1, x3, y3 call aline x3, y3, x1, y1 End Sub
sub star x, y, rInner, rOuter, nPoints, angleOffset, TFfill ' x, y are same as for circle, ' rInner is center circle radius ' rOuter is the outer most point of star ' nPoints is the number of points, ' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub ' this is to allow us to spin the polygon of n sides ' TFfill filled True or False (1 or 0)
pAngle = RAD * (360 / nPoints) : radAngleOffset = RAD * angleOffset x1 = x + rInner * cos(radAngleOffset) y1 = y + rInner * sin(radAngleOffset) for i = 0 to nPoints - 1 x2 = x + rOuter * cos(i * pAngle + radAngleOffset + .5 * pAngle) y2 = y + rOuter * sin(i * pAngle + radAngleOffset + .5 * pAngle) x3 = x + rInner * cos((i + 1) * pAngle + radAngleOffset) y3 = y + rInner * sin((i + 1) * pAngle + radAngleOffset) if TFfill then call ftriangle x1, y1, x2, y2, x3, y3 else call aline x1, y1, x2, y2 call aline x2, y2, x3, y3 end if x1 = x3 : y1 = y3 next if TFfill then call fcirc x, y, rInner end sub
sub stext x, y, message$ 'note: have to reset fore or back color after ink #gr "place ";x;" ";y;";|";message$ end sub
sub ctext y, message$ 'uses const Xmax and sub stext call stext (Xmax - len(message$) * 7) /2, y, message$ end sub
sub lButtonUp H$, mx, my 'must have handle and mouse x,y call quit H$ '<=== H$ global window handle end sub
sub charIn H$, c$ if asc(c$) = 32 then goON = 1 - goON else call quit H$ end if end sub
'Need line: #gr "trapclose quit" sub quit H$ close #gr '<=== this needs Global H$ = "gr" end 'Thanks Facundo, close graphic wo error end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
Function Atan2(y, x) 'Atan2 is a function which determines the angle between points 'x1, y1 and x2, y2. The angle returned is in radians 'The angle returned is always in the range of '-PI to PI radians (-180 to 180 degrees) '============================================================== 'NOTE the position of Y and X arguments 'This keeps Atan2 function same as other language versions '============================================================== If x = 0 Then If y < 0 Then Atan2 = -1.5707963267948967 Else Atan2 = 1.5707963267948967 End If Else chk = atn(y/x) If x < 0 Then If y < 0 Then chk = chk - 3.1415926535897932 Else chk = chk + 3.1415926535897932 End If End If Atan2 = chk End If 'thanks Andy Amaya End Function
'draws an arc with center at xCenter, yCenter, radius from center is arcRadius sub arc xCenter, yCenter, arcRadius, dAStart, dAMeasure 'notes: 'you may want to adjust size and color for line drawing 'using angle measures in degrees to match Just Basic ways with pie and piefilled 'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
rAngleStart = RAD * dAStart rAngleEnd = RAD * dAMeasure + rAngleStart Stepper = RAD / (.1 * arcRadius) 'fixed lastX = xCenter + arcRadius * cos(rAngleStart) lastY = yCenter + arcRadius * sin(rAngleStart) #gr "set ";int(lastX);" ";int(lastY) for rAngle = rAngleStart+Stepper to rAngleEnd step Stepper nextX = xCenter + arcRadius * cos(rAngle) nextY = yCenter + arcRadius * sin(rAngle) #gr "goto ";int(nextX);" ";int(nextY) 'int speeds things up next end sub
|
|
|
Post by chmod777 on Aug 22, 2022 20:50:41 GMT -5
Thank you so much for sharing that code in this thread. I genuinely appreciate it.
I'll work through it more thoroughly when it's morning again in my time zone.
Thanks again!
|
|
|
Post by Rod on Aug 23, 2022 5:37:59 GMT -5
Have you found the example programs? The tutorial takes a little time but is well worth working through. Running the example programs let’s you see all of the gadgets or controls the Liberty offers. They should appear as .bas programs if you click on file open.
They can be hard to find if you have altered the setup to open a known file or the last file as this will hide your user directory. Easiest way is to click on setup and select no file on startup. Then restart Liberty and the example files will be listed when you click file open.
Play with as many as you can to see what is possible.
Lots of folks do use the mainwin to run their program. Aside from Color and font changes you can do a lot but it is the old fashioned way and there is so much more if you step into GUI programming.
|
|