LB Booster
« Mainwin Font »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:52am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: Mainwin Font  (Read 2012 times)
Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Mainwin Font
« Thread started on: Jan 11th, 2015, 2:55pm »

New to LBB. Certainly faster. I like it!

I have an LB4 program that runs in mainwin (yes I know I shouldn't). The program allows the user to change the mainwin font by altering the respective lbasic404.ini file entry where the font is set.

Is there a way to change the font that mainwin uses in LBB?

Thank you smiley
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Mainwin Font
« Reply #1 on: Jan 11th, 2015, 3:24pm »

on Jan 11th, 2015, 2:55pm, Monkfish wrote:
Is there a way to change the font that mainwin uses in LBB?

Yes you can, although I can't guarantee it will be entirely free of side-effects. You can do it as follows:

Code:
    !*font Courier New,16
    print "Hello mainwin!" 

Note that as it's using the 'BBC BASIC escape' feature you must specify the font in a slightly different format from how you normally would in LB (no underscores, and a comma before the size).

Adding that code will make the program incompatible with LB 4.04 so if you want to retain compatibility put the font-change line in a separate file and use LBB's 'include facility:

Code:
'don't put the include as the first line
'include newfont.bas
    print "Hello mainwin!" 

LB 4 will treat the 'include as a comment and ignore it.

Richard.

« Last Edit: Jan 11th, 2015, 3:34pm by Richard Russell » User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Mainwin Font
« Reply #2 on: Jan 14th, 2015, 10:41am »

Hi Richard, I would like the user to be able to select the font using fontdialog. I have written a program to convert from the font format in LB to the one in BBC BASIC (and stored the font it in a string called font$), but I can't seem to be able to pass this to the escape function (as below):

!*font font$

e.g. font$="Courier New,16"
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Mainwin Font
« Reply #3 on: Jan 14th, 2015, 11:43am »

on Jan 14th, 2015, 10:41am, Monkfish wrote:
I can't seem to be able to pass this to the escape function (as below):

BBC BASIC's 'star' commands have the same limitation as LB's GUI commands: you can't pass a variable directly, instead you have to construct a string containing the command and its parameters.

The syntax you need to use is this:

Code:
    fontcmd$ = "font Courier New,16"
    !OSCLI fontcmd$
    print "Hello world!" 

Or this would work just as well:

Code:
    font$ = "Courier New,16"
    !OSCLI "font " + font$
    print "Hello world!" 

Richard.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Mainwin Font
« Reply #4 on: Jan 14th, 2015, 6:25pm »

Thanks again Richard, that worked fine. Strangely, changing the font changes the flashing input I-beam into a dot rather than an "I". No big deal, but worth pointing out.

There were two other anomalies that I discovered while testing my program under LBB instead of LB. However, both may be intentional.

1. Input statements (both input and input$) accept input from the mouse scroll wheel. So if someone scrolls their mouse wheel while at an input statement they will get a string of spurious characters appear.

2. LBB doesn't seem able to open a hidden file for writing. It can open a hidden file for reading just fine, but not for writing. I have to run a batch file to make the file visible, then open it for writing, write data, close it, and then run another batch file to reset the hidden attribute.

I must say, I much prefer using LBB to LB. Great job!
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Mainwin Font
« Reply #5 on: Jan 14th, 2015, 7:28pm »

on Jan 14th, 2015, 6:25pm, Monkfish wrote:
Strangely, changing the font changes the flashing input I-beam into a dot rather than an "I".

I said there might be side-effects!

Quote:
Input statements (both input and input$) accept input from the mouse scroll wheel.

True. It could ignore those characters if you think it would be preferable.

Quote:
LBB doesn't seem able to open a hidden file for writing.

My tests suggest that it can successfully open the file for update, i.e. for modifying an existing file, but won't replace the file with a new one. This is a Windows feature which is documented at MSDN:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx

"If CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL are specified, CreateFile fails and sets the last error to ERROR_ACCESS_DENIED if the file exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM attribute".

Quote:
I have to run a batch file to make the file visible, then open it for writing, write data, close it, and then run another batch file to reset the hidden attribute.

If the new file is the same length as, or longer than, the previous one you could open the file for update (OPEN for BINARY) and then it would work.
Alternatively you could reset and set the 'hidden' attribute using API calls, which in my opinion is nicer than messing around with batch files.

Richard.
« Last Edit: Jan 14th, 2015, 8:05pm by Richard Russell » User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Mainwin Font
« Reply #6 on: Jan 14th, 2015, 9:17pm »

Thanks Richard. That clears all that up smiley

Yes, I think input and input$ function should be isolated from all mouse functions. Sometimes a wireless mouse can send spurious data which would then appear as garbage at a waiting input statement.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Mainwin Font
« Reply #7 on: Jan 14th, 2015, 11:04pm »

on Jan 14th, 2015, 9:17pm, Monkfish wrote:
Yes, I think input and input$ function should be isolated from all mouse functions.

I've been thinking about this and I've decided that it would be desirable to exclude the mouse-wheel codes from the INPUT statement but that it would not be desirable to exclude them from the INPUT$() function.

These codes are inserted into the keyboard buffer deliberately to make it easy to incorporate mouse-wheel functionality in a program, without the complications of API calls or (worse) having to use WMLiberty.DLL.

Quote:
Sometimes a wireless mouse can send spurious data

The mouse wheel functionality has been present in BBC BASIC (which is why it exists in LBB) for more than 13 years. Nobody has ever commented that it is undesirable or has ever reported 'spurious' keyboard input arising from this source.

So in the next release of LBB I will filter out the mouse-wheel codes in INPUT, but INPUT$(1) will continue to return them.

Richard.

User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Mainwin Font
« Reply #8 on: Jan 15th, 2015, 12:09pm »

That seem reasonable. You are more qualified than me to make that call. I just love the fact that you have gone to the trouble to create an alternative compiler for LB users. My program looks a lottle more professional, stable and it runs at least twice as fast. Thank you smiley
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Mainwin Font
« Reply #9 on: Jan 15th, 2015, 3:39pm »

on Jan 15th, 2015, 12:09pm, Monkfish wrote:
My program looks a lottle more professional, stable and it runs at least twice as fast.

Only twice as fast? A little disappointing! wink

Have you used LBB's profiler to see where the time is being spent? If your program plots graphics that could explain the improvement being only modest; there's a Wiki article about this. Another thing which can have an impact is doing a SCAN unnecessarily frequently; if you have a time-critical loop containing a SCAN try moving it out of the loop. WORD$() is quite slow in LBB too, especially if you don't specify an explicit delimiter.

Richard.
« Last Edit: Jan 15th, 2015, 3:42pm by Richard Russell » User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Mainwin Font
« Reply #10 on: Jan 15th, 2015, 7:10pm »

Thanks for the tips Richard. I will certainly remember them.

The speed of my program is reliant on nested array lookups, sometimes three deep. So the contents of one array points to the entry in the next and so on. I'm quite good at writing reasonably tight inner loops... my problem is that everything else is an unprofessional hack. I have been programming for about 35 years, but I'm not a serious programmer, just a BASIC mashuper. My code is awful. Even I can't understand it if I come back to it years later. I just like programming to get the computer to solve problems for me.

This program I have just finished is to create a league table for my bowls team. We have a team of say 12 players, but only 4 can play in each weekly game. So we have to select 4 from 12 so that everyone plays a similar number of games or a set number of games. That's not so difficult, but you also have allow partners to play together, keep certain players apart, holiday periods avoided, everyone's games spread out as evenly as possible thoughout the season and also maximise team variation, so everyone gets to play with everyone else... within the previous constraints.

In many cases there may not be one solution that fits to all the requirements. It is also sobering to realise that selecting 4 players from 12 for 30 games, produces a number of possible configurations that is roughly equivalent to the number of atoms in the known universe! And this program has to find the best one!

Now you know why I'm delighted with any speed increase I can get wink
User IP Logged

Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: Mainwin Font
« Reply #11 on: Jan 21st, 2015, 05:30am »

I read in another thread that the following BBC Basic command can be used to change the font in MainWin.
Code:
font$ = "Courier New, 14"
!OSCLI "font " + font$
 

You can search your system for LBB.ini, but it's not user-friendly. On XP it is in C:Documents and Settings\(myusername)\Programdata

And it's ok to write programs that run only in MainWin. In the old days that's how they all ran. Do what seems best for you.

« Last Edit: Jan 21st, 2015, 05:33am by Jack Kelly » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Mainwin Font
« Reply #12 on: Jan 21st, 2015, 08:22am »

on Jan 21st, 2015, 05:30am, Jack Kelly wrote:
You can search your system for LBB.ini

There's no reason why you should need to view or edit that file, since it only records settings that you can easily see and change in the IDE, but there's an easier way to find it should you want to: use the environment variable %APPDATA% (either in Windows Explorer or at a Command Prompt)

Quote:
And it's ok to write programs that run only in MainWin.

There are differing opinions on that! Some LB enthusiasts will argue that the mainwin should be used only for 'little programs' and for debugging GUI applications (which is certainly its principle use as far as I'm concerned). They would discourage its use as the main or only UI in a large program.

I won't take sides on that issue, but it's worth mentioning that LBB's mainwin does not have the high degree of compatibility with LB4 that the GUI features do. For example there is no menu, and you can only 'scroll back' a limited distance. On the other hand you can change the colour and even use graphics in the LBB mainwin, which you can't in LB4.

Richard.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Mainwin Font
« Reply #13 on: Jan 21st, 2015, 12:35pm »

Thanks Jack smiley

I wondered if LBB had an ini file. Changing the font within the program seems to work fine, but it's handy to know.

My program only uses text input because it's intended to be used by people who might not be confident in using a computer. If issues arise from using Mainwin, I will just have to shift all my input statements over to a separate window. Not sure what the benefits would be though?

I prefer to allow LBB to compile my code because the program it creates just feels more professional and produces a single executable... and it's faster wink
« Last Edit: Jan 21st, 2015, 12:38pm by Monkfish » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Mainwin Font
« Reply #14 on: Jan 21st, 2015, 2:06pm »

on Jan 21st, 2015, 12:35pm, Monkfish wrote:
I wondered if LBB had an ini file. Changing the font within the program seems to work fine, but it's handy to know.

I'm not sure if there's been some misunderstanding. The LBB.INI file sets the font used in the IDE (program editor), but it has no influence at all on the font used in the mainwin. They are totally independent, as one would (hopefully) expect.

In LB 4.04 the font used in the mainwin of a compiled program is linked in some way with the font used in the IDE. Why? It reminds me of the 'spooky action at a distance' that so upset Einstein, and it's almost as strange. But then I find many things about LB 4 inexplicable! shocked

Richard.
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls