10 REM ******************************** 20 REM PROCalpha_placer 30 REM True Alphabetical placer routine 40 REM By Tim Surtell 50 REM ******************************** 60 REM NC100/200 Version 1.1 70 REM Downloaded from Tim's NC Users' Site 80 REM http://www.ncus.org.uk 90 REM Place the following DIM line at the beginning of your program. 100 REM The current list is put in 'sw$(n)'. Set 'num to the total number of 110 REM words in 'sw$(n)'. Put the word to be placed in 'sw$(0)'. 120 REM New list will be in 'sw$(n)'. 130 DIM rbeg(20),rend(20),sw$(50),cw$(50) 140 REM 150 DEF PROCalpha_placer 160 FORI=0 TO num 170 cw$(I)="" 180 FORA=1 TO LEN(sw$(I)) 190 c=ASC(MID$(sw$(I),A,1)) 200 IF c>96 AND c<123 cw$(I)=cw$(I)+CHR$(c):GOTO240 210 IF c>64 AND c<91 c=c+32 220 IF c<97 OR c>122 GOTO240 230 cw$(I)=cw$(I)+CHR$(c) 240 NEXT 250 NEXT 260 REM 270 letter=1:rbeg(1)=1:rend(1)=num:placed=FALSE 280 REPEAT 290 range=0 300 FORI=rbeg(letter) TO rend(letter) 310 c=ASC(MID$(cw$(I),letter,1)):cw=ASC(MID$(cw$(0),letter,1)) 320 IF range=0 AND c=cw rbeg(letter+1)=I:range=1:GOTO350 330 IF range=1 AND c>cw rend(letter+1)=I-1:range=2:I=rend(letter):GOTO350 340 IF range=0 AND c>cw placed=TRUE:placebefore=I:I=rend(letter):GOTO350 350 NEXT 360 IF range=0 AND ASC(MID$(cw$(0),letter,1))>ASC(MID$(cw$(rend(letter)),letter,1)) placed=TRUE:placebefore=rend(letter)+1 370 IF range=1 rend(letter+1)=rend(letter):range=2 380 IF cw=-1 AND c=-1 placed=TRUE:placebefore=rend(letter) 390 letter=letter+1 400 UNTIL placed=TRUE 410 FORI=num TO placebefore STEP -1:sw$(I+1)=sw$(I):NEXT:sw$(placebefore)=word$:num=num+1 420 ENDPROC