Post by Ammammatae ricordo anche di aver preparato una serie di routine, una per ogni comando,
a cui passavo i parametri e ricevevo indietro il record o lo status
dell'operazione
si tratta di un tipico caso di "spaghetti code" ;)
questa era la prima versione su cui lavorai, ereditata dal programmatore che
mi aveva preceduto
successivamente riscrissi le routine ordinandole un po'
la routine a 60000 leggeva l'indirizzo di memoria a cui era stato caricato il
fabsp (di solito nell'autoexec.bat)
la routine a 60676 era quella che eseguiva il comando
i vari segmenti di programma sono datati tra il 1994 e il 2000 :)
60000 REM
60001 REM S=60304
60008 ' xxxxxxxx.BAS"
60012 OPEN "\NGX\FSEG" FOR INPUT AS 1
60016 INPUT #1, FSEG
60020 CLOSE 1
60024 RETURN
60028 CMND$ = "O\" + M$ + ".KEY\" + FLNO$: REM OPEN KEY
60032 GOSUB 60676
60036 IF ERRF% <> 0 THEN 60668
60039 RETURN
60200 RKEY$ = "": IF MAXKLEN = 0 THEN MAXKLEN = 42
60204 FOR I = ADRKEY TO ADRKEY + MAXKLEN - 1
60208 DEF SEG = FSEG
60212 KCHAR = PEEK(ADRKEY)
60216 DEF SEG
60220 RKEY$ = RKEY$ + CHR$(KCHAR)
60224 ADRKEY = ADRKEY + 1
60228 NEXT I
60232 RETURN
60240 F$ = "F": GOTO 60244: REM SF
60242 F$ = "L": REM SL
60244 CMND$ = F$ + "\" + PKN$ + "\" + FLNO$
60248 GOSUB 60676
60252 IF ERRF% <> 0 THEN 60668
60260 RETURN
60264 F$ = "N": GOTO 60268: REM NEXT
60266 F$ = "P": REM PREV
60268 CMND$ = F$ + "\" + FLNO$
60270 NMND$ = F$ + "\" + FLNO$
60272 GOSUB 60676
60274 IF ERRF% = 15 THEN RETURN
60276 IF ERRF% <> 0 THEN 60668
60284 RETURN
60288 REM SEARCH
60304 F$ = "S"
60308 CMND$ = F$ + "\" + PKN$ + "\" + FLNO$ + "\" + IK$
60310 CMND$ = F$ + "\" + PKN$ + "\" + FLNO$ + "\" + IK$
60312 GOSUB 60676
60316 IF ERRF% = 0 THEN 60332: REM OK
60320 IF ERRF% = 12 THEN 60332: REM NOTF (RET. RN OF ADJAC SMKEY)
60324 IF ERRF% = 15 THEN 60332: REM NOTF (>ALL KEYS RN OF LARGER)
60326 IF ERRF% = 16 THEN 60332: REM NOTF (NO KEYS ON FILE )
60328 IF ERRF% = 13 THEN 60332: REM NOTF (BEF BEG OF KEYS )
60330 GOTO 60668
60332 REM
60340 RETURN
60344 REM GENERIC SEARCH
60348 F$ = "G"
60360 GOTO 60308
60364 REM INSERT
60400 REM
60404 CMND$ = "I\" + FLNO$ + "\" + KEYM$(1) + "\" + KEYM$(2)
60406 GOTO 60416
60412 CMND$ = "I\" + FLNO$ + "\" + KEYO$(1) + "\" + KEYO$(2) + "\" + KEYO$(3)
60416 GOSUB 60676
60419 GOSUB 48000
60420 IF ERRF% <> 0 THEN 60668
60432 RETURN
60436 REM S+ DELETE KEYS
60448 CMND$ = "S\" + PKN$ + "\" + FLNO$ + "\" + IK$
60452 GOSUB 60676
60456 IF ERRF% = 13 THEN 60480
60460 IF ERRF% = 15 THEN 60480
60464 IF ERRF% = 12 THEN 60480
60468 IF ERRF% <> 0 THEN 60668
60472 REM GET REC
60476 COMPARE KEY REC.CON IK$
60480 PRINT "NO MORE KEYS WITH THE VALUE "; IK$
60484 STOP
60488 PRINT
60492 GOSUB 60740
60496 PRINT
60500 PRINT "DELETE THIS RECORD? (Y/N) "
60504 AN$ = INKEY$: IF AN$ = "" THEN 60504
60508 IF AN$ = "Y" THEN 60536
60512 CMND$="N\"+FLNO$ REM NEXT
60516 GOSUB 60676
60520 IF ERRF% = 12 THEN 60480
60524 IF ERRF% = 13 THEN 60480
60528 IF ERRF% = 15 THEN 60480
60532 GOTO 60468
60536 RECNO$ = STR$(RECNO)
60540 IF LEFT$(RECNO$, 1) = " " THEN RECNO$ = RIGHT$(RECNO$, LEN(RECNO$) -
1): GOTO 60540
60542 REM DELETE
60544 CMND$ = "D\" + RECNO$ + "\Y\" + FLNO$ + "\" + KEYO$(1) + "\" + KEYO$(2)
+ "\" + KEYO$(3)
60548 GOSUB 60676
60552 IF ERRF% <> 0 THEN 60668
60556 LSET MARK$ = "D"
60560 CODE# = RECNO
60572 RETURN
60576 REM REPLACE A KEY
60580 RECNO$= RECORD NUMBER OF KEY TO REPLACE
60584 RECNO = VAL(RECNO$)
60596 OLDKEY$=VECCHIA KEY
60608 NEWKEY$=NUOVA KEY
60612 CMND$="R\"+PKN$+"\"+RECNO$+"\"+FLNO$+"\"+OLDKEY$+"\"+NEWKEY$
60616 GOSUB 60676
60620 IF ERRF% <> 0 THEN 60668
60624 GET #1, RECNO
60628 LSET NAME1$ = NEWKEY$: REM KEY IN THE RECORD
60632 PUT #1, RECNO
60640 RETURN
60644 REM COMMANDS T,U,H,M
60648 CMND$ = F$ + "\" + FLNO$
60652 GOSUB 60676
60656 IF ERRF% <> 0 THEN 60668
60660 PRINT "THE NUMBER IS "; RECNO
60664 RETURN
60668 PRINT "DATA TREE(xxxx) ERROR NO: "; ERRF%
60672 STOP
60676 '
60680 DEF SEG = FSEG
60684 FABS = &H5
60688 CALL FABS(CMND$, ERRF%, RECNO%, ADRKEY%)
60690 EXCMND$ = CMND$
60692 RNLO = RECNO%
60696 IF RNLO < 0 THEN RNLO = RNLO + 65536!
60700 ADRKEY = ADRKEY%
60704 IF ADRKEY < 0 THEN ADRKEY = ADRKEY + 65536!
60708 CMND$ = "X"
60712 CALL FABS(CMND$, DUM%, RECNO%, DUM%)
60716 RNHI = RECNO%: IF RNHI < 0 THEN RNHI = RNHI + 65536!
60720 RECNO = RNLO + RNHI * 65536!
60724 RECNO$ = RIGHT$(STR$(RECNO), LEN(STR$(RECNO)) - 1)
60728 DEF SEG
60730 CODE# = RECNO: IF FLNO$ = "1" THEN CODEO# = CODE# ELSE IF FLNO$ = "2"
THEN CODEM# = CODE#
60732 ' GOSUB 60200 (RK)
60734 RETURN
60736 GET #1, RECNO
60748 IK$ = LEFT$(IK$ + STRING$(MAXKLEN, " "), MAXKLEN)
60752 RETURN
60828 REM ERR
60912 RETURN
60916 '
60932 '
60936 '
60940 CMND$ = "A\" + PKN$ + "\" + RECNO$ + "\" + FLNO$ + "\" + IK$
60941 OCMND$ = "A\" + PKN$ + "\" + RECNO$ + "\" + FLNO$ + "\" + IK$
60942 GOSUB 60676
60944 IF ERRF% = 15 GOTO 60952
60946 IF ERRF% = 16 GOTO 60952
60948 'IF ERRF% <> 0 THEN 60668
60952 ' x 15(16 TESTARE FUORI
60956 RETURN
60960 IB$ = "": AN$ = IB$: B$ = IB$
60964 AN$ = INKEY$: IF AN$ = "" THEN 60964
60966 IF MID$(AN$, 2, 1) = "H" THEN RETURN
60968 IF AN$ = CHR$(13) THEN 60996
60972 IF AN$ <> CHR$(8) THEN 60982
60976 IF LEN(IB$) = 0 THEN 60960
60980 IB$ = LEFT$(IB$, LEN(IB$) - 1): GOSUB 3610: PRINT IB$; : GOTO 60964
60982 IF AN$ = CHR$(24) THEN 60992
60984 IF AN$ < CHR$(32) THEN 60964
60988 IF AN$ > CHR$(90) THEN 60964
60990 IF POS(0) > P(2) THEN 60964
60992 IB$ = IB$ + AN$: PRINT AN$; : GOTO 60964
60996 B$ = IB$
60998 PRINT SPACE$(LM - LEN(B$));
61000 RETURN
65000 REM
65010 CLS: FOR J=1 TO 24:PRINT J,G1#(J): NEXT J
65020 RETURN
--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
Post by Ammammatahttp://www.bb2002.it :) <<<<<