📄 demt2_b3.cpp
字号:
/*******************************************************
* *
* Program : DEMT2_B3 Language : Borland C++ *
* *
* Modified : 20 nov 2003 *
* *
* Copyright (c) 1988,2003, ORITECH V 5.1 *
* All rights reserved. *
* *
*******************************************************
* *
* DEMT2_B3.CPP Demo EasyTask DOS32 *
* *
*******************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <graphics.h>
#include <dos.h>
#include <conio.h>
#include <string.h>
#include <float.h>
#include <time.h>
#include "etlib.h"
typedef struct
{
long cnt1;
long cnt2;
long cnt3;
int position_x;
} TParmsCnt;
typedef TParmsCnt *PParmsCnt;
typedef struct
{
long cnt1;
long cnt2;
long cnt3;
int position_x;
int position_y;
} TParms3;
typedef TParms3 *PParms3;
PMultiTask taskclockptr, taskcountptr;
PMultiTask taskcnt1ptr, taskcnt2ptr, taskcnt3ptr;
PParmsCnt parmscnt, parmscnt2;
TParms3 myparms3;
void taskclock(pvoid, pvoid) // task 1
{
char tbuffer[9];
char sb[128];
pausemode(MTT); // save context
window(1,1,80,25);
textbackground(White);
textcolor(LightBlue);
do
{
gotoxy(70,1);
sprintf(sb,"%s",_strtime( tbuffer ));
cprintf(sb);
taskdelay(1000);
} while (TRUE);
}
void taskcount(pvoid, pvoid) // task 2
{
long x;
char sb[128];
pausemode(MTT); // save context
textbackground(BLACK);
textcolor(LightCyan);
window(20,15,30,20);
x = 0;
do
{
x++;
if ((x%9 == 0) && (x%4 == 0))
{
sprintf(sb,"x=%li\n\r",x);
cprintf(sb);
}
pause();
} while (!kbhit());
killalltasks();
}
void taskcnt(TParmsCnt VAR parms, pvoid)
{
long n;
char s[128];
pausemode(MTT);
textbackground(Green);
textcolor(Yellow);
window(parms.position_x,5,parms.position_x+22,10);
clrscr();
parms.cnt1 = 0; // init local variables
parms.cnt2 = 0;
parms.cnt3 = 0;
for (n=1L; n<=1000000L; n++)
{
parms.cnt1 += 1;
parms.cnt2 += 2;
parms.cnt3 += 3;
if (((parms.cnt1 % 5) == 0) && ((parms.cnt1 % 7) == 0))
{
sprintf(s,"%li:%li:%li\n\r",parms.cnt1,parms.cnt2,parms.cnt3);
cprintf(s);
}
pause();
}
}
void taskcnt3(TParms3 VAR parms, pvoid)
{
long n;
char s[128];
pausemode(MTT);
textbackground(White);
textcolor(BLACK);
window(parms.position_x,parms.position_y,parms.position_x+22,parms.position_y+5);
clrscr();
parms.cnt1 = 0; // init local variables
parms.cnt2 = 0;
parms.cnt3 = 0;
for (n=1L; n<=1000000L; n++)
{
parms.cnt1 += 1;
parms.cnt2 += 2;
parms.cnt3 += 3;
if (((parms.cnt1 % 5) == 0) && ((parms.cnt1 % 7) == 0))
{
sprintf(s,"%li:%li:%li\n\r",parms.cnt1,parms.cnt2,parms.cnt3);
cprintf(s);
}
pause();
}
}
void main(void)
{
etker_init();
textbackground(BLACK);
textcolor(WHITE);
clrscr();
_setcursortype(_NOCURSOR);
taskclockptr = newtask(taskclock,8000,1,MT_CHILD,NULL,0,NULL);
taskcountptr = newtask(taskcount,8000,1,MT_CHILD,NULL,0,NULL);
taskcnt1ptr = newtask((TTaskFunc*)taskcnt,8000,1,MT_CHILD,NULL,sizeof(TParmsCnt),NULL);
taskcnt2ptr = newtask((TTaskFunc*)taskcnt,8000,3,MT_CHILD,NULL,sizeof(TParmsCnt),NULL);
myparms3.position_x = 50;
myparms3.position_y = 15;
taskcnt3ptr = newtask((TTaskFunc*)taskcnt3,8000,2,MT_CHILD,&myparms3,0,NULL);
parmscnt2 = (PParmsCnt)taskcnt1ptr->taskparam;
parmscnt2->position_x = 10;
parmscnt2 = (PParmsCnt)taskcnt2ptr->taskparam;
parmscnt2->position_x = 50;
waitnotask();
_setcursortype(_NORMALCURSOR);
cprintf("Program End\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -