Solved

two easy questions

Posted on 1998-10-15
3
202 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
3 Comments
 
LVL 1

Accepted Solution

by:
mlaiosa earned 110 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

867 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now