Board Logo
« Adjusting program to suit display size »

Welcome Guest. Please Login or Register.
Jan 21st, 2018, 12:50am


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: Adjusting program to suit display size  (Read 650 times)
donjohnson24
Member in Training
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 20
xx Re: Adjusting program to suit display size
« Reply #15 on: Sep 30th, 2017, 6:41pm »

on Sep 29th, 2017, 11:41pm, bplus wrote:
Don, looks like you are progressing very nicely!

All those buttons look like allot of work! probably a labor of love, but has nice visual quality when done.


Thank you for your kind words - unless I find some magic solution to detecting keypresses, I think I have the progam pretty near finished now. Did some more 'disabling' and 'enabling' to control where a user can go, and added some colour to help with that.

If you are interested, the latest version is at http://www.donjohnson24.co.uk/PalmDocs/ as RACENITE.zip

Don
User IP Logged

Don Johnson (not the Film Star!)
e-mail me: don@donjohnson24.co.uk
personal web: http://www.donjohnson24.co.uk
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1255
xx Re: Adjusting program to suit display size
« Reply #16 on: Sep 30th, 2017, 9:18pm »

Quote:
unless I find some magic solution to detecting keypresses


I may have just the thing:
Code:
'detecting keypress magic.txt for JB (B+-MGA) 2017-09-30

global xmax, ymax
'set these to screen width = xmax, screen height = ymax, that you want

xmax = 1000 : ymax = 700  '<<<<<< set this as you need or from plug-in notes

global cellW, cellH
'do not mess with cellW and cellH globals for printing
cellW = 14 'pixels wide for characters
cellH = 28 'pixels high for characters

global maxRow, maxCol
'and then these are calclated from above globals
maxCol = int(xmax / cellW)  'these control printing characters
maxRow = int(ymax / cellH)

global lastC, lastR 'for loc8 (locate), pl (print a line), lp (locate and print)
lastC = 1 : lastR = 1

'key events update globals with latest info
global inkee$

nomainwin

WindowWidth = xmax + 8
WindowHeight = ymax + 32
UpperLeftX = (DisplayWidth-WindowWidth) / 2
UpperLeftY = (DisplayHeight-WindowHeight) / 2

open "Detecting keypress magic" for graphics_nsb_nf as #gr '<, == change for plug in modules
#gr "trapclose quit"
#gr "font dejavu_sans_mono ";cellW;" ";cellH
#gr "setfocus"                     '<<<<<<<<<<<<<<<<<<<<< this is needed for catching keypress
#gr "when characterInput charIn"   '<<<<<<<<<<<<<<<<<<<<< keypress handler for #gr
#gr "down"

[start]
loopCount = loopCount + 1
if loopCount mod 2 then

    'catch a keypress

    call cp 10, "Waiting for your keypress..."
    OK = 0
    while not(OK)
        scan 'allow an exit
        OK$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
        OK$ = OK$ + chr$(8)+ chr$(27) + chr$(13) + "1234567890!@#$%^&*()_-+={}[]|\:;'<,>.?/"
        if instr(OK$, inkee$) then OK = 1
    wend
    call cp 15, "You pressed '";inkee$;"' this message will clear in 2.5 secs..."

else

    ' enter a whole string !

    call loc8 10, 10
    call inp "Enter something > ", something$
    call cp 15, "You entered '";something$;"' this message will clear in 2.5 secs..."
end if
inkee$ = "" '<<<<<<<<<<<<<<<<<<< ha! remember to clear
call pause 2500
call clear 0, rnd(0) * 100 + 155, rnd(0) *100 + 155
goto [start]
wait

sub charIn hdl$, c$   'this sub updates global inkee$ with the latest keypress
    inkee$ = c$
end sub

sub quit hdl$
    timer 0
    close #gr
    end
end sub

sub clear r, g, b 'clear screen to new RGB color and set backcolor
' and set up so pl (print line) will start at line 1, cell column 1)
    #gr "fill ";r;" ";g;" ";b
    #gr "backcolor ";r;" ";g;" ";b
    lastC = 1 : lastR = 1
end sub

sub loc8 x, y   'locate xColumnCell, yRowCell for printing
    if 0 < x and x < maxCol + 1 and 0 < y and y < maxRow + 1 then
        lastC = x
        lastR = y
    end if
end sub

sub pl mess$ 'print line (feed)
    startR = lastR
    for i = 1 to len(mess$)
        scan
        call lp lastC, lastR, mid$(mess$, i, 1)
        if lastR <> startR then exit for
    next
    lastC = 1
    lastR = startR + 1
    if lastR > maxRow then lastR = maxRow 'yuck!
end sub

sub lp x, y, mess$ 'locate x, y : print mess$ lp = locate and print
    'if locate = x col and y row then and top left corner locates as 1, 1
    c = x - 1: r = y
    if 0 < x and x < maxCol + 1 and 0 < y and y < maxRow + 1 then
        #gr "place ";c * cellW;" ";r * cellH - 4
        #gr "|";mess$
        lastC = x + len(mess$)
        if lastC > maxCol then lastC = 1 : lastR = lastR + 1
        if lastR > maxRow then lastR = maxRow 'yuck!
    end if
end sub

'updated
sub cp y, cpText$ 'cp Center Print on line y the cpText$
    call lp int((maxCol - len(cpText$))/2 + 1.5), y, cpText$
    lastC = 1 : lastR = y + 1
end sub


sub inp prmpt$, byref var$   'input
'prints prompt at lastC, lastR and leaves lastC = 1 lastR = pRow + 1

    inkee$ = "" 'clear last key (new fix for DE5)
    call lp lastC, lastR, prmpt$;"{"
    'this will update lastR and lastC to the starting point of input variable
    pRow = lastR : pCol = lastC 'save these for redrawing var
    call lp pCol, pRow, "}"
    OK$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
    OK$ = OK$+ chr$(8)+ chr$(27) + chr$(13) + "1234567890!@#$%^&*()_-+={}[]|\:;'<,>.?/"
    do
        scan
        if instr(OK$, inkee$) then
            if inkee$ = Chr$(8) then
                if t$ <> "" then
                    if Len(t$)=1 then t$="" else t$=Left$(t$,Len(t$)-1)
                end if
            else
                if inkee$=Chr$(13) or inkee$=Chr$(27) then
                    'new D5, I was expecting nothing in return for my esc
                    if inkee$ = chr$(27) then t$ = ""
                    exit do
                else
                    t$=t$;inkee$
                end if
            end if
            call lp pCol, pRow, t$;"} "
            inkee$ = ""
        end if
    loop until done
    var$ = t$
    lastC = 1 : lastR = pRow + 1
end sub

sub at xPix, yPix, char$  'print a string at pixel x, y This pin point locating.
    #gr "place ";xPix;" ";yPix
    #gr "|";char$ 
end sub

sub pause mil   'tsh version has scan built-in
    t0 = time$("ms")
    while time$("ms") < t0 + mil : scan : wend
end sub


 


Append: The reason why an entered string like "row, row, row your boat" won't appear is because it is too long for the cp sub along with the other text to fit on same line. So you do have to be careful of string lengths specially with LARGE PRINT.
« Last Edit: Sep 30th, 2017, 9:47pm by bplus » User IP Logged

B+
donjohnson24
Member in Training
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 20
xx Re: Adjusting program to suit display size
« Reply #17 on: Oct 3rd, 2017, 3:00pm »

on Sep 30th, 2017, 9:18pm, bplus wrote:
I may have just the thing:


I see you use INKEY$ - which I think does not work in a 'Window' - which I like for various reasons. Thank you for your suggestions, but, as explained below, I shall continue on my present path.

My problems with detecting entries were self-created, and arose because I failed to notice that statictext fields could be updated. I had assumed that I always had to use a textbox to display variable info', including some that I didn't want updated by the user. When my old brain cottoned on, I realised that a lot of the disable/enable commands could be eliminated - which pleased me because it meant that the displayed info' is no longer greyed out. As this program is meant to be viewed on a projected screen, and readable from the back of a fifty-foot hall, the larger and clearer the text the better.

So, after some major surgery, I think I now have a program that will work OK in its intended environment, and with minimum possibilities of operators thinking that their updates have taken effect when they haven't. The worst time for this to occur is in the main operating window that the punters view - 'Enter Bets and Show Tote' - where it is not possible to exit the window without pressing the 'Show Odds' button, which takes into account any changes entered under 'Update Bets'.

I'm still unable to get int the Archive, so I have posed the latest version to http://www.donjohnson24.co.uk/PalmDocs/ as RACENITE.bas (with RACENITE.DAT for some data). I did not bother to zip the files this time as the files are pretty small by today's standards.

I shall have to update the details about RACENITE on my website . . . . . .

User IP Logged

Don Johnson (not the Film Star!)
e-mail me: don@donjohnson24.co.uk
personal web: http://www.donjohnson24.co.uk
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1255
xx Re: Adjusting program to suit display size
« Reply #18 on: Oct 3rd, 2017, 3:28pm »

Quote:
I see you use INKEY$ - which I think does not work in a 'Window' - which I like for various reasons. Thank you for your suggestions, but, as explained below, I shall continue on my present path.


Hi Don,

No you did not see that! I did NOT use INKEY$

Yes, INKEY$ does not work in a graphic Window, so I have code that simulates it, along with the others that don't work PRINT, LOCATE, INPUT... all with code subs that simulate those functions.

I understand though because your eyesight may be going bad like mine and because when you get so far into doing the code thing your way, you don't want to see an easier approach!

As another demo of the simulated functions, I translated my mainwin (text only) Game of 21 into a LARGE PRINT version on a graphics Window using the set of simulated functions. It does not use any buttons, textboxes or other controls, it just uses the simulation subs.
http://justbasic.conforums.com/index.cgi?board=games&action=display&num=1506835419

PS It is right to learn how to use the controls first unless you are just looking for a quick one-off kind of thing.
« Last Edit: Oct 3rd, 2017, 3:36pm by bplus » User IP Logged

B+
donjohnson24
Member in Training
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 20
xx Re: Adjusting program to suit display size
« Reply #19 on: Oct 4th, 2017, 5:48pm »

on Oct 3rd, 2017, 3:28pm, bplus wrote:
I understand though because your eyesight may be going bad like mine and because when you get so far into doing the code thing your way, you don't want to see an easier approach!



I guess you've hit the nail on the head, (twice) there!

But, thanks for your interest and suggestions.
User IP Logged

Don Johnson (not the Film Star!)
e-mail me: don@donjohnson24.co.uk
personal web: http://www.donjohnson24.co.uk
Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls