BBS: Inland Empire Archive Date: 01-21-93 (17:58) Number: 384 From: ADRIAN MADDEN Refer#: NONE To: ALL Recvd: NO Subj: Multi-tasking example in Conf: (2) Quik_Bas
DEF SEG = &H40 'Swich to BIOS segment POKE &H17, PEEK(&H17) AND (239) 'Shut off the Scroll-Lock key POKE &H17, PEEK(&H17) AND (223) 'Shut off the Num-Lock key POKE &H17, PEEK(&H17) AND (191) 'Shut off the Cap- Lock key DEF SEG 'Switch back to the default segment KEY 15, CHR$(&H0) + CHR$(&H1D) 'Define a key that traps CTRL KEY(15) ON 'Turn the key on. ON KEY(15) GOSUB EXITR CLS TEXT$ = "Hello. This is a simple parallel tasking program written in QuickBASIC." X(1) = 1 Y(1) = 1 X(2) = 10 Y(2) = 1 J = 7 AAS = 14 C = 15 G = 2 GGG = 0 T5 = 1 LOCATE 9, 1 PRINT "You can enter text:" TEXT2$ = "This is a neat addition, don't you think?" LOCATE 16, 1 PRINT "Press to exit..." LOCATE 17, 1 PRINT "START> <FINISH" GOTO TASKMAN: 1 LOCATE X(1), Y(1) I(1) = I(1) + 1 IF I(1) > LEN(TEXT$) THEN I(1) = 1: C = C - 1: X(1) = 1: Y(1) = 1: LOCATE X(1), Y(1) IF C = 0 THEN C = 15 COLOR C PRINT MID$(TEXT$, I(1), 1); X(1) = CSRLIN Y(1) = POS(X(1)) RETURN 2 LOCATE X(2), Y(2) COLOR 15 E$ = INKEY$ IF TRY = 1 AND UCASE$(E$) = "Y" THEN ENDR = 1: RETURN IF TRY = 1 AND UCASE$(E$) = "N" THEN ENDR = 0: LOCATE 20, 1: PRINT " ": RETURN IF E$ = "" THEN RETURN IF E$ = CHR$(8) THEN E$ = CHR$(29) + " " + CHR$(29) PRINT E$; HA1 = CSRLIN HA2 = POS(CSRLIN) LOCATE 25, 20 PRINT HA1; HA2; E$; LOCATE HA1, HA2 X(2) = CSRLIN Y(2) = POS(X) RETURN 3 IF H = 0 THEN G = G + 1 ELSE G = G - 1 IF G = 10 THEN H = 1: G = G - 1 IF G = 1 THEN H = 0 B = B + 1 IF B = 16 THEN B = 1 COLOR B LOCATE G, 75 PRINT G; RETURN 4 LOCATE 20, 1 COLOR 11 PRINT "QUIT?" E$ = INKEY$ IF E$ = "Y" OR E$ = "y" THEN ENDR = 1 IF E$ = "N" OR E$ = "n" THEN LOCATE 20, 1: PRINT " ": TRY = 0 RETURN 5 IF GGG = 1 THEN T5 = T5 - 1 ELSE T5 = T5 + 1 IF T5 = 0 THEN GGG = 0: T5 = T5 + 1 LOCATE 15, T5 IF GGG = 1 THEN COLOR 12 ELSE COLOR 14 PRINT MID$(TEXT2$, T5, 1); IF T5 > LEN(TEXT2$) THEN GGG = 1 RETURN 6 AAS = AAS + 1 IF AAS = 15 THEN AAS = 8 COLOR AAS LOCATE 16, 7: PRINT "CONTROL" RETURN 7 IF NGDF = 1 THEN J = J - 1 ELSE J = J + 1 IF J = 18 THEN NGDF = 1 IF J = 7 THEN NGDF = 0: J = 8 LOCATE 17, J IF NGDF = 1 THEN PRINT CHR$(29) + " " + CHR$(29) ELSE PRINT "." RETURN TASKMAN: LOCATE 25, 1 PRINT "Task managing..."; DO E = E + 1 GOSUB 1 GOSUB 2 GOSUB 3 GOSUB 5 GOSUB 6 GOSUB 7 IF TRY = 1 THEN GOSUB 4 LOOP UNTIL ENDR = 1 CLS END EXITR: TRY = 1 RETURN --- Maximus 2.01wb * Origin: The Nimby Zone (1:207/213)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET