1000 ! * TSET.BAC 1005 INTEGER : EXTEND 1010 ; '** Time set utility **' 1020 ; ' Ver X.02, 1985-04-24' 1030 ; ' Copyright 1984 Dataindustrier AB' 1040 ; 1050 ! * Written by G|ran Nordenborg 1060 ! ** ** ** ** ** ** ** ** ** ** ** 1070 ! * 1080 ! * Ver date / Ver nb / Sign / Note 1090 ! * 84-06-29 / X.00 / GN / Main 1100 ! * 84-09-07 / X.01 / GN / No stop when time=2000:00:00 1110 ! * 85-04-24 / X.02 / BL / Accessible from DOS, FNStartpar$ handling 1120 ! * 1130 ! ** ** ** ** ** ** ** ** ** ** ** 1140 ! * 1150 ! EJECT 1160 ! ******************************** 1170 ! * 1180 ! * Main routine 1190 ! * 1200 Q7=FNInitialize 1210 IF FNSettime THEN ; 'Error during time set' 1220 ; FNExit 1230 ! EJECT 1240 ! ************************************ 1250 ! * 1260 ! * Set time 1270 ! * 1280 DEF FNSettime 1290 Timeflag=F 1300 WHILE Second<>PEEK(-12) AND Timeflag=F ! No clock tick during time read 1310 Year=PEEK(-17) 1320 Month=PEEK(-16) 1330 Day=PEEK(-15) 1340 Hour=PEEK(-14) 1350 Minute=PEEK(-13) 1360 Second=PEEK(-12) 1370 Timeflag=T 1380 WEND 1390 IF FNChktime(Year,Month,Day,Hour,Minute,Second)=F THEN ; 'Local time is ''';TIME$;'''' 1400 ON ERROR GOTO 1480 1410 INPUT 'Enter time YY,MM,DD,HH,MM,SS :'Year,Month,Day,Hour,Minute,Second 1420 IF FNChktime(Year,Month,Day,Hour,Minute,Second) THEN ; 'Bad time specification' : GOTO 1410 1430 POKE -11,0 ! Make 1 second to next clock tick 1440 POKE -17,Year,Month,Day,Hour,Minute,Second 1450 IF FNSetctime(Year,Month,Day,Hour,Minute,Second) THEN RETURN T 1460 ; 'Local time is ''';TIME$;'''' 1470 RETURN F 1480 RESUME 1490 1490 ; 1500 IF ERRCODE<>210 THEN RETURN T 1510 GOTO 1420 1520 FNEND 1530 ! ******************************* 1540 ! * 1550 ! * Do communication with net central. 1560 ! * 1570 DEF FNTalknet(Fc,Sfc,B,C,D,E) LOCAL Z 1580 POKE 64798,255 ! 0FFH -> BSAVE. => TFT. fake (use DOSBUF0). 1590 POKE 64961,Fc ! FC -> MSG.FC (Function code). 1600 POKE 64962,Sfc ! SFC -> MSG.SFC (Subfunction code). 1610 POKE 64963,C,B ! MSG.PDN, MSG.ERRB (BC register to/from central). 1620 POKE 64965,E,D ! Register DE to/from central. 1630 POKE 64798,B ! LFT save 1640 Z=CALL(24615) ! NETCALL. => Talk to the central. 1650 RETURN PEEK(64962) 1660 FNEND 1670 ! 1680 END 1690 ! ************************************** 1700 ! * 1710 ! * All initialisations 1720 ! * 1730 DEF FNInitialize 1740 F=0 1750 T=-1 1760 RETURN F 1770 FNEND 1780 ! ********************************* 1790 ! * 1800 ! * Check time specification 1810 ! * 1820 DEF FNChktime(Y,Mo,D,H,Mi,S) 1830 IF Y<84 OR Year>100 THEN RETURN T 1840 IF Mo=0 OR Mo>12 THEN RETURN T 1850 IF H>23 THEN RETURN T 1860 IF Mi>59 THEN RETURN T 1870 IF S>59 THEN RETURN T 1880 IF D>31 THEN RETURN T 1890 IF Mo=2 AND D>28 THEN RETURN T 1900 IF (Mo=4 OR Mo=6 OR Mo=9 OR Mo=11) AND D>30 THEN RETURN T 1910 RETURN F 1920 FNEND 1930 ! ************************************* 1940 ! * 1950 ! * Set central time 1960 ! * 1970 DEF FNSetctime(Y,Mo,D,H,Mi,S) 1980 Timebuff$=SPACE$(6) 1990 POKE VAROOT(Timebuff$)+2,0,245 2000 Timebuff$=CHR$(FNBcd(H),FNBcd(Mi),FNBcd(D),FNBcd(Mo),FNBcd(Y),FNBcd(S)) 2010 Q7=FNTalknet(14+64,12,0,0,0,0) 2020 RETURN F 2030 FNEND 2040 ! ************************************* 2050 ! * 2060 ! * Convert to BCD 2070 ! * 2080 DEF FNBcd(Number) 2090 RETURN (Number/10)*16+MOD(Number,10) 2095 FNEND 2100 ! 2110 ! ********************************* 2120 ! * 2130 ! * Check if user entered from DOS or BASIC 2140 ! * 2150 DEF FNChkdos LOCAL I 2160 I=PEEK2(65302)-160 2170 WHILE I<160 : IF PEEK2(I)=-212 RETURN -1 2180 IF PEEK(I)<>13 I=I+1 : WEND 2190 RETURN 0 2200 FNEND 2210 ! 2220 ! ********************************** 2230 ! * 2240 ! * Get start parameter string (if any) 2250 ! * 2260 DEF FNStartpar$ LOCAL Cmdsp,I,Cmd$=160 2270 Cmdsp=PEEK2(65302)-160 2280 WHILE I<160 : I=I+1 : IF PEEK(Cmdsp+I-1)=44 GOTO 2310 2290 IF PEEK(Cmdsp+I-1)=13 RETURN '' ! No startpar string 2300 WEND : RETURN '' ! No startpar string 2310 IF PEEK(Cmdsp+I)=255 I=I+1 ! Skip DOS-entry flag 2320 WHILE I<160 : IF PEEK(Cmdsp+I)=13 GOTO 2350 2330 IF PEEK(Cmdsp+I)<32 OR PEEK(Cmdsp+I)>127 RETURN '' 2340 Cmd$=Cmd$+CHR$(PEEK(Cmdsp+I)) : I=I+1 : WEND 2350 RETURN Cmd$ 2360 FNEND 2370 ! 2380 ! ************************************* 2390 ! * 2400 ! * Exit to DOS or BASIC 2410 ! * 2420 DEF FNExit LOCAL A$=21,A 2430 IF FNChkdos=0 GOTO 2480 ELSE CLOSE ! We MUST close ALL files!!! 2440 A$='CMDINT SYS'+CHR$(14,255,205,27,96,216,195,3,193) 2450 A=VARPTR(A$) 2460 IF CALL(A+11,A) ; "Can't load CMDINT.SYS, press any key for RESET!"; 2470 GET A$ : IF CALL(0) REM Just a miracle would get through here... 2480 END ! End to get out of a function is ugly but... 2490 FNEND