10 REM >.New2Old 20 REM by Steven Flintham 30 REM 40 REM Version 0.10 50 REM based on SendMes 2.10 60 REM 70 REM Tuesday 7th January 1997 80 : 90 MODE 7 100 PROCinit 110 : 120 REM Get the submission disc - this involves unpleasant code because of 130 REM the error trapping required 140 fs$=FNprompt_sub_disc 150 ON ERROR PROCbeep:fs$=" ":GOTO 160 160 IF fs$=" " AND FNfs=4 THEN fs$="D" 170 IF fs$=" " AND FNfs=8 THEN fs$="A" 180 IF fs$="A" THEN PROCinit_adfs 190 IF fs$="D" THEN PROCinit_dfs 200 ON ERROR VDU 3:PROCoscli("FX3"):CLOSE #0:MODE 7:REPORT:PRINT " at line ";ERL:PROCenable:END 210 : 220 CLS 230 PROCprint("Please wait, converting messages...") 240 PROCcheck 250 PROCinit2 260 PROCconvert 270 : 280 MODE 7 290 PROCenable 300 END 310 : 320 DEF PROCdisable 330 *FX229,1 340 *FX4,1 350 ENDPROC 360 : 370 DEF PROCenable 380 *FX229 390 *FX4 400 ENDPROC 410 : 420 DEF PROCinit 430 ON ERROR MODE 7:REPORT:PRINT " at line ";ERL:PROCenable:END 440 CLOSE #0 450 PROCdisable 460 PROCcursor_off 470 PROCinit_colours 480 PROCinit_screen 490 buffer_size%=4080:REM 4096 minus enough for to$ and the deleted flag (could probably increase further) 500 DIM block% 32, buffer% buffer_size% 510 ENDPROC 520 : 530 DEF PROCinit2 540 LOCAL chan% 550 chan%=OPENIN("!Mesg") 560 max_mesg%=(EXT #chan%-256)/4096 570 CLOSE #chan% 580 ENDPROC 590 : 600 DEF FNS="New2Old" 610 : 620 DEF PROCinit_adfs 630 *ADFS 640 *MOUNT 0 650 *DIR $ 660 ENDPROC 670 : 680 DEF PROCinit_dfs 690 *DISC 700 *DRIVE 0 710 *DIR $ 720 ENDPROC 730 : 740 DEF PROCcursor_off 750 VDU 23,1,0;0;0;0; 760 ENDPROC 770 : 780 DEF PROCcursor_on 790 VDU 23,1,1;0;0;0; 800 ENDPROC 810 : 820 DEF PROCoscli($block%) 830 LOCAL X%,Y% 840 X%=block% MOD 256 850 Y%=block% DIV 256 860 CALL &FFF7 870 ENDPROC 880 : 890 DEF PROCinit_colours 900 border%=150 910 heading%=147 920 text%=135 930 ENDPROC 940 : 950 DEF PROCinit_screen 960 LOCAL repeat% 970 VDU 26,12 980 PRINTTAB(0,23);CHR$(border%);"ÿüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüüÿ"; 990 VDU 30,11,30 1000 PRINT " ";CHR$(border%);"ÿ¯¯¯¯¯¯¯¥ÿ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ÿ"; 1010 PRINT CHR$(border%);"ÿ¯¯¯¯¯¯¯¯¯¯¯ª¯¯¯¯¯¯¯¯ ";CHR$(border%);"ÿ"; 1020 PRINT CHR$(border%);"ÿ";CHR$(heading%);"¶£Ž ·éšè° ¶© °à€ôà à ° °à    ";CHR$(border%);"ÿ"; 1030 PRINT CHR$(border%);"ÿ";CHR$(heading%);"¶£Ž¡·éêê  ²éêê꡵êèêàîê œ¡ ";CHR$(border%);"ÿ"; 1040 PRINT CHR$(border%);"";CHR$(heading%);"¢£ £¡¢ ¡ ¢¡ ¡¢ ¢ ¡¡ £¢ ¢¡   " 1050 FOR repeat%=1 TO 19 1060 PRINT CHR$(border%);"ÿ";SPC(36);CHR$(border%);"ÿ"; 1070 NEXT 1080 PRINTTAB(4,5);CHR$(heading%-16);"8BS message file converter 0.10" 1090 VDU 28,2,23,37,7 1100 ENDPROC 1110 : 1120 DEF PROCprint(T$) 1130 PROCpretty_print(T$,text%,TRUE) 1140 ENDPROC 1150 : 1160 REM N%=TRUE means go onto a new line afterwards 1170 DEF PROCpretty_print(T$,C%,N%) 1180 REPEAT 1190 IF LEN(T$)<36 THEN PRINT CHR$(C%);T$;SPC((35-LEN(T$))*-N%);:T$="" ELSE A%=INSTR(T$," ",37):A%=A%+(A%=0)*-36:REPEAT:A%=A%-1:UNTIL MID$(T$,A%,1)=" ":PRINT CHR$(C%);LEFT$(T$,A%-1);SPC(36-A%);:T$=MID$(T$,A%+1) 1200 UNTIL T$="" 1210 ENDPROC 1220 : 1230 DEF PROCfatal(error$) 1240 CLS 1250 PROCprint(error$) 1260 PRINT'CHR$(text%);"Press SPACE to return to BASIC" 1270 *FX21 1280 REPEAT UNTIL GET=32 1290 VDU 26,12 1300 PROCcursor_on 1310 PROCenable 1320 END 1330 : 1340 DEF FNprompt_sub_disc 1350 LOCAL key%,key$ 1360 CLS 1370 PROCprint("Please insert your submission disc in drive 0. This disc should remain in the drive at all times when you are using this program.") 1380 PRINT 1390 PROCprint("When you have done this, press A if it an ADFS disc, D if it is a DFS disc or SPACE to use the current filing system.") 1400 PRINT 1410 PROCprint("If in doubt, just press SPACE.") 1420 REPEAT 1430 *FX21 1440 key%=GET 1450 key$=CHR$((key% AND &DF)-32*(key%=32)) 1460 UNTIL INSTR(" AD",key$)<>0 1470 =key$ 1480 : 1490 DEF FNfs 1500 LOCAL A%,Y% 1510 A%=0 1520 Y%=0 1530 =(USR(&FFDA) AND &FF) 1540 : 1550 DEF PROCbeep 1560 SOUND 1,-10,52,5 1570 ENDPROC 1580 : 1590 DEF FNexist(fname$) 1600 LOCAL chan% 1610 chan%=OPENIN(fname$) 1620 IF chan%<>0 THEN CLOSE #chan% 1630 =(chan%<>0) 1640 : 1650 DEF PROCcheck 1660 LOCAL chan%,version% 1670 IF NOT FNexist("!Mesg") THEN PROCfatal("This disc does not have a !Mesg file on it.") 1680 chan%=OPENIN("!Mesg") 1690 version%=BGET #chan% 1700 CLOSE #chan% 1710 IF version%<>1 THEN PROCfatal("The !Mesg file on this disc is a version "+STR$(version%)+" file. I can only convert version 1 files to version 0.") 1720 IF FNexist("!MsgOld") THEN PROCfatal("This disc already has a !MsgOld file on it, so I cannot keep the new format file under this name.") 1730 ENDPROC 1740 : 1750 DEF PROCconvert 1760 LOCAL in%,out%,discard%,sender_id$,sender_name$,mesg_num_offset%,num_messages%,convert%,to$,deleted% 1770 *RENAME !Mesg !MsgOld 1780 in%=OPENIN("!MsgOld") 1790 out%=OPENOUT("!Mesg") 1800 discard%=BGET #in%:BPUT #out%,0:REM version 0 1810 INPUT #in%,sender_id$:PRINT #out%,sender_id$ 1820 INPUT #in%,sender_name$:PRINT #out%,sender_name$ 1830 mesg_num_offset%=PTR #out% 1840 PRINT #out%,0:REM dummy number of messages for now 1850 num_messages%=0 1860 FOR convert%=0 TO max_mesg%-1 1870 PTR #in%=256+convert%*4096 1880 INPUT #in%,to$ 1890 deleted%=BGET #in% 1900 IF deleted%=0 THEN PROCconvert_message(in%,out%,to$):num_messages%=num_messages%+1 1910 NEXT 1920 PTR #out%=mesg_num_offset% 1930 PRINT #out%,num_messages% 1940 CLOSE #in% 1950 CLOSE #out% 1960 ENDPROC 1970 : 1980 REM TODO: This is slow but simple; it could be replaced with code which 1990 REM loads and saves using OSGBPB and a machine code routine to find the 2000 REM terminating 152 2010 DEF PROCconvert_message(in%,out%,to$) 2020 LOCAL byte% 2030 PRINT #out%,to$ 2040 BPUT #out%,0:REM not deleted 2050 REPEAT 2060 byte%=BGET #in% 2070 BPUT #out%,byte% 2080 UNTIL byte%=152 2090 ENDPROC