Solved

two easy questions

Posted on 1998-10-15
3
206 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

810 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