Link to home
Start Free TrialLog in
Avatar of gbzhhu
gbzhhuFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Reading in Grahpics mode

Hi

I am using Borland Pascal (DOS) version 7.0.  I wondered if it is possible to read from user while in graphics mode.  I mean just like Read and Readln in CRT mode.  If possible could anybody send example code.

Also anothe problem I have is I want to read a number from user, if I use integer or word and user presses a character the program will crash.  What is the best way to validate and make sure the program does not crash.

If answering please bear in mind that even though I do VB and C++ stuff, my Pascal knowledge is not that brilliant, therefore a little example code will help.

Thank you folks
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gbzhhu

ASKER

Hi Scrapdog

The validation part of your answer works brilliant for me, however, the graphics part, I was using InitGraph statement to initialise graphics and I was using OutTextXy to write something on screen, but did not know what to use in order to read something from user while still in graphics mode.  Now readln works, but I would like to move the cursor to the position I want (somewhere in the screen) and then use readln.

Can you please have a look at the problem and see if you can help.  Is there a the equivalent in graphics mode of the following

gotoxy(12,22); readln(something);


Also I did not understand dthe assembly lines which initialise graphics (first time I have ever seen) what happened to InitGraph;  I mean the only help file I have with my Pascal is crap -- do you know a better one?

thanks again
Let's see your source code.
Avatar of Motaz
Motaz

Unfortunately there is no equevelant to ( gotoxy, readln ) in graphic mode, so that you must make your own gotoxy, readln procedures using readkey and OutTextXy and read any thing as string.

Motaz from Sudan.
I've fucntion that read string in graphic mode called ReadStr, you can find it in my unit which exist in my homepage :

http://members.wbs.net/homepages/a/z/z/azzoz.html

The unit called MGR.pas, you will find many examples use that unit.

You can call that function as :

St:=ReadStr(200,100,'',30);

st : string;
200 : X-cordinate
100 : Y-cordinate
''     : initial value of string
30  : maximum length of string you want to read.

If you want to set a colour for text and background you can use :

Colour(14,1);  { Yellow in Blue }

Motaz.