Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

two easy questions

Posted on 1998-10-15
3
Medium Priority
?
215 Views
Last Modified: 2010-04-15
1. why doesn't the ascii character -> (right arrow) work.
   every ascii chart I have seen says that this is hex 1A
   but it will not work. I get the others to work but not    that one.
2 I am writing a dos program that has a menu. I have set up   borders around the menu no problem now I want to color the   menu. how do I color just the menu background and not the   whole screen.  
0
Comment
Question by:strmtrpr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
mlaiosa earned 440 total points
ID: 1253572
All the ascii charcters below 32 (0x20) have special meanings and for that reason, many of them cannot be displayed on the screen using standard out.  1A is one such charcter.  It is the End of FIle (EOF) charcter.

to display *any* ascii charcter on a display that is not MGA or HGC, and to set the color of any signal charcter, use the folowing: (I assume you are using TC for dos):

#include <dos.h>

void putchar(int x, int y, char c)
//puts the charcter c at x,y on the screen.
{
  *(char far *)MK_FP(0xb800,2*(y*80+x))=c;
}

char putchar(int x, int y)
//returns the charcter at x,y
{
  return *(char far *)MK_FP(0xb800,2*(y*80+x));
}

void setattr(int x, int y, int attr)
//set the attribute attr at x,y
{
  *(char far *)MK_FP(0xb800,2*(y*80+x)+1)=attr;
}

int getattr(int x, int y)
//get the attribute at x,y
{
  return *(char far *)MK_FP(0xb800,2*(y*80+x)+1);
}


for all those functions, the upper left corner of the screen is 0,0  They do not move the cursor, or care where it is.
valid attributes are 0x00 .. 0xff

the first hex digit is the background color and the second is the forground color.

I would reccomend doing some experiments to find what 0..f values generate what values and make some defines, ex:

#define black 0
#define blue 1
#define green 2
#define cyan 3

so that you could do stuf like:

putattr(5,15,(black<<4)+green);  //this will generate green on black
0
 

Author Comment

by:strmtrpr
ID: 1253573
thank you answering so quickly.

0
 
LVL 84

Expert Comment

by:ozo
ID: 1253574
Actually, ASCII calls it the Substitute (SUB) character
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question