Wednesday 26 December 2012

Raspberry Pi in a QL Case

There has been talk of using the Raspberry Pi as  a platform for a QL successor. Here below are links to a site showing how someone has built a RPi into a QL case and connected it to the orginal QL keyboard. Although unless you are set on retaining the original QL's limited range of keys and their feel, it would seem easier to find on ebay a slimline mini usb keyboard of the required dimensions and fit this in place of the original keyboard with if needed a little trimming of the case.

http://www.deblauweschicht.nl/tinkering/qlkeys1.html

http://www.deblauweschicht.nl/tinkering/qlkeys2.html

Sunday 23 December 2012

Sunday 2 December 2012

There is life in old programs yet

The maths tutor program from the February 1989 QL World has proven useful here in QL Heaven. A certain person having to learn times tables found this utility useful. It has everything needed. A learning mode with explanations, a test mode which is probably the most useful, a brain taxing quiz mode and more. The interface is simple but reflects the time at which it was written.  The program was installed on a windows laptop with a shortcut icon to launch QPC" which on start up loaded and ran the Multiplication tables program. No QL knowledge needed. No doubt it could be run under windows using other PD or freeware emulators.

Here is the listing if anyone is interested. BTW it has been slightly modified from the listing in the magazine to take advantage of the greater screen terrain available on PCs and hence the font size used may be inappropriate for a base QL. And there are a very small number of other tweaks of little significance. 


100 :
200 :
210 :
220 :
230 intro "Multiplication Tables"
240 :
250 test = 0 : DIM tables_list(12)
260 REPeat do_tables
270   menu
280 :
290   IF menu_choice$ INSTR "LRPT"
300       which_table
320   ELSE
330       quiz_tables test,tables_list
350   END IF
355 :
360   IF menu_choice$ INSTR "T"
370       tables_list(table_choice)=table_choice
380       test_tables(table_choice)
400   END IF
410   IF menu_choice$ INSTR "P"
420       practise_tables(table_choice)
440   END IF
450   IF menu_choice$ INSTR "R"
460       recite_tables(table_choice)
480   END IF
490   IF menu_choice$ INSTR "L"
500       learn_table(table_choice)
520   END IF
530 END REPeat do_tables
540 :
550 :
560 :
570 :
580 :
590 :
600 DEFine PROCedure intro (title$)
610 CSIZE 2,1:PAPER 2:INK 7:CLS
620 AT 5,(26-LEN(title$))/2:PRINT title$:PAUSE 90
630 CSIZE 2,1:PAPER 1:INK 6:CLS
640 END DEFine intro
650 :
660 :
670 :
680 :
690 DEFine PROCedure menu
700 PAPER 6:INK 1:CSIZE 2,1:CLS
710 AT 3,1:PRINT "Press the letter for your choice or 'ESC' to Quit"
720 AT 6,1:PRINT "To learn a table:-   ";TO 27;"PRESS L"
730 AT 8,1:PRINT "To recite a table: - " ;TO 27;"PRESS R"
740 AT 10,1:PRINT "To practise a table: - ";TO 27;"PRESS P"
750 AT 12,1:PRINT "For a test on a table:- ";TO 27;"Press T"
760 AT 14,1:PRINT "For a tables quiz:- ";TO 27;"Press Q"
770   REPeat menu_choice
780     AT 16,27: PRINT "Which?"
785     menu_choice$=INKEY$(-1) : convert_case
787     IF menu_choice$=CHR$(27):STOP
790     IF menu_choice$<>"" AND menu_choice$ INSTR "LRPTQ" THEN
800       EXIT menu_choice
810     ELSE
820       rub_out menu_choice$,16,33
830     END IF
840   END REPeat menu_choice
850 END DEFine menu
860 :
870 :
880 :
890 :
900 DEFine PROCedure which_table
910 CLS
920 AT 4,4:PRINT "Which table < 1,.....,12 >? and press ENTER"
930 REPeat pick_table
940 AT 14,27: INPUT table_choice$
950   IF table_choice$<"1" OR table_choice$>"12" THEN
960      rub_out table_choice$,14,27
970   ELSE
980     LET table_choice=table_choice$
990     EXIT pick_table
1000  END IF
1010 END REPeat pick_table
1020 END DEFine which_table
1030 :
1040 :
1050 :
1060 :
1070 DEFine PROCedure learn_table(table_choice)
1080 intro "Learn a Table"
1090 FOR learn=1 TO 12
1100   teach table_choice,learn:wait:CLS
1110 END FOR learn
1120 recite_tables(table_choice)
1130 END DEFine learn_table
1140 :
1150 :
1160 :
1170 :
1180 DEFine PROCedure recite_tables(table_choice)
1190 intro "Recite a Table"
1200 :
1210 REPeat table_recite
1220 CLS
1230 FOR M = 1 TO 12
1240   AT M,11:PRINT table_choice:AT M,15:PRINT "x";M
1250 AT M,21:PRINT "=  ":AT M,24:PRINT table_choice*M
1260 PAUSE 175
1270 END FOR M
1280 option "Recite","Practice"
1290 :
1300 IF option$ INSTR "CMP" THEN EXIT table_recite
1310 END REPeat table_recite
1320 IF option$ INSTR "P" THEN practise_tables(table_choice)
1330 IF option$ INSTR "C" THEN
1340    which_table
1350    recite_tab1es (table_choice)
1360 END IF
1370 END DEFine recite_tables
1380 :
1390 :
1400 :
1410 :
1420 DEFine PROCedure practise_tables(table_choice)
1430  intro "Practise a Table"
1440  REPeat table_practise
1450    DIM hiqh_light(12):LET mistakes=0:CLS
1460 :
1470    FOR M=1 TO 12
1480       AT M,11:PRINT table_choice:AT M,15:PRINT 'x';M
1490       AT M,21:PRINT "=  ":LET answer$="?"
1500       check_input answer$,M,24
1510       IF answer$=tab1e_choice*M THEN
1520          good_news
1530 :
1540       END IF
1550       IF answer$<>table_choice*M THEN
1560          LET high_light(M) = 1 : LET mistakes=mistakes+1
1570          bad_news
1590          teach table_choict,M
1610          wait
1630          Rebuild_table(tab1e_choice),M
1660       END IF
1670   END FOR M
1680 IF mistakes = 0 THEN
1690   option "Practise", "Test"
1700 END IF :
1710  IF option$ INSTR "CMT" THEN
1720     EXIT table_practise
1730  ELSE
1740     AT 16,9:PRINT "Practise those in red"
1750     AT l7,9:PRINT "then press any key. " : wait
1760  END IF
1770 END REPeat table_practise
1780 IF option$ INSTR "T" THEN test_tables(table_choice)
1790 IF option$ INSTR "C" THEN
1800    which_table
1810    practise_tables ( table_choice )
1820 END IF
1830 END DEFine practise_tables
1840 :
1850 :
1860 :
1870 :
1880 DEFine PROCedure Rebuild_table(table_choice,M)
1890 CLS:CSIZE 2,1
1900 :
1910 FOR row = 1 TO M
1920 IF high_light(row)=1 THEN STRIP 2
1930 AT row,11:PRINT table_choice;" ":AT row, 15:PRINT "x  ";row
1940 AT row, 21:PRINT "=" :AT row,24:PRINT table_choice*row
1950 STRIP 1
1960 END FOR row
1970 END DEFine Rebuild_table
1980 :
1990 :
2000 :
2010 :
2020 DEFine PROCedure test_tables(table_choice)
2030 LOCal a$, time_now$,end_time$
2040 LET test=1
2050 intro "Test a Table"
2060 PAPER 6: INK 0
2070   REPeat table_test
2080     DIM number(10)
2090     a$=DATE$:time_now$=a$(16 TO 20)
2100     correct_marker = 0
2110     LET number_1=table_choice
2120     LET tables_list(number_1)=table_choice
2130     FOR counter = 1 TO 10
2140       CSIZE 3,1
2150       CLS
2160       REPeat multiplier
2170         LET mark=0
2180         LET number_2=RND(1 TO 12)
2190         FOR check=1 TO counter
2200           IF number_2=number(check) THEN mark=1:EXIT check
2210         END FOR check
2220         IF mark=0 THEN EXIT multiplier
2230       END REPeat multiplier
2240       LET number(check)= number_2
2250       AT 5,6: PRINT number_1:AT 5,10:PRINT "x  ";number_2
2260       AT 5,16:PRINT "=   ":LET answer$="?"
2270       check_input answer$,5,19
2280       IF answer$=number_1*number_2 THEN
2290          correct_marker= correct_marker+1:good_news: correct
2300       ELSE
2310          bad_news: wrong:teach number_1,number_2: wait
2320       END IF
2330    END FOR counter
2340    CSIZE 2,1
2350    CLS
2360    a$=DATE$:end_time$=a$(16 TO 20)
2370    minutes=end_time$(1 TO 2)-time_now$(1 TO 2)
2380    time_elapsed=60*(end_time$(1 TO 2)-time_now$(1 TO 2))+end_time$(4 TO 5)-time_now$( 4 TO 5)
2390    faces(correct_marker)
2400    AT 20,10:PRINT "You took "!time_elapsed!"seconds." !
2410    option "Test","Quiz"
2420 :
2430    IF option$ INSTR "CMQ" THEN EXIT table_test
2440   END REPeat table_test
2450 IF option$ INSTR "C" THEN
2460 which_table
2470 test_tables (table_choice)
2480 END IF
2490 IF option$ INSTR "Q" THEN quiz_tables test, tables_list
2500 END DEFine test_tables
2510 :
2520 :
2530 :
2540 :
2550 DEFine PROCedure quiz_tables(test,tables_list)
2560 LOCal a$, time_now$,correct_marker,mark,table
2570 intro "Tables Quiz"
2580 PAPER 6:INK 0
2590 DIM new_tables_list(12),tab(12)
2600 FOR table=1 TO 10
2610    tab(table)=2*table+1
2620 END FOR table
2630 FOR table=11 TO 12
2640   tab(table) = 3*table-9
2650 END FOR table
2660 quiz_list test,tables_list,new_tables_list
2670 :
2680 LET new_tables_list(0)=0:correct_total=0:total_time=0
2690 FOR table = 1 TO 12
2700      IF new_tables_list(table)<>0 THEN
2710      LET new_tables_list(0)=new_tables_list(0)+1
2720    END IF
2730 END FOR table
2740 REPeat quiz
2750 intro "There will be "&new_tables_list(O)&"rounds"
2760 FOR round =1 TO new_tables_list(0)
2770 intro "Round "&round
2780 PAPER 6 : INK 0: CSIZE 3,1
2790 DIM n3(10),n4(10)
2800 a$=DATE$:time_now$=a$(16 TO 20)
2810 correct_marker=0
2820 FOR counter=1 TO 10
2830   CLS:CSIZE 3,1
2840   REPeat multiplicand
2850     number_3=RND(1 TO 12)
2860     IF new_tables_list(number_3)<>0 THEN
2870       mark=0
2880       IF new_tables_list(0)>=10 THEN
2890          FOR check=1 TO counter
2900             IF number_3=n3(check) THEN mark=1:EXIT check
2910          END FOR check
2920       END IF
2930       IF mark=0 THEN EXIT multiplicand
2940     END IF
2950   END REPeat multiplicand
2960   LET n3(counter)=number_3
2970   REPeat multiplier
2980     mark=0
2990     number_4=RND(1 TO 12)
3000     FOR check=1 TO counter
3010       IF number_4=n4(check) THEN mark=1:EXIT check
3020     END FOR check
3030     IF mark=0 THEN EXIT multiplier
3040   END REPeat multiplier
3050   LET n4(counter)=number_4
3060   AT 5,6: PRINT number_3:AT 5,10: PRINT "x  ";number_4
3070   AT 5,16: PRINT "=  ":LET answer$="?"
3080   check_input answer$,5,19
3090   IF answer$=number_3*number_4 THEN
3100      correct_marker= correct_marker + 1:good_news: correct
3110   ELSE
3120      bad_news:wrong
3130      teach number_3,number_4:wait
3140   END IF
3150 END FOR counter
3160 CLS:CSIZE 2,1
3170 a$=DATE$:end_time$=a$(16 TO 20)
3180 minutes=end_time$(1 TO 2)-time_now$(1 TO 2)
3190 time_elapsed=60*(end_time$(1 TO 2)-time_now$(1 TO 2))+end_time$(4 TO 5)-time_now$(4 TO 5)
3200 faces(correct_marker)
3210 AT 12,10:PRINT "You took "!time_elapsed!"seconds."
3220 PAUSE 150
3230 LET correct_total=correct_total+correct_marker
3240 LET total_time=total_time+time_elapsed
3250 CLS
3260 END FOR round
3270 CLS
3280 AT 5,4:PRINT "You got ";correct_total;" outof ";round*10;" correct"
3290 AT 7,5:PRINT "You took "!total_time!"seconds. "
3300 PAUSE 150
3310 option "Quiz"," "
3320 :
3330 IF option$ INSTR "M" THEN EXIT quiz
3340 END REPeat quiz
3350 END DEFine quiz_tables
3360 :
3370 :
3380 :
3390 :
3400 DEFine PROCedure correct
3410 AT 6,9: INK 2:FLASH 1:PRINT "Well done!"
3420 PAUSE 100: FLASH 0: INK 0
3430 END DEFine correct:
3440 :
3450 :
3460 :
3470 :
3480 DEFine PROCedure wrong
3490 AT 6,5: INK 2: FLASH 1: PRINT "No. Wait for help !"
3500 PAUSE 100 :FLASH 0:INK 0
3510 END DEFine wrong
3520 :
3530 :
3540 :
3550 :
3560 DEFine PROCedure bad_news
3570 FOR j= 1 TO 255
3580 BEEP 500,j
3590 END FOR j
3600 END DEFine bad_news
3610 :
3620 :
3630 :
3640 :
3650 DEFine PROCedure good_news
3660 FOR j= 100 TO 4000 STEP 500
3670 BEEP 5000,j: PAUSE 5
3680 END FOR j
3690 END DEFine good_news
3700 :
3710 :
3720 :
3730 :
3740 DEFine PROCedure teach(n1,n2 )
3750 CLS:CSIZE 2,1
3760 AT 1,1:PRINT "To work out "!n1! " x"!n2!":":PRINT
3770 FOR j=1 TO n1
3780   FOR k=1 TO n2
3790     PRINT "*";
3800   END FOR k:PRINT
3810 END FOR j
3820 AT 5,17 : PRINT "There are " ;n1:AT 6,17 :: PRINT "lots of ";n2;" 's"
3830 AT 7,17 : PRINT "If you count all"
3840 AT 8,17 : PRINT "the stars, you":AT 9,17:PRINT "wiI1 find that"
3850 AT 10,17 : PRINT "there are ";n1*n2:AT 11,17: PRINT "of them. "
3860 AT 12,17 : FLASH 0 : PRINT "So:  "
3870 AT 14,17:UNDER 0: CSIZE 2,1:PRINT n1 ;" x ";n2;" = ";n1*n2
3880 FLASH 0: UNDER 0: CSIZE 2,1
3890 AT 17,17: PRINT "Press any key."
3900 CSIZE 2,1
3910 END DEFine teach
3920 :
3930 :
3940 :
3950 :
3960 DEFine PROCedure faces(cownt)
3970 CLS
3980 AT 1,1: PRINT "You got ";cownt;" of them right, "
3990 increment=0: radius=7
4000 FOR n=1 TO cownt
4010 CIRCLE n*radius+1+increment,80,radius
4020 ARC n*radius+1+increment - 2.6, 78 TO n*radius+1+increment+2.6,78,PI
4030 POINT n*radius +1+increment - 2,82 : POINT n*radius+ 1+increment+2,82
4040 increment=increment+radius+2
4050 END FOR n
4060 AT 12,1:PRINT "and ";10 - cownt;" of them wrong"
4070 increment=0
4080 FOR n=1 TO 10-cownt
4090 CIRCLE n*radius+1+ increment,50,radius
4100 ARC n*radius+1+increment-2.6,46 TO n*radius+1+increment+2.6,46,-PI
4110 POINT n*radius+1+increment-2,52:POINT n*radius+1+increment+2,52
4120 increment=increment+1+radius+2
4130 END FOR n
4140 END DEFine faces
4150 :
4160 :
4170 :
4180 :
4190 DEFine PROCedure wait
4200 LOCal a$
4210 a$=""
4220 REPeat loop
4230 a$=INKEY$
4240   IF a$ <> "" THEN EXIT loop
4250 END REPeat loop
4260 END DEFine wait
4270 :
4280 :
4290 :
4300 :
4310 DEFine PROCedure rub_out(text$,text_line,column)
4320 LET length = LEN(text$)
4330 AT text_line,column:PRINT FILL$(" ",length)
4340 END DEFine rub_out
4350 :
4360 :
4370 :
4380 :
4390 DEFine PROCedure check_input(answer$,text_line,column)
4400 REPeat get_input
4410   AT text_line,column : INPUT answer$
4420   IF answer$="" OR answer$=" " THEN GO TO 4410
4430   IF answer$<="0" OR answer$>"999" THEN
4440      rub_out answer$,text_line,column
4450   ELSE
4460      EXIT get_input
4470   END IF
4480 END REPeat get_input
4490 END DEFine check_input
4500 :
4510 :
4520 :
4530 :
4540 DEFine PROCedure option(level$,change$)
4550 PAUSE 125 : CSIZE 2,1
4560 IF level$(1) INSTR "RPT" THEN AT 14,4: PRINT "Press C to Change table"
4570 AT 15,4:PRINT "Press R to Repeat"
4580 AT 16,4:PRINT "Press M to obtain Menu"
4590 IF change$<>" " THEN
4600     AT 20,4 : PRINT "Press ";change$(1);" to move on to a ";change$
4610 END IF
4620 REPeat choose_option
4630   AT 22,4: PRINT "Which?";
4635   menu_choice$=INKEY$(-1) : convert_case :option$=menu_choice$
4640   IF option$<>"" AND LEN(option$)=1 THEN
4650       IF (change$=" " AND option$ INSTR "RM" ) OR (level$(1) INSTR "RPT" AND option$ INSTR "RCM"&change$(1) ) THEN
4660         EXIT choose_option
4670       ELSE
4680         rub_out option$, 18,10
4690       END IF
4700     ELSE
4710       IF option$<>"" THEN rub_out option$,18,10
4720   END IF
4730 END REPeat choose_option
4740 END DEFine option
4750 :
4760 :
4770 :
4780 :
4790 DEFine PROCedure quiz_list(test,tables_list,new_tables_list)
4800 AT 6,2: PRINT "The quiz will be on the following"
4810 AT 7,2: PRINT "Multiplication tables: "
4820 AT 9,5: PRINT;
4830 FOR tab1e=1 TO 12
4840    IF test=0 THEN
4850       PRINT " ";table;
4860     ELSE
4870       IF tables_list(table)<>0 THEN PRINT " ";table;
4880    END IF
4890 END FOR table
4900 PRINT " "
4910 AT 12,5:PRINT "Press A to Accept this list. "
4920 AT 14,5:PRINT "Press C to Change this list. "
4930 REPeat quiz_on
4940 AT 16, 5: PRINT "Which?"
4945 menu_choice$=INKEY$(-1):convert_case:quiz_on$=menu_choice$
4950 IF quiz_on$<>" " AND LEN(quiz_on$)=1 THEN
4960    IF quiz_on$ INSTR "AC" THEN
4970       EXIT quiz_on
4980     ELSE
4990       STRIP 1: rub_out quiz_on$,16,11: STRIP 6
5000    END IF
5010 ELSE
5020   IF quiz_on$<>"" THEN STRIP 1:rub_out quiz_on$, 16,11 :STRIP 6
5030 END IF
5040 END REPeat quiz_on
5050 IF quiz_on$ INSTR "c" THEN
5060   alter_list test,tables_list,new_tables_list:RETurn
5070 ELSE
5080   FOR table=1 TO 12
5090      IF test=1 THEN LET new_tables_list(table)=tables_list(table)
5100      IF test=0 THEN LET new_tables_list(table)=table
5110   END FOR table
5120 END IF
5130 END DEFine quiz_list
5140 :
5150 :
5160 :
5170 :
5180 DEFine PROCedure alter_list(test,tables_list,new_tables_list)
5190 LOCal pick_table
5200 PAPER 1:CLS:STRIP 7:INK 0
5210 AT 8,2 : PRINT "< or >, to choose, to select"
5220 AT 9,10: PRINT " to delete"
5230 AT l0,2: PRINT " when your list is complete"
5240 AT 15,3: PRINT "Multiplication tables chosen: -"
5250 CSIZE 1,0
5260 n=1
5270 REPeat quiz_on
5280   FOR table=1 TO 12
5290     STRIP 7
5300     IF table=n THEN STRIP 2
5310     AT 13,tab(table)-2: PRINT table;
5320   END FOR table
5330   a$=INKEY$(-1)
5340   IF a$=CHR$(192) THEN n=n-1:IF n=0  THEN n=1
5350   IF a$=CHR$(200) THEN n=n+1:IF n=13 THEN n=12
5360   IF a$=CHR$(32) THEN
5370      LET new_tables_list(n)=n
5380      AT 17,tab(n)-2:STRIP 2:PRTNT n
5390   END IF
5400   IF a$=CHR$(194) THEN
5410      LET new_tables_list(n)=0
5420      AT 17,tab(n)-2 : STRIP 1:PRINT "  "
5430   END IF
5440   IF a$=CHR$(10) THEN
5460      LET pick_table=O
5470      FOR check=1 TO 12
5480         LET pick_table= pick_table+new_tables_list(check)
5496      END FOR check
5500      IF pick_table<>0 THEN CLS:PAPER 6:INK 0:EXIT quiz_on
5510   END IF
5520 END REPeat quiz_on
5530 END DEFine alter_list
5540 :
5550 :
5560 :
5570 :
5580 DEFine PROCedure convert_case
5590 IF CODE(menu_choice$)>90 : menuchoice$=CHR$(CODE(menu_choice$)-32)
5600 END DEFine convert_case