Main
   Home
   About
   DiscussionBoard
Files
   About
   Submit
   Search
Downloads
   Action
   QB64
Links
   Link to us
QB45.org
[ Back to QB45 | FAQ | Search a message | Reply to this message | Back to messages ]

gablea on 08/07/11 - 17:16:42

Hi all,

I know I have posted a few question with in the last few days but these are things that I JUST can not figure out.

I want to display large text on the screen (to show the user what change to give back) and I have defined the "numbers" at start up.

but when I display the numbers the first line is located correctly but then the other lines are not.

Example
I have done this to make a large number 1

Large_1 = Large_1 + " █ " + chr$(13)
Large_1 = Large_1 + "██ " + chr$(13)
Large_1 = Large_1 + " █ " + chr$(13)
Large_1 = Large_1 + " █ " + chr$(13)
Large_1 = Large_1 + "███"

when I display the number using locate 10,20: Print Large_1 I get

█
██
█
█
███

how do I display the number in the right location?

Andy


gablea on 08/07/11 - 17:17:38

please ignore the &#9608 in the message about they should be Alt + 219 (works in the DOS app file)

Cyperium on 08/10/11 - 12:08:50

It's the CHR$(13) that is the cause for this behaviour I think.

Instead you could store the big 1 in a array of strings.

Like this:



one$(0) = chr$(32) + chr$(219)
one$(1) = chr$(219) + chr$(219)
one$(2) = chr$(32) + chr$(219)
one$(3) = chr$(32) + chr$(219)
one$(4) = chr$(219) + chr$(219) + chr$(219)

for showone = 0 to 4
LOCATE showone + 10, 10: print one$(showone)
next


Tested and works, if you want I'll make automatic bigfont functions for you, you could for example scan each letter in graphics mode using POINT to get every letter in such arrays and then have a function that displays them at the specified locations (or displays a string of them if you like).

Cyperium on 08/10/11 - 12:37:13

I made a function for you:



DIM SHARED font(256, 9) AS STRING

initfont

displayfont "hello", 5, 1
'syntax: displayfont text$, ylocation, xlocation

SUB initfont
SCREEN 13
FOR k = 0 TO 255
CLS
IF k <> 7 AND k <> 8 AND k <> 9 AND k <> 10 AND k <> 11 AND k <> 12 AND k <> 13 AND k <> 28 AND k <> 29 AND k <> 30 AND k <> 31 THEN
LOCATE 1, 1: PRINT CHR$(k)
END IF

FOR yfont = 0 TO 8
font(k, yfont) = SPACE$(9)
FOR xfont = 0 TO 8
IF POINT(xfont, yfont) <> 0 THEN MID$(font(k, yfont), xfont + 1, 1) = CHR$(219)
NEXT
NEXT
NEXT
SCREEN 2
SCREEN 0
END SUB

SUB displayfont (text$, yloc, xloc)
xrel = 0
IF LEN(text$) THEN
FOR letter = 1 TO LEN(text$)
FOR fontrows = 0 TO 8

LOCATE yloc + fontrows, xloc + xrel
PRINT font(ASC(MID$(text$, letter, 1)), fontrows)

NEXT
xrel = xrel + 8
NEXT
END IF
END SUB



It might be memory consuming though as it uses many strings for the array.

Cyperium on 08/10/11 - 13:13:45

In this version you can set a "smaller" variable to 1 to get slightly smaller text, it works best for numbers though, set smaller to 0 if you want the bigger text.


DIM SHARED font(256, 9) AS STRING
DIM SHARED smaller
smaller = 1
initfont

displayfont "1234567890", 5, 1
'syntax: displayfont text$, ylocation, xlocation

SUB initfont
SCREEN 13
FOR k = 0 TO 255
CLS
IF k <> 7 AND k <> 8 AND k <> 9 AND k <> 10 AND k <> 11 AND k <> 12 AND k <> 13 AND k <> 28 AND k <> 29 AND k <> 30 AND k <> 31 THEN
LOCATE 1, 1: PRINT CHR$(k)
END IF
yfpos = 0
FOR yfont = 0 TO 8
font(k, INT(yfpos)) = SPACE$(9)
xfpos = 0
FOR xfont = 0 TO 8
IF POINT(INT(xfont), yfont) <> 0 THEN MID$(font(k, INT(yfpos)), INT(xfpos) + 1, 1) = CHR$(219)
IF smaller = 0 THEN xfpos = xfpos + 1 ELSE xfpos = xfpos + .6
NEXT
IF smaller = 0 THEN yfpos = yfpos + 1 ELSE IF yfont <> 1 AND yfont <> 5 THEN yfpos = yfpos + 1
NEXT
NEXT
SCREEN 2
SCREEN 0
END SUB

SUB displayfont (text$, yloc, xloc)
xrel = 0
IF LEN(text$) THEN
FOR letter = 1 TO LEN(text$)
FOR fontrows = 0 TO 8

LOCATE yloc + fontrows, xloc + xrel
PRINT font(ASC(MID$(text$, letter, 1)), fontrows)

NEXT
IF smaller = 0 THEN xrel = xrel + 8 ELSE xrel = xrel + 5
NEXT
END IF
END SUB



TopGun on 08/13/11 - 11:33:07

LOL I tried your code, pretty cool :) never thought of doing it that way :D

Cyperium on 08/15/11 - 12:13:13

Thanks :)

Cyperium on 08/20/11 - 05:10:43

There's large fonts routines here:
Graphics Font

They are designed to work in graphics mode though.

Reply to this message
Name:
Message:
Please enter this number:
No HTML allowed. You may use BB-code in your posting.
Members
Login
Register
QB45 Members
Member List