   10REM SAVE"$.Arabic.Util.Analyse"
   20*SPOOL
   30*CLOSE
   40*SPOOL INFOTXT
   50PRINT"AUTO"
   60nextindex=255
   70Unique = 0
   80DIM Base 7
   90DIM Reverse 255
  100FOR I=128 TO 255:Reverse?I=&FF:NEXT
  110FOR I=0 TO 127:Reverse?I=I:NEXT
  120DIM Char 4*128*9   :REM Font, Char-128, Defn+Code
  130DIM Files$(3)
  140Files$(0)="SA"
  150Files$(1)="Beg"
  160Files$(2)="Mid"
  170Files$(3)="End"
  180FOR File = 0 TO 3
  190File$ = Files$(File)
  200I%=OPENIN(File$)
  210FOR Ch = 32 TO 127
  220  PROCskip(Ch)
  230NEXT
  240FOR Ch = 128 TO 255
  250  PROCdo(Ch)
  260NEXT
  270CLOSE#I%
  280NEXT
  290PROCCompactFonts
  300PROCRevTab
  310REMPRINTUnique;" unique characters"
  320*SPOOL
  330END
  340DEFPROCdo(C%)
  350C23=BGET#I%
  360IF C23<>23 THEN PRINT"Error at char ";C%:END
  370CC% = BGET#I%
  380IF CC%<>C% THEN PRINT"Error at char ";C%:END
  390REMPRINT"VDU 23,";C%;
  400FOR Px=0 TO 7
  410  CC% = BGET#I%
  420REM  PRINT",";CC%;
  430  Char?(File*128*9 + (C%-128)*9 + Px) = CC%
  440NEXT
  450REMPRINT
  460ENDPROC
  470DEFPROCskip(Ch)
  480FOR px=0 TO 9
  490  CC%=BGET#I%
  500NEXT
  510ENDPROC
  520DEFPROCCompactFonts
  530REM select unique characters
  540FOR font = 0 TO 3
  550REMPRINT".";Files$(font);"Tab"
  560FOR ch=0 TO 127
  570  !Base = Char!(font*128*9+ch*9)
  580  Base!4 = Char!(font*128*9+ch*9+4)
  590  REMPRINT Files$(font);"  ";ch+128,~!Base,~Base!4;"   ";
  600  REMVDU 23,128,Base?0,Base?1,Base?2,Base?3,Base?4,Base?5,Base?6,Base?7,128
  610  PROClocate(font,ch)
  620  REMPRINT
  630NEXT
  640NEXT
  650ENDPROC
  660DEFPROClocate(font,ch)
  670Char?8=nextindex
  680FOR index = 0 TO font*128*9+(ch-1)*9 STEP 9
  690  IF (Char!index <> !Base) OR (Char!(index+4) <> Base!4) THEN GOTO 750
  700  PROCtabentry(FALSE)
  710  Char?(font*128*9 + ch*9 + 8) = Char?(index+8)
  720  IF index=0 THEN index=font*128*9+(ch-1)*9:NEXT:ENDPROC
  730  REMPRINT"  ->  ";Files$(index DIV (128*9));"_";((index MOD (128*9)) DIV 9)+128;
  740  index=font*128*9+(ch-1)*9:NEXT:ENDPROC
  750REM
  760NEXT
  770Reverse?nextindex = ch+128
  780Char?(index + 8) = nextindex:nextindex=nextindex-1
  790Unique = Unique+1
  800PROCtabentry(TRUE)
  810ENDPROC
  820DEFPROCtabentry(New)
  830IF (Base!0=0) AND (Base!4=0) THEN Char?(index + 8) = 32
  840REMPRINT "  EQUB ";Char?(index + 8);"  \ ";Files$(font);"Tab?";ch+128;
  850IF New THEN PRINT"VDU 23,";nextindex+1;",";Base?0;",";Base?1;",";Base?2;",";Base?3;",";Base?4;",";Base?5;",";Base?6;",";Base?7
  860ENDPROC
  870DEFPROCRevTab
  871ENDPROC
  880PRINT".Reverse"
  890FOR I=128 TO 255
  900  PRINT"  EQUB ";Reverse?I;"  \ Reverse?";I
  920NEXT
  930ENDPROC
