Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_printmode ???
#1
why doesn't this work?

Code: (Select All)
Screen _NewImage(400, 300, 32)
dm = _PrintMode
_PrintMode _KeepBackground
Print "X"
_printmode dm

this is a simplified example from what I was doing but it produces the same syntax error. I was able to get arround the problem but this is just annoying:

Code: (Select All)
Screen _NewImage(400, 300, 32)
dm = _PrintMode
_PrintMode _KeepBackground
Print "X"
Select Case dm
    Case 1
        _PrintMode _KeepBackground
    Case 2
        _PrintMode _OnlyBackground
    Case 3
        _PrintMode _FillBackground
End Select
Reply
#2
(10-10-2023, 07:36 PM)James D Jarvis Wrote: why doesn't this work?

Code: (Select All)
Screen _NewImage(400, 300, 32)
dm = _PrintMode
_PrintMode _KeepBackground
Print "X"
_printmode dm

this is a simplified example from what I was doing but it produces the same syntax error. I was able to get arround the problem but this is just annoying:

Code: (Select All)
Screen _NewImage(400, 300, 32)
dm = _PrintMode
_PrintMode _KeepBackground
Print "X"
Select Case dm
    Case 1
        _PrintMode _KeepBackground
    Case 2
        _PrintMode _OnlyBackground
    Case 3
        _PrintMode _FillBackground
End Select
_PRINTMODE does not accept a numeric value as a mode parameter, only _KEEPBACKGROUND, _ONLYBACKGROUND, and _FILLBACKGROUND.

I agree though, this seems like an oversight. If the _PRINTMODE function gives you a numeric value it should also allow a numeric value between 1 and 3 as a valid mode.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#3
You could use a function like this:

Code: (Select All)
CONST __REPORT = 0
CONST __KEEPBACKGROUND = 1
CONST __ONLYBACKGROUND = 2
CONST __FILLBACKGROUND = 3

SCREEN _NEWIMAGE(400, 300, 32)
dm = __PRINTMODE(__REPORT) '            or __PRINTMODE(0)
dummy = __PRINTMODE(__KEEPBACKGROUND) ' or __PRINTMODE(1)
PRINT "X"
dummy = __PRINTMODE(dm) '               restore previous print mode


FUNCTION __PRINTMODE (mode AS INTEGER)

    SELECT CASE mode
        CASE 0: __PRINTMODE = _PRINTMODE '   report current mode
        CASE 1: _PRINTMODE _KEEPBACKGROUND ' set modes
        CASE 2: _PRINTMODE _ONLYBACKGROUND
        CASE 3: _PRINTMODE _FILLBACKGROUND
    END SELECT

END FUNCTION
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply




Users browsing this thread: 1 Guest(s)