home *** CD-ROM | disk | FTP | other *** search
- /*
- Read ScrEdit.Tut for a description of how to use this program.
- */
- #include <alloc.h>
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <ctype.h>
-
- /*
- Before you can compile this program you must use the OPTION/DIRECTORIES/INCLUDE
- and the OPTION/DIRECTORIES/LIBRARY to specifie the location on your system files, you must also specifie the location of the library menu.
- of SCREDIT.H and SCREDIT.C.
-
- Don't forget to specifie a the project files SCRDEMO.PRJ in the
- PROJECT/PROJECT FILE menu. You must place the drive, path, and file name
- in the project file:
-
- (COMPACT) Example: ScrDemo C:\Pascal\ScrEdit\ScrEdit.C
- (LARGE or
- HUGE) Example: ScrDemo C:\Pascal\ScrEdit\ScrEdit.Lib
-
- */
- #include "scredit.h"
-
- #include "SCRDEMO.001"
- #include "SCRDEMO.002"
-
- int Option,
- Screen_Mode,
- Cursor_Position;
-
-
- void Back_To_Turbo_C_Land()
- {
- char Response[11];
- Response[0] = 0;
-
- textbackground(BLACK);
- textcolor (YELLOW);
-
- while (strcmp("RETURN",Response)!= 0)
- {
- clrscr();
- cprintf("This is regular 'C' code now.\r\n\r\n");
- cprintf("You can do anything now that you want to, use any \r\n");
- cprintf("programming statement that you wish to. When you \r\n");
- cprintf("are ready to resume with Turbo ScrEdit just return \r\n");
- cprintf("and the screen will be reloaded and you will resume \r\n");
- cprintf("at the point where you left the screen.\r\n\r\n");
- cprintf("Type 'RETURN' in upper case to end this example...");
- Response[0]=6;
- cscanf("%s",Response);
- }
- textbackground(BLACK);
- textcolor (GREEN);
- }
-
- void ProcessScreen()
- {
- S_ShowStatus = 0;
- if (Screen_Mode==1)
- {
- Cursor_Position = Demo_Screen_buf.OP;
- switch (Cursor_Position){
- case 0 : {S_Point = S_FirstField;break;}
- case 1 : {S_Point = 1 ;break;}
- case 2 : {S_Point = 4 ;break;}
- case 3 : {S_Point = 11;break;}
- case 4 : {S_Point = 8 ;break;}
- }
- }
-
- if (Screen_Mode == 2)
- {
- Cursor_Position = Demo_Screen_buf.OP;
- S_Point ++;
- switch (Cursor_Position){
- case 0 :{S_Point = 0;
- break;
- }
- case 1 :{if ((S_Point > 3)|| (S_Point < 1)) S_Point = 1;
- break;
- }
- case 2 :{if ((S_Point > 9)||(S_Point < 4)) S_Point = 4;
- if (S_Point == 8) S_Point = 9;
- break;
- }
- case 3 :{if ((S_Point > 12)||(S_Point < 11)) S_Point = 11;
- break;
- }
- case 4 :{if ((S_Point > 10)||(S_Point < 8)) S_Point = 8;
- if (S_Point == 9) S_Point = 10;
- break;
- }
- }
- }
-
- strcpy(S_Msg," <F1>=Initialize <F2>=Return to Menu ");
-
- switch (Screen_Mode){
- case 2 : {S_ReadField() ;break;}
- case 1 : {S_ReadScreen() ;break;}
- }
-
- if (S_Fkey)
- {
- if ((!S_Shift)&&(!S_Ctrl)&&(!S_Alt))
- {
- if (S_F1)
- {
- Initialize_Demo_Screen_buf();
- S_Point = S_FirstField;
- strcpy(S_Msg,"Screen has been initialized.");
- }
- if (S_F2)
- S_LoadScreen("Demo_Menu");
- }
- }
- }
-
-
- void ScrDemo_Init()
- {
- S_OpenScreenFile("ScrDemo.SCR");
- Initialize_Demo_Menu_buf();
- Initialize_Demo_Screen_buf();
- Option = 1;
- S_Sound = 1;
- S_Cursor = S_NORMAL;/* other options S_BLOCK, S_OFF */
-
- textbackground(BLACK);
- textcolor (GREEN);
-
- S_LoadScreen("Demo_Menu");
- }
-
-
- void Read_Menu_Screen()
- {
- int X,Y,Z;
- S_ShowStatus = 1;
- while (!S_Esc)
- {
- memset(&Demo_Menu_buf,0,sizeof(Demo_Menu_buf));
-
- strcpy(Demo_Menu_buf.O1, "This Menu");
- strcpy(Demo_Menu_buf.O2, "Using S_ReadScreen");
- strcpy(Demo_Menu_buf.O3, "Using S_ReadField");
- strcpy(Demo_Menu_buf.O4, "Using S_ReadKey");
- strcpy(Demo_Menu_buf.O5, "Using S_NextKey");
- strcpy(Demo_Menu_buf.O6, "Using Windows");
- strcpy(Demo_Menu_buf.O7, "Using The Message Line");
- strcpy(Demo_Menu_buf.O8 ,"Mixed ScrEdit");
- strcpy(Demo_Menu_buf.O13,"Display remaining heap");
-
- if (Option < 1) Option = 9;
- if (Option > 9) Option = 1;
-
- switch (Option) {
- case 1 : {
- strcpy(Demo_Menu_buf.P1,"==>");
- strcpy(Demo_Menu_buf.M1,"To use this menu, have a listing of the");
- strcpy(Demo_Menu_buf.M2,"file SCRDEMO.C with you and follow");
- strcpy(Demo_Menu_buf.M3,"each of the examples through the 'C'");
- strcpy(Demo_Menu_buf.M4,"code. This program is designed to help");
- strcpy(Demo_Menu_buf.M5,"you understand how to implement Turbo");
- strcpy(Demo_Menu_buf.M6,"ScrEdit procedures in your programs.");
- break;
- }
- case 2 : {
- strcpy(Demo_Menu_buf.P2,"==>");
- strcpy(Demo_Menu_buf.M1,"S_ReadScreen - process an entire screen");
- strcpy(Demo_Menu_buf.M2,"with one call. Control returns to your ");
- strcpy(Demo_Menu_buf.M3,"program when ENTER, UP or DOWN arrows,");
- strcpy(Demo_Menu_buf.M4,"HOME, END, PGUP, PGDN, INSERT, DEL, one");
- strcpy(Demo_Menu_buf.M5,"the F keys, or any key is pressed in");
- strcpy(Demo_Menu_buf.M6,"conjuction with ALT or CTRL keys.");
- break;
- }
- case 3 : {
- strcpy(Demo_Menu_buf.P3,"==>");
- strcpy(Demo_Menu_buf.M1,"S_ReadField - Process a single screen");
- strcpy(Demo_Menu_buf.M2,"field at a time. Control returns to");
- strcpy(Demo_Menu_buf.M3,"your program when the cursor is moved");
- strcpy(Demo_Menu_buf.M4,"off of the field with the left or right");
- strcpy(Demo_Menu_buf.M5,"arrow keys, TAB key, or Any of the");
- strcpy(Demo_Menu_buf.M6,"other keys listed with S_ReadScreen.");
- break;
- }
- case 4 : {
- strcpy(Demo_Menu_buf.P4,"==>");
- strcpy(Demo_Menu_buf.M1,"S_ReadKey - This demonstrates how to");
- strcpy(Demo_Menu_buf.M2,"display a message on the message line");
- strcpy(Demo_Menu_buf.M3,"and accept a keystroke response from");
- strcpy(Demo_Menu_buf.M4,"the user. The key pressed does not");
- strcpy(Demo_Menu_buf.M5,"echo to the screen and will not be");
- strcpy(Demo_Menu_buf.M6,"placed in any screen field.");
- break;
- }
- case 5 : {
- strcpy(Demo_Menu_buf.P5,"==>");
- strcpy(Demo_Menu_buf.M1,"S_NextKey - This demonstrates how to");
- strcpy(Demo_Menu_buf.M2,"read the next key pressed only. No");
- strcpy(Demo_Menu_buf.M3,"message can be displayed. Turbo Scredit");
- strcpy(Demo_Menu_buf.M4,"waits for the next key pressed and");
- strcpy(Demo_Menu_buf.M5,"returns to your program.");
- break;
- }
- case 6 : {
- strcpy(Demo_Menu_buf.P6,"==>");
- strcpy(Demo_Menu_buf.M1,"A method of using windows to display");
- strcpy(Demo_Menu_buf.M2,"data on your screens and then restore");
- strcpy(Demo_Menu_buf.M3,"the screen to its original state.");
- break;
- }
- case 7 : {
- strcpy(Demo_Menu_buf.P7,"==>");
- strcpy(Demo_Menu_buf.M1,"Demonstrates several way of using");
- strcpy(Demo_Menu_buf.M2,"the message line to communicate with");
- strcpy(Demo_Menu_buf.M3,"the user of your program.");
- break;
- }
- case 8 : {
- strcpy(Demo_Menu_buf.P8,"==>");
- strcpy(Demo_Menu_buf.M1,"This demonstrates how you can exit a");
- strcpy(Demo_Menu_buf.M2,"procedure using a Turbo ScrEdit screen");
- strcpy(Demo_Menu_buf.M3,"to use your language's standard input");
- strcpy(Demo_Menu_buf.M4,"and output statements, and then resume");
- strcpy(Demo_Menu_buf.M5,"using Turbo ScrEdit when you wish.");
- break;
- }
- case 9 : {
- strcpy(Demo_Menu_buf.P13,"==>");
- strcpy(Demo_Menu_buf.M1,"Display the current remaining heap ");
- strcpy(Demo_Menu_buf.M2,"and farheap memory that has not ");
- strcpy(Demo_Menu_buf.M3,"been allocated.");
- break;
- }
- }
-
-
- S_ResetKeyFlags();
- while ((!S_Esc)&&(!S_Enter)&&(!S_Fkey))
- {
- S_ReadKey();
- if ((S_Up)||(S_Down)||(S_Enter)||(S_Esc))
- {
- if (S_Down) Option++;
- if (S_Up) Option--;
- if (S_Enter)
- {
- if (Option==1)
- strcpy(S_Msg,
- " Please read the text in the Option Description window.");
- if (Option == 2)
- {
- Screen_Mode = 1;
- Initialize_Demo_Screen_buf();
- S_LoadScreen("Demo_Screen");
- while (!S_F2) ProcessScreen();
- }
- if (Option == 3)
- {
- Screen_Mode = 2;
- Initialize_Demo_Screen_buf();
- S_LoadScreen("Demo_Screen");
- while (!S_F2) ProcessScreen();
- }
- if (Option == 4)
- {
- strcpy(S_Msg,
- "Demo of S_READKEY - Press 'C' key to continue");
- do{
- S_ReadKey();
- strcpy(S_Msg,
- "OOPS!! wrong key - Press 'C' key to continue");
- } while ((S_Ch!='C')&&(S_Ch!='c'));
-
- strcpy(S_Msg," 'C' has been pressed - You may continue");
- }
- if (Option == 5)
- {
- for (X=1;X<7;X++){
- gotoxy(39,14+X);
- cprintf(" ");}
- gotoxy(39,17);
- cprintf(" << OKAY PRESS A SHIFT C to CONTINUE >>");
- do{
- S_NextKey();
- S_Ch = toupper(S_Ch);
- } while (!((S_Shift)&&(S_Ch=='C')));
- }
- if (Option == 6)
- {
- textcolor(BLACK);
- Y = 1;
- for (X=1;X<5;X++)
- {
- textbackground(Y++);
- window(X*5,(X*2),(X*5)+40,(X*2)+10);
- clrscr();
- cprintf("This is window %d",X);
- }
- window(66,11,66,21);
- textbackground(BLUE);
- textcolor(CYAN);
- for (X=1;X<12;X++){
- cprintf("░");}
- window(26,21,67,21);
- gotoxy(1,X);
- cprintf("░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
- window(25,10,65,20);
- clrscr();
- textcolor(WHITE);
- gotoxy(10,5);cprintf("<<< These are windows >>>");
- gotoxy(10,7);cprintf(" Press any key to Exit..");
- S_NextKey();
- window(1,1,80,25);
- textbackground(BLACK);
- textcolor(GREEN);
- S_LoadScreen("Demo_Menu");
- }
- if (Option == 7)
- {
- strcpy(S_Msg,"Do You want to continue Y/N ");
- do{
- S_ReadKey();
- S_Ch = toupper(S_Ch);
- if ((S_Ch=='Y')||(S_Ch=='N'))
- {
- if (S_Ch=='N')
- strcpy(S_Msg," How about now..Do you want to continue? Y/N ");
- }
- else
- {
- if (S_Ch < 32) S_Ch = 32;
- strcpy(S_Msg,"< > Please respond with Y or N");
- S_Msg[1] = S_Ch;
- }
- }while (S_Ch!='Y');
- strcpy(S_Msg,"Ok you may continue");
- }
- if (Option == 8)
- {
- Back_To_Turbo_C_Land();
- S_LoadScreen("Demo_Menu");
- }
- if (Option == 9)
- {
- for (X=1;X<7;X++){
- gotoxy(39,14+X);
- cprintf(" ");}
- gotoxy(39,16);
- cprintf("coreleft = %lu",(unsigned long)coreleft());
- gotoxy(39,17);
- cprintf("farcoreleft = %lu",(unsigned long)farcoreleft());
- S_NextKey();
- }
- S_ShowStatus = 1;
- S_ResetKeyFlags();
- }
- }
- else
- strcpy(S_Msg," Only UP and DOWN arrows and ENTER and ESC are valid");
- }
- }
- }
-
-
-
-
- void main()
- {
- ScrDemo_Init();
- while (!S_Esc) Read_Menu_Screen();
- S_CloseScreenFile();
- gotoxy(1,24);
- }