#!/usr/local/bin/basic 100 rem Pilot ToDoDB.pdb dump utility (for Chipmunk Basic) 110 rem Copyright 1997 Ronald H. Nicholson, Jr. 120 ' 130 ' pdb header 140 ' 0x000 : 0x022 cstr - DB name 150 ' 0x024 long - crdate, moddate, backupdate 154 ' 0x036 short - offset to category names 160 ' 0x03c long - type 170 ' 0x040 long - creator 180 ' 0x04c short - num records 190 ' 0x050 short - record 0 offset 192 ' 0x052 byte - record 0 category 200 ' 0x058 short - record 1 offset 210 ' 260 ' todo record 270 ' 0x00 short - 7 bits ( year - 1904 ) 280 ' - 4 bits month 290 ' - 5 bits day 300 ' 0x02 byte - priority 310 ' - 0x80 bit = done flag 330 ' 0x03 cstr - todo text (null terminated) 340 ' 350 dim m%(65000) 352 dim cat$(16) 360 f$ = "ToDoDB.pdb" 370 open f$ for data input as #1 else goto 550 : rem unix remove "data" 380 i = 0 390 p = varptr(m%(0)) 400 c = fgetbyte #1 410 while not eof(1) 420 m%(i) = c : i = i+1 430 c = fgetbyte #1 440 wend 450 mtop = i 460 close #1 470 rem 478 c2 = m%(val("0x36"))*256+m%(val("0x36")+1) 480 n2 = m%(val("0x4c"))*256+m%(val("0x4c")+1) 490 print n2,"records" 500 print "header info : "; 510 for i = 60 to 67 : print chr$(m%(i)); : next i : print 520 rem 530 gosub 2000 540 for n = 0 to n2-1 : gosub 800 : next n 560 rem gosub 1000 580 exit 590 end 600 rem decode entry n 610 i = val("0x50")+(n*8) 620 p = m%(i)*256+m%(i+1) 640 category = m%(i+2) 690 yr = 1904+int(m%(p+0)/2) 700 mo = int((m%(p+1) and val("0xe0"))/32) 710 if (m%(p+0) and 1) > 0 then mo = mo+8 720 day = m%(p+1) and val("0x1f") 724 if m%(p) = 255 then yr = -1 : mo = -1 : day = -1 730 done = (m%(p+2) and 128) > 0 734 priority = m%(p+2) and 127 740 i3 = 3 : d$ = "" 750 while (i3 < 64) and (m%(p+i3) > 31) 760 d$ = d$+chr$(m%(p+i3)) : i3 = i3+1 770 wend 780 rem print n,yr,mo,day,done,d$ 790 return 800 rem print entry n 820 gosub 600 840 t$ = str$(yr,4)+","+str$(mo,2)+","+str$(day,2)+"," 860 if yr = -1 then t$ = "0,0,0 ," 880 if done then t$ = t$ + " 1, " : else t$ = t$ + " 0, " 890 if category > 15 then category = 0 892 t$ = t$ + chr$(34)+cat$(category) + chr$(34)+", " 900 while len(t$)<32 : t$ = t$+" " : wend 920 t$ = t$ + chr$(34)+d$+chr$(34) 930 t$ = t$ + ", " + str$(priority) 950 rem 960 print t$ 970 return 990 end 1000 rem csv dump 1020 gosub 600 1040 for n = 0 to n2-1 1060 gosub 600 1100 print yr;",";mo;",";day;","; 1120 print hour1;",";min1;"'"; 1140 print hour2;",";min2;","; 1160 print chr$(34);d$;chr$(34) 1180 next n 1190 return 2000 rem get categories 2020 j = 0 2030 p = c2 + (j*16) + 2 2040 while 2050 t$ = "" : i3 = 0 2060 while (i3 < 32) and (m%(p+i3) > 31) 2070 t$ = t$+chr$(m%(p+i3)) : i3 = i3+1 2080 wend 2090 cat$(j) = t$ 2100 print str$(j,2);" : ";t$ 2110 j = j + 1 2120 p = c2 + (j*16) + 2 2160 wend (m%(p+2) = 0) 2190 return 9990 end