home *** CD-ROM | disk | FTP | other *** search
- program demo;
-
- {----------------------------------------------------------}
- {- -}
- {- Global type delcarations required for the procedures: -}
- {- -}
- {- ColorMsg -}
- {- WaitMsg -}
- {- WriteSt -}
- {- WriteStLn -}
- {- -}
- {----------------------------------------------------------}
-
- Type
- Str255 = String[255];
- Str2 = String[2];
- TCSet = Set of 0..255;
-
-
- {----------------------------------------------------------}
- {- -}
- {- External procedure declarations -}
- {- -}
- {----------------------------------------------------------}
-
- Procedure BoarderColor(Color : Integer); External 'V1.ENH';
- Procedure ClrWin; External 'V2.ENH';
- Procedure ColorMsg(X,Y,Color : Integer; Message : Str255); External 'V3.ENH';
- Procedure FillCol(X,Y,Num : Integer; Ch : Char); External 'V4.ENH';
- Procedure FillColAttrib(X,Y,Num,Color : Integer); External 'V5.ENH';
- Procedure FillRow(X,Y,Num : Integer; Ch : Char); External 'V6.ENH';
- Procedure FillRowAttrib(X,Y,Num,Color : Integer); External 'V7.ENH';
- Procedure FrameWin(UL,UR,LL,LR,Hor,Ver : Char); External 'V8.ENH';
- Procedure GetScrn(X,Y,NumChars : Integer; Var ChArray); External 'V10.ENH';
- Procedure GotoXYAbs(X,Y : Integer); External 'V12.ENH';
- Procedure InitVideo(Mode : Integer); External 'V13.ENH';
- Procedure PutScrn(X,Y,NumChars : Integer; Var ChArray); External 'V14.ENH';
- Procedure RvsVideo; External 'V15.ENH';
- Procedure ScrollDn(Lines,Color,X1,Y1,X2,Y2 : Integer); External 'V16.ENH';
- Procedure ScrollLeft(Columns,Color,X1,Y1,X2,Y2 : Integer); External 'V17.ENH';
- Procedure ScrollUp(Lines,Color,X1,Y1,X2,Y2 : Integer); External 'V18.ENH';
- Procedure ScrollRight(Columns,Color,X1,Y1,X2,Y2 : Integer); External 'V19.ENH';
- Procedure SetCursorSize(StartLine,EndLine : Integer); External 'V20.ENH';
- Procedure WaitMsg(X,Y : Integer; Msg : Str255;
- TESet : TCSet; Var TC : Str2); External 'V21.ENH';
- Procedure WriteSt(St : Str255); External 'V24.ENH';
- Procedure WriteStLn(St : Str255); External 'V25.ENH';
-
- Function GetCursorSize : Integer; External 'V9.ENH';
- Function GetVideoMode : Integer; External 'V11.ENH';
- Function WhereXAbs : Integer; External 'V22.ENH';
- Function WhereYAbs : Integer; External 'V23.ENH';
-
- {----------------------------------------------------------}
- {- Global type and variable declarations for demo program -}
- {----------------------------------------------------------}
-
- Var
- Done : Boolean;
- Ch : Char;
-
-
- Procedure DoBoarderColor;
- Var
- Color : Integer;
- Begin
- Repeat
- ClrScr;
- WriteStLn('Enter a value from 0-15 to see a boarder color');
- WriteSt('Enter a value >15 to quit ');
- Readln(Color);
- BoarderColor(Color);
- Until (Color < 0) Or (Color > 15);
- BoarderColor(0);
- End;
-
- Procedure DoColorMsg;
- Var
- i : Integer;
- Begin
- For i := 1 To 20 Do
- ColorMsg(10,i,i,'This is a message using color');
- ColorMsg(10,24,7,'Press [ENTER] to continue');
- Readln;
- End;
-
- Procedure DoFillCol;
- Var
- i,j,k : Integer;
- Begin
- j := 1;
- repeat
- ColorMsg(41,4,48,' ');
- ColorMsg(41,5,48,' Enter a value (1-40) to display ');
- ColorMsg(41,6,48,' a column of characters. ');
- ColorMsg(41,7,48,' ');
- ColorMsg(41,8,48,' Any value not in range will exit ');
- ColorMsg(41,9,48,' ');
- GotoXYAbs(41,10);
- ClrEol;
- Readln(i);
- FillCol(i,1,25,Chr(64+j));
- If (i > 0) And (i < 41) Then Begin
- ColorMsg(41,4,48,' ');
- ColorMsg(41,5,48,' Enter a value (0-255) to display ');
- ColorMsg(41,6,48,' the color for the column of chars.');
- ColorMsg(41,7,48,' ');
- ColorMsg(41,8,48,' Any value not in range will exit ');
- ColorMsg(41,9,48,' ');
- GotoXYAbs(41,10);
- ClrEol;
- Readln(k);
- FillColAttrib(i,1,25,k);
- j := j + 1;
- End
- Else
- j := 26;
- Until (i < 0) Or (i > 40) Or (j > 25) Or (k < 0) Or (k > 255);
- End;
-
- Procedure DoFillRow;
- Var
- i,j,k : Integer;
- Begin
- j := 1;
- repeat
- ColorMsg(41,18,48,' ');
- ColorMsg(41,19,48,' Enter a value (1-25) to display ');
- ColorMsg(41,20,48,' a row of characters. ');
- ColorMsg(41,21,48,' ');
- ColorMsg(41,22,48,' Any value not in range will exit ');
- ColorMsg(41,23,48,' ');
- GotoXYAbs(41,24);
- ClrEol;
- Readln(i);
- FillRow(1,i,80,Chr(64+j));
- If (i > 0) And (i < 26) Then Begin
- ColorMsg(41,18,48,' ');
- ColorMsg(41,19,48,' Enter a value (0-255) to display ');
- ColorMsg(41,20,48,' the color for the row of chars. ');
- ColorMsg(41,21,48,' ');
- ColorMsg(41,22,48,' Any value not in range will exit ');
- ColorMsg(41,23,48,' ');
- GotoXYAbs(41,24);
- ClrEol;
- Readln(k);
- FillRowAttrib(1,i,80,k);
- j := j + 1;
- End
- Else
- j := 26;
- Until (i < 0) Or (i > 25) Or (j > 25) Or (k < 0) Or (k > 255);
- End;
-
- Procedure DoFrameWin;
- Var
- i,j : Integer;
- Begin
- For i := 1 To 10 Do Begin
- Window(i,i,80-i,25-i);
- FrameWin('┌','┐','└','┘','─','│');
- ClrWin;
- GotoXY(1,1);
- For j := 1 to 20 do
- Writeln('This is window ',i:1);
- Writeln('Press [ENTER] to continue... ');
- Readln;
- End;
- Window(1,1,80,25);
- End;
-
- Procedure DoCursorSize;
- Var
- i : Integer;
- Done : Boolean;
- Begin
- Repeat
- ClrScr;
- WriteStLn('This routine demonstrates 3 Cursor sizes');
- WriteStLn('for use with the color/graphic adapter');
- WriteStLn(' ');
- WriteStLn(' 0 - Normal');
- WriteStLn(' 1 - Large');
- WriteStLn(' 2 - Hidden');
- WriteStLn(' ');
- WriteStLn('Enter a value (0-3) for the size cursor you want ');
- WriteSt('Enter any value outside range to exit ');
- Readln(i);
- Case i Of
- 0 : SetCursorSize(7,6);
- 1 : SetCursorSize(7,0);
- 2 : SetCursorSize(32,32);
- Else
- Done := True;
- End;
- WriteStLn(' ');
- WriteStLn('The new cursor scan lines are:');
- WriteStLn(' ');
- WriteStLn(' Start Scan Stop Scan');
- WriteStLn(' ---------- ---------');
- i := GetCursorSize;
- Writeln(Hi(i):7,Lo(i):17);
- WriteStLn(' ');
- WriteStLn('Press [ENTER] to continue... ');
- Readln;
- Until Done;
- End;
-
- Procedure DoScrn;
- Var
- CA2 : Array[1..640] Of Char;
- TC : Str2;
- Begin
- WriteStLn('This is line 1 of the screen. This line and the next 3 lines');
- WriteStLn('will be read from the screen and placed on lines 15-18');
- WriteStLn('All you will have to do is press the [ENTER] key to continue');
- WriteStLn('thru this procedure.');
- Readln;
- GetScrn(1,1,320,CA2);
- WaitMsg(1,6,
- 'The screen has been read. Press [ENTER] to continue... ',[13],TC);
- PutScrn(1,15,320,CA2);
- WaitMsg(1,7,'Press [ENTER] to exit this procedure',[13],TC);
- End;
-
- Procedure DoRvsVideo;
- Var
- TC : Str2;
- Begin
- WriteLn('This is how text is displayed before RvsVideo');
- WaitMsg(1,5,'Press [ESC] to continue...',[1],TC);
- RvsVideo;
- WriteLn('This is how text is displayed after RvsVideo');
- WaitMsg(1,5,'Press [ESC] to continue...',[1],TC);
- RvsVideo;
- End;
-
- Procedure DoScroll;
- Var
- i : Integer;
- Ch : Char;
- Begin
- ClrScr;
- WriteStLn(' We will be scrolling the contents of window');
- WriteStLn(' either one column or row at a time');
- WriteStLn(' ');
- WriteStLn(' L - Scroll Left one column');
- WriteStLn(' R - Scroll Right one column');
- WriteStLn(' U - Scroll Up one row');
- WriteStLn(' D - Scroll Down one row');
- WriteStLn(' Q - Quit and return to menu');
- WriteStLn(' Press key for desired action');
- Window(48,1,80,25);
- FrameWin('┌','┐','└','┘','─','│');
- For i := 49 To 79 Do
- FillCol(i,2,23,Chr(i+16));
- Repeat
- Read(Kbd,Ch);
- Ch := UpCase(Ch);
- Case Ch Of
- 'L' : ScrollLeft (1,48,49,2,79,24);
- 'R' : ScrollRight(1,48,49,2,79,24);
- 'U' : ScrollUp (1,0 ,49,2,79,24);
- 'D' : ScrollDn (1,0 ,49,2,79,24);
- End;
- Until Ch = 'Q';
- Window(1,1,80,25);
- End;
-
- Procedure DoCursorPos;
- Var
- x,y : Integer;
- Begin
- Window(54,9,80,14);
- FrameWin('┌','┐','└','┘','─','│');
- Repeat
- ClrWin;
- ColorMsg(55,10,6,' ');
- ColorMsg(55,11,6,'Enter Column (1-40) ');
- ColorMsg(55,12,6,' ');
- GotoXYAbs(75,11);
- Readln(x);
- ColorMsg(55,12,11,'Enter Row (1-25) ');
- GotoXYAbs(72,12);
- Readln(y);
- GotoXYAbs(x,y);
- y := WhereXAbs;
- x := WhereYAbs;
- ClrWin;
- ColorMsg(55,11,1,'Press [ENTER] to continue');
- Readln;
- ClrScr;
- GotoXY(1,1);
- Writeln('The absolute column = ',y:1);
- Writeln('The absolure row = ',x:1);
- ColorMsg(55,13,1,'Press [ENTER] to continue');
- GotoXYAbs(y,x);
- Readln;
- Until (x > 40) Or (x < 1) Or (y > 25) Or (y < 1);
- Window(1,1,80,25);
- End;
-
- Procedure DoVideoModes;
- Var
- i,j : Integer;
- TC : Str2;
- Begin
- i := GetVideoMode;
- Gotoxy(5,10);
- Case i of
- 0..6 : WriteStln('You have a color/graphics adapter card installed');
- 7 : WriteStln('You use a monochrome monitor on your system');
- Else
- WriteStln('Enhance graphics adapter card installed?');
- End;
- Writeln;
- WriteStLn('Press [ENTER] to continue...');
- Readln;
- Writeln;
- WriteStln('Enter a value (0-7) for initializing a video mode');
- Readln(j);
- InitVideo(j);
- j := GetVideoMode;
- InitVideo(i);
- WriteSt('I initialized the video mode to number ');
- Writeln(j:1);
- WriteStln('I also returned you to the mode you were in before');
- WriteStln('I printed out the above statement.');
- WriteStln(' ');
- WaitMsg(1,25,'Press [ESC] to continue...',[1],TC);
- End;
-
- Begin
- Done := False;
- Repeat
- ClrScr;
- WriteStLn(' This menu is displayed using WriteStLn');
- WriteStLn(' ');
- WriteStLn(' Press a letter for the procedures to demonstrate');
- WriteStLn(' ');
- WriteStLn(' A. BoarderColor, WriteSt');
- WriteStLn(' B. FillCol, FillColAttrib, ColorMsg');
- WriteStLn(' C. FillRow, FillRowAttrib, ColorMsg');
- WriteStLn(' D. FrameWin, ClrWin');
- WriteStLn(' E. GetCursorSize, SetCursorSize');
- WriteStLn(' F. GetScrn, PutScrn');
- WriteStLn(' G. RvsVideo');
- WriteStLn(' H. ScrollLeft, ScrollRight, ScrollUp, ScrollDn');
- WriteStLn(' I. GotoXYAbs, WhereXAbs, WhereYAbs');
- WriteStLn(' J. InitVideo, GetVideoMode');
- WriteStLn(' ');
- WriteStLn(' K. Quit this demo');
- WriteStLn(' ');
- Read(Kbd,Ch);
- Ch := UpCase(Ch);
- ClrScr;
- Case Ch Of
- 'A' : DoBoarderColor;
- 'B' : DoFillCol;
- 'C' : DoFillRow;
- 'D' : DoFrameWin;
- 'E' : DoCursorSize;
- 'F' : DoScrn;
- 'G' : DoRvsVideo;
- 'H' : DoScroll;
- 'I' : DoCursorPos;
- 'J' : DoVideoModes;
- 'K' : Done := True;
- End;
- Until Done;
- ClrScr;
- End.