_TITLE "Get Your Pizza Here" 'by Steve McNeill mods by B+ copied and mod 2019-08-11 ' 2019-08-10 bplus wants to try out a pizza ordering menu for a resturant app
' Testing my Mesage Box with Steve's SaveState and RestoreState procedures works!
' ??????????????????????????? every now and again a miniture but fully fuctional screen comes up ???????????
CONST Skyblue~&
= &HFF87CEEB CONST Gold~&
= &HFFFFD700 CONST Black~&
= &HFF000000 CONST LightGray~&
= &HFFD3D3D3
choices
AS INTEGER 'from 0 to choices, so subtract 1 from total number of choices captions
AS STRING ' "12345678901234567890" --10 spaces per choice, so the left would represent two choices
nOptions = 3
DIM mArray
(7) AS STRING * 10, i
, j
, menu$
, mx
, my
, kh
, o
, total!
, ttl$
mArray(0) = "Pepperoni"
mArray(1) = "Sausage"
mArray(2) = "Onion"
mArray(3) = "Mushroom"
mArray(4) = "Peppers"
mArray(5) = "X Cheese"
mArray(6) = "X Sauce"
mArray(7) = "Anchovies"
FOR i
= 0 TO 7 'build captions string menu$ = menu$ + mArray(i)
' 10 chars captions fixed length string*10 Really only nine characters fit
Options(1).x = 20: Options(1).y = 50: Options(1).high = 50: Options(1).wide = 150 '1 is mode
Options(1).choices = 7: Options(1).captions = menu$
Options
(1).Font
= F15: Options
(1).clicks
= STRING$(Options
(1).choices
+ 1, "0") 'rnd selected as default 'b+??????????????
Options(2).x = 470: Options(2).y = 150: Options(2).high = 50: Options(2).wide = 150
Options(2).choices = 1: Options(2).captions = "Total Up"
Options(2).Font = F15: Options(2).clicks = "00"
mArray(0) = "Cash"
mArray(1) = "Amer Expr"
mArray(2) = "Mastercar"
mArray(3) = "Discover"
mArray(4) = "Chase"
mArray(5) = "Citi"
mArray(6) = "VISA"
mArray(7) = "Bplus Tab"
menu$ = ""
FOR i
= 0 TO 7 'build captions string menu$ = menu$ + mArray(i)
Options(3).x = 20: Options(3).y = 250: Options(3).high = 50: Options(3).wide = 150 '1 is mode
Options(3).choices = 7: Options(3).captions = menu$
Options
(3).Font
= F15: Options
(3).clicks
= STRING$(Options
(1).choices
+ 1, "0")
COLOR &HFFFFFF00, &HFF000000 DisplayOptions
getClick mx, my, kh
'which button if any was pressed
FOR i
= 0 TO Options
(o
).choices
IF mx
> Options
(o
).x
+ i
* Options
(o
).wide
AND mx
< Options
(o
).x
+ (i
+ 1) * Options
(o
).wide
THEN IF my
> Options
(o
).y
AND my
< Options
(o
).y
+ Options
(o
).high
THEN 'ok we're in now what? togggle choice i
Options(2).captions = "Total Up "
total! = 0
Options(2).clicks = "00"
MID$(Options
(o
).clicks
, i
+ 1, 1) = "0" MID$(Options
(o
).clicks
, i
+ 1, 1) = "1" total! = 9.39
CASE 1:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ 2.20 CASE 2:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ 2.40 CASE 3:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ .40 CASE 4:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ .70 CASE 5:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ .90 CASE 6:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ 1.20 CASE 7:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ .80 CASE 8:
IF MID$(Options
(1).clicks
, j
, 1) = "1" THEN total!
= total!
+ 25.50 Options
(2).captions
= "Total Up $" + _TRIM$(STR$(total!
)) IF total!
> 0 THEN Options
(2).clicks
= "11" Options
(3).clicks
= STRING$(Options
(3).choices
, "0") + "1" ttl$ = "Attention Payment Error"
CASE 0: mBox ttl$
, "Sorry, your money is no good here. Try Bplus Tab." CASE 1, 2, 3, 4, 5, 6: mBox ttl$
, "Your card has been declined. Try Bplus Tab." CASE 7: mBox
"Payment method approved", "Bplus says Hi, enjoy your pizza!" Options(2).captions = "Total Up "
total! = 0
Options(2).clicks = "00"
Options
(1).clicks
= STRING$(8, "0")
DIM s
, i
, x1
, y1
, w
, h
, clicks$
, j
, t$
s = SaveState
FOR i
= 1 TO nOptions
'3 option sets to display x1 = Options(i).x: y1 = Options(i).y
w = Options(i).wide: h = Options(i).high
clicks$ = Options(i).clicks
FOR j
= 0 TO Options
(i
).choices
t$
= _TRIM$(MID$(Options
(i
).captions
, j
* 10, 10)) COLOR Black
, 0: BoxTitle x1
+ j
* w
, y1
, w
, h
, 3, Skyblue
, Gold
, t$
COLOR LightGray
, 0: BoxTitle x1
+ j
* w
, y1
, w
, h
, 3, Black
, Gold
, t$
RestoreState s
Box x1, y1, x2, y2, thick, fg, bg
CenterText x1, y1 + thick, x1 + x2, y1 + y2 + thick, title$
LINE (x
+ i
, y
+ i
)-STEP(wide
- 2 * i
, high
- 2 * i
), Trim
, B
SUB CenterText
(x1
, y1
, x2
, y2
, text$
) DIM xmax
, ymax
, textlength
, xpos
, ypos
xmax = x2 - x1: ymax = y2 - y1
xpos = (xmax - textlength) / 2
'getClick returns the mouse x, y position WHEN THE MOUSE WAS RELEASED! or keypress ASC 27 or 32 to 125
'2019-08-06 Test now with new mBox and inputBox procedures
'found mBox needed a _KEYCLEAR, how about inputBox? OK had _KEYCLEAR already
mx = -1: my = -1: q = 0
'IF mb THEN
DIM SS
AS SaveStateType
, Temp
AS SaveStateType
, i
, O
'SHARED NSS AS LONG 'Number of Saved States
'SHARED SaveMem AS _MEM
SaveMem
= _MEMNEW(LEN(SS
) * 255) 'Save up to 255 save states; More than 255 and we toss an error
'Data to Save
SS.InUse = -1
_MEMGET SaveMem
, SaveMem.OFFSET
+ O
, Temp
_MEMPUT SaveMem
, SaveMem.OFFSET
+ O
, SS
SaveState = i
_MEMPUT SaveMem
, SaveMem.OFFSET
+ NSS
* LEN(SS
), SS
NSS = NSS + 1
SaveState = NSS
_MEMGET SaveMem
, SaveMem.OFFSET
+ (WhichOne
- 1) * LEN(SS
), SS
SS.InUse = 0 'Let the routine know that we're no longer in use for this handle
_MEMPUT SaveMem
, SaveMem.OFFSET
+ (WhichOne
- 1) * LEN(SS
), SS
'title$ limit is 57 chars, all lines are 58 chars max, version 2019-08-06
'THIS SUB NOW NEEDS SUB scnState(restoreTF) for saving and restoring screen settings
bg = &HFF000040
fg = &HFF33AAFF
'first screen dimensions and items to restore at exit
'screen and current settings to restore at end ofsub
'scnState 0
'try Steve saveState
State = SaveState
_KEYCLEAR '<<<<<<<<<<<<<<<<<<<< do i still need this? YES! 2019-08-06 update!
'screen snapshot
'setup t() to store strings with ti as index, linit 58 chars per line max, b is for build
'are there any new line signals, CR, LF or both? take CRLF or LFCR as one break but dbl LF or CR means blank line
tail = "": ff = 0
FOR j
= LEN(b
) TO 1 STEP -1 'backup until find a space, save the tail end for next line ff = 1 'found space flag
tail = d + tail 'the tail grows!
b = b + c 'just keep building the line
t(ti) = b
bxH = ti + 3: bxW = limit + 2
'draw message box
'now for the action
'convert to pixels the top left corner of box at moment
bxW = bxW * 8: bxH = bxH * 16
tlx = (sw - bxW) / 2: tly = (sh - bxH) / 2
lastx = tlx: lasty = tly
'now allow user to move it around or just read it
IF mx
>= tlx
AND mx
<= tlx
+ bxW
AND my
>= tly
AND my
<= tly
+ 16 THEN 'mouse down on title bar grabx = mx - tlx: graby = my - tly
IF mx
- grabx
>= 0 AND mx
- grabx
<= sw
- bxW
AND my
- graby
>= 0 AND my
- graby
<= sh
- bxH
THEN 'attempt to speed up with less updates
IF ((lastx
- (mx
- grabx
)) ^ 2 + (lasty
- (my
- graby
)) ^ 2) ^ .5 > 10 THEN tlx = mx - grabx: tly = my - graby
lastx = tlx: lasty = tly
'put things back
RestoreState State ' testing Steve's RestoreState
'scnState 1 'Thanks Steve McNeill
' try out Steve's saveState and RestoreState procedures inside mBox
'' for saving and restoring screen settins
'SUB scnState (restoreTF AS INTEGER) 'Thanks Steve McNeill
' STATIC Font AS LONG, DefaultColor AS _UNSIGNED LONG, BackGroundColor AS _UNSIGNED LONG, Dest AS LONG, Source AS LONG
' STATIC row AS INTEGER, col AS INTEGER, autodisplay AS INTEGER, mb AS INTEGER
' IF restoreTF THEN
' _FONT Font
' COLOR DefaultColor, BackGroundColor
' _DEST Dest
' _SOURCE Source
' LOCATE row, col
' IF autodisplay THEN _AUTODISPLAY ELSE _DISPLAY
' _KEYCLEAR
' WHILE _MOUSEINPUT: WEND 'clear mouse clicks
' mb = _MOUSEBUTTON(1)
' IF mb THEN
' DO
' WHILE _MOUSEINPUT: WEND
' mb = _MOUSEBUTTON(1)
' _LIMIT 100
' LOOP UNTIL mb = 0
' END IF
' ELSE
' Font = _FONT: DefaultColor = _DEFAULTCOLOR: BackGroundColor = _BACKGROUNDCOLOR
' Dest = _DEST: Source = _SOURCE
' row = CSRLIN: col = POS(0): autodisplay = _AUTODISPLAY
' END IF
'END SUB