Also note, this may only work in full-screen mode, not for a console
in a window.
------------------
Tom Hanlin
PowerBASIC Staff
Announcement
Collapse
No announcement yet.
PSTRING problem
Collapse
X
-
Guest repliedSeems to be a Windows or PB problem. In my system (Windows 2000 SP2), sometimes appears as brown and sometimes as pale yellow. The other colors, e.g. 15 (bright white), work fine.
It also works using assembler to print the string:
Code:DECLARE FUNCTION GetStrLoc(BYVAL AllocHandle%) AS LONG DECLARE SUB AsmPrint(BYVAL Row%,BYVAL Col%,BYVAL Txt$, BYVAL Attr%) ' ========================================================================= SUB AsmPrint( BYVAL Row AS INTEGER,_ BYVAL Col AS INTEGER,_ BYVAL Txt AS STRING,_ BYVAL Attr AS INTEGER) PUBLIC DIM pvScrnSeg AS INTEGER '-- Video memory segment pvScrnSeg% = &HB800 '-- Color monitor ! push ds ; Save data segment in the stack ! mov ax,DS: pvScrnSeg% ! mov es,ax ! mov ax,Txt$ ; Get the string handle ! push ax ; ! call getstrloc ; Get string length in cx ! jcxz AsmPrintDone ; IF CX = 0 THEN GOTO AsmPrintDone ! mov ds,dx ; String segment ! mov si,ax ; String offset ' Calculates offset of the video memory ! mov ax,Row% ; Line ! dec al ; Zero based ! mov bl,160 ; 80 cols * 2 bytes each ! mul bl ; AX = ( Row? -1 ) * 160 ! mov bx,Col% ; Column ! dec bl ; Zero based ! shl bx,1 ; BX = BX * 2 ! add ax,bx ; ! mov di,ax ; Video memory segment offset ! mov ax,Attr% ; Color attribute ! mov ah,al ; Stores it in AH AsmPrintLoop: ! lodsb ; Get string character in AL ! stosw ; Write character & color attribute ! loop AsmPrintLoop ; LOOP UNTIL CX=0 AsmprintDone: ! pop ds ; Restore data segment END SUB ' ========================================================================= sub BlinkOff ! xor BL, BL ! mov AX, &h1003 ! int &h10 end sub sub BlinkOn ! mov BL, 1 ! mov AX, &h1003 ! int &h10 end sub cls call BlinkOff DIM a AS STRING a$ = "Blue on yellow" color 1, 14 locate 8, 10 print a$ AsmPrint 10, 10, a$, &HE1
------------------
[This message has been edited by JOSE ROCA (edited May 07, 2003).]
Leave a comment:
-
Jose-
I copied your example. It is *much* shorter than the routine I
have. When I tried it, I didn't get the bright colors. The print
statement:
PRINT "Blue on yellow"
results in "Blue on yellow" with a blue characters and brown
background. I am using PB 3.5 for Dos. Do I have the wrong
version of PB for this work?
Thank you.
Robert
------------------
Leave a comment:
-
Guest repliedTo get bright background colors in DOS disallow blinking and use 8 to 15 as the background color.
Code:SUB BlinkOff ! xor BL, BL ! mov AX, &H1003 ! int &H10 END SUB SUB BlinkOn ! mov BL, 1 ! mov AX, &H1003 ! int &H10 END SUB
Code:BlinkOff COLOR 1, 14 PRINT "Blue on yellow"
------------------
[This message has been edited by JOSE ROCA (edited May 07, 2003).]
Leave a comment:
-
While we are on this topic, I've been looking for a way to
have bright colors as a background in plain text mode for
some time. To my understanding it is not possible, although
with some cards blinking text is made with a bright background
I read somewhere. And a neat little screen drip screensaver I
made using assembly and scrolling random parts of the screen
concentrated in the center while changing the background color
has weird effects in Windows DOS boxes like bright backgrounds, etc.
If anyone knows how to get bright backgrounds, let me know. I've seen
one program written in Quick BASIC use them, along with Q & Quick BASIC
allowing you to select them as colors in the editor. If I recall Turbo
Pascal or another language had some interesting screen and palette effects
not possible in BASIC as well.
Originally posted by Robert Carneal:
Tom-
PSTRING is a subroutine. This subroutine allows me to make use
of the bright colors as a background color. I thought I got
this from PowerBasic's downloads.
And what exactly do you mean by "it does not want to allow
this"?
I mean when I use variables containing a color number, say
FGC=5 for example, it acts as if it cannot see the value. Since
Since there is no "value," it works as if I had used 0 (zero).
Do you get an error message (if so, what?)
No, there is no error message. The program finishes.
does the program not work (if so, how?)
The program does not work in the fact the the desired color does
not get printed. Just black (0- zero) gets printed.
hmm, I do not see a copyright, but may I post the code? It is 23
lines long, not long at all.
Thank you, Tom.
------------------
If you aim at nothing...you will hit it.
Leave a comment:
-
Tom-
Thank you. I have been more sensitive to the Copyright now
that I am also doing volunteer tech support. I have a list of
items I cannot copy from the company, and what to say instead.
So, PString didn't come from PB/DOS Downloads? Ok, I have made
tons of paper notes and probably have it written down where I
got it, if I can find the notes. If I do find them, I will tell
you where I found it.
I remember I found this routine while searching for something
that would allow me to use the Bright colors as a background
color, if that presents a clue.
I am willing have this thread closed, if you want, as I am no
longer actively looking for the answer.
Thank you.
[This message has been edited by Robert Carneal (edited May 06, 2003).]
Leave a comment:
-
A scan for PSTRING on the Forums and in the PB/DOS Downloads doesn't
show any obvious candidates. Unfortunately, without knowing where it
came from, we can't know what copyright restrictions (if any) might
be involved. Best not to post it here, then.
Best guess is a type mismatch. Under the right circumstances, you
could run into trouble if, say, BClr is defined as single precision
and the routine is expecting an integer.
------------------
Tom Hanlin
PowerBASIC Staff
Leave a comment:
-
Tom-
PSTRING is a subroutine. This subroutine allows me to make use
of the bright colors as a background color. I thought I got
this from PowerBasic's downloads.
And what exactly do you mean by "it does not want to allow
this"?
I mean when I use variables containing a color number, say
FGC=5 for example, it acts as if it cannot see the value. Since
Since there is no "value," it works as if I had used 0 (zero).
Do you get an error message (if so, what?)
No, there is no error message. The program finishes.
does the program not work (if so, how?)
The program does not work in the fact the the desired color does
not get printed. Just black (0- zero) gets printed.
hmm, I do not see a copyright, but may I post the code? It is 23
lines long, not long at all.
Thank you, Tom.
------------------
Leave a comment:
-
Please tell us more. Where does PSTRING come from? And what exactly
do you mean by "it does not want to allow this"? Do you get an error
message (if so, what?) or does the program not work (if so, how?)
------------------
Tom Hanlin
PowerBASIC Staff
Leave a comment:
-
I have made a work-around, and can continue. I can use QPRINT
and achieve what I am looking for.
However, I still would appreciate knowing the answer to my
original inquiry.
Thanks.
------------------
Leave a comment:
-
PSTRING problem
I am having a PSTRING problem- can anyone help please?
This statement works:
PutUp$="F1 First":CALL PSTRING(15,2,PutUp$,15,9)
No problem there. It prints "F1 First F7 First in List" in
Bright White on a blue background.
However, if I want to:
PutUp$="F1 First":CALL PSTRING(15,2,PutUp$,15,BClr)
{Assume BClr is any 0 - 14}
It does not want to allow this.I would like to be
able to control my color for emphasis. I am under the impression
it should allow me to use variables so I can print that line
with any color (almost) anywhere on the screen. Does it behave
like that? If so, what I am doing wrong?
I am using PB 3.5 for Dos, and my OS is Win ME.
Thank you.
[This message has been edited by Robert Carneal (edited May 05, 2003).]Tags: None
Leave a comment: