Tuesday, 4 August 2009

Another Snippet

I was thinking about the QL World magazine and about all the bits of SBASIC code published in that. Which bits were the best I wonder. Here is one snippet that I have used again and again.

23548 DEFine PROCedure EditFileName(y%,x%)
23556 fil$=INFO$(edch%,y%,x%,40,fil$)
23564 END DEFine EditFileName
23572 :
23580 DEFine FuNction INFO$(edch%,ypos%,xpos%,max%,default$)
23588 LOCal y$(36),loop,key
23596 IF default$="":default$=dest$
23604 y$=default$:xpos%=xpos%
23612 kx%=xpos%+(LEN(y$)*6)
23620 PAPER#edch%,white:REMark CLS#edch%
23628 STRIP#edch%,white:INK#edch%,black
23636 REPeat loop
23644 BLOCK#edch%,216,10,xpos%,ypos%,white
23652 REMark PRINT#edch%,FILL$(' ',max%);
23660 CURSOR#edch%,xpos%,ypos%;
23668 PRINT#edch%,y$;
23676 Kursen edch%,kx%,ypos%
23684 key=CODE(INKEY$(#edch%,-1))
23692 SELect ON key
23700 =9,10 :REMark ENTER/TAB
23708 IF LEN(y$)>0
23716 BLOCK#edch%,216,10,xpos%,ypos%,white
23724 Kursen edch%,kx%,ypos%
23732 CURSOR#edch%,xpos%,ypos%
23740 PRINT#edch%,y$
23748 RETurn y$
23756 END IF
23764 :
23772 =27 : REMark ESC
23780 Kursen edch%,kx%,ypos%
23788 RETurn INFO$(edch%,ypos%,xpos%,max%,fil$)
23796 :
23804 =194 : REMark backspace key
23812 letter=INT((kx%-xpos%)/6)
23836 IF LEN(y$)>1:y$=y$(1 TO LEN(y$)-1)
23844 IF LEN(y$)=1:y$="":kx%=kx%-6
23852 kx%=kx%-6 : IF kx%0 AND letter<=LEN(y$) AND letter>0
23884 IF letter>1:y$=y$(1 TO letter-1)&y$(letter+1 TO LEN(y$))
23892 IF letter=1 AND LEN(y$)>1 : y$=y$(2 TO LEN(y$))
23900 IF letter=1 AND LEN(y$)=1 : y$=""
23908 IF letter<=0:y$=""
23916 kx%=kx%-6 : IF kx%<=0:y$="":kx%=xpos%:REMark remove last charcter from string
23940 :
23948 =202 : REMark delete key
23956 letter=INT((kx%-xpos%)/6)
23964 IF LEN(y$)>0 AND letter<=LEN(y$) AND letter>0
23972 IF letter+2<=LEN(y$)
23980 y$=y$(1 TO letter)&y$(letter+2 TO LEN(y$))
23988 ELSE
23996 IF letter>0:y$=y$(1 TO letter)
24004 IF letter=0
24012 IF LEN(y$)<=1 : y$="" 24020 IF LEN(y$)>1 : y$=y$(2 TO LEN(y$))
24028 END IF
24036 END IF
24044 END IF
24052 IF letter<=0:y$="":kx%=xpos%:REMark remove last charcter from string
24060 :
24068 =33 TO 127 : REMark characters
24076 letter=INT((kx%-xpos%)/6):IF letter<=0:letter=0
24084 IF letter<0 24092="" if="">=LEN(y$)
24100 y$=y$&CHR$(key)
24108 kx%=kx%+6:IF kx%>=xpos%+(max%*6):kx%=xpos%+((max%-1)*6)
24116 END IF
24124 IF LEN(y$)>0 AND letter=1:y$=y$(1 TO letter)&CHR$(key)&y$(letter+1 TO LEN(y$))
24140 IF letter=0:y$=CHR$(key)&y$(1 TO LEN(y$)):kx%=kx%+6
24148 kx%=kx%+6
24156 END IF
24164 :
24172 =32 : REMark space
24180 y$="":kx%=xpos%
24188 :
24196 =192 :REMark move cursor left
24204 Kursen edch%,kx%,ypos%
24212 kx%=kx%-6 : IF kx%=xpos%+(max%*6) : kx%=xpos%+((max%-1)*6)
24260 END SELect
24268 END REPeat loop
24276 RETurn y$
24284 END DEFine INFO$
24292 :
24300 DEFine PROCedure Kursen(edch%,kx%,ky%)
24308 OVER#edch%,-1
24316 BLOCK#edch%,6,10,kx%,ky%,HEX("FF0000")
24324 OVER#edch%,0
24332 END DEFine Kursen
24340 :

Its a bit long. But it is a SBASIC equivalent of EDLINE$. Why bother with this then. Its easier to integrate into another program and removes one toolkit dependency.

Here is another little secrete as well. Notice line 24316. The colour number for the block command is given as HEX("FF0000"). SBASIC allows the 24 bit colour as $FF0000 but QLiberator written many years before the GD2 drivers does not accept this convention hence the use of TK2 HEX function. Drat thats another toolkit dependency but not so important as all expanded systems have toolkit2 and all 24 bit colour values require this format if QLiberated.

Friday, 31 July 2009

C Programming

Digital C might be updated. Check out the QL users forum

Thursday, 30 July 2009

Quanta Magazine June/July

The latest Quanta magazine arrived today. Slightly lighter than previous copies but with 40 pages. Articles from the stalwarts Dilwyn Jones and Steve Poole. News items around games and the discovery of the lost installment of Simon Goodwins Browser program. Its now on Dilwyns site. I have given it a go here is a picture :




George Gwilt has made some changes to his programs. There are some new CDs. Dilwyn wonders if QcdeZe can be used on a Qubide2 system. I am fairly sure this is the case as I recollect that I used it when I had a working aurora system.

Friday, 24 July 2009

16k Colours with QPTR

My version of QPTR is 0.13. I have never ceased to be amazed at the resilience of this extension in the face of developments in SuperBasic and then SBASIC.

The Qliberator directive to incorporate this extension is $$asmb="location"_QPTR,0,172

I acquired the value of 172 by trial and error. It is published nowhere in any manual.



Anyway here is how to add 16k colours to the WMAN structures set up from SBASIC through QPTR. I had no idea of how simple this was until I came across an article by Geoff Wicks in QLToday in 2006, volume 10 issue 4 January to March, page 17. The article was entitled "Eleven Lines of BASIC". Nothing to do with QPTR but everything to do with the indexing of the colour built into smsq/e.

What Geoff says is this for colour index values:
0 - 255 QL colours
256 - 511 Palette colours
512 - 767 System colours (do not use!)-GWicks(sic) (Duh!)-me
768 - 1023 Shades of grey
Combine this minuscule snippet of information with the structure of the system palettes and what you get is add 512 to the index value of the system palette colour you want to use in QPTR window definitions and low and behold you have accessed the current system theme. System palettes/colours are described in QLToday volume 8 issue 2 May/June 2003 page 47.

Why was this not immediately obvious to plodders like me or how did Geoff get hold of this information so clearly and why did he not put it into context. Apply your own conspiracy theory.

Sorry no picture this time. Next time I will supply some examples of how to use this information.

Sunday, 19 July 2009

Favourite Freeware QL Software

What software do you use regularly? Besides SBASIC, QD, one little bit of software that I find indispensable is StufferStore and GSH (Get Stuffer History). One thing that the QL does differently from the PC is its clipboard.

There are two clipboard equivalents. One is the stufferbuffer and one is the Scrap. The Stufferbuffer takes on line of text, length upto 32k if needed I think. It automatically picks up file names from the QPAC file requester but can also be fed lines from other programs. For example CTRL-Z in QD drops a line of code in and F10 in the SBASIC editor drops a line in. ClipScrapBoard and other clip programs also stuff lines into the stuffer buffer. The problem arises if the line you want has been over written. Perhaps you used that filename then did a few other things and now need it again, but its no longer the current item in the single line stuffer buffer.

This is where StufferStore comes in. Stufferstore when launched in the boot file runs as a low CPU consumption background task which monitors the stufferbuffer. Each time a new item is placed in the stufferbuffer stufferstore copies it into its own stuffer history, which is a SBASIC public history device. Then to retrieve the data along comes GSH. Hotkey GSH and it opens a window listing all items in the History device using the QMenu list select menu.



Select an item and there it is back in as the current item in the stufferbuffer. Copy and past several lines of a program - no problem. Store them all in the stufferbuffer from SBASIC using the F10 key. Paste them back where you want with the stufferbuffer hotkey using GSH to place each back in the stufferbuffer in the order they need to be pasted back out. Sounds complicated but is easy in practice.

Monday, 13 July 2009

As Promised

Here are some of the issues that have rocked the QLiverse in the past. I believe that what I am about to relate is factually correct but I am reliant on memory and therefore apologise in advance if I have got some of them wrong.

The first dust up that I am aware of is the 1996/7 argument over complimentary SuperGold cards awarded by the then Quanta Committee without the full knowledge of the membership.



Simultaneously here were also some beneficial rates given for advertising to some traders that were effectively a subsidy from Quanta. These problems were raised by the then editor of Quanta who subsequently resigned over the handling of these issues.

The next major fight was over the smsq/e licence where the handling of the licencing arrangements effectively left one hardware supplier who had been instrumental in triggering the completion of the colour drivers by Tony Tebby at the programming mercy of the author of the main PC emulator for the QL. A possible conflict of interest that was not resolved and therefore effectively finished native hardware development.




Then there were the cries of piracy from the author of Just Words. This confusing issue was mixed in with the above conflict but the separation of issues was not made clear until now.



There was the attempt by the chairman of Quanta to censor a public user group on the net.

There is still the running wrangle between the editor of QLToday and Quanta.

And lately there has been a public airing of dirty linen between an established UK QL trader and the owner of QLToday.

The miracle is that despite this QL enthusiasm continues. The lion in general lies down with the lamb at the QL shows but there has always been a slow leak of casualties that weakens QL Heaven.



A happier topic is needed for my next post I think!

Sunday, 12 July 2009

Latest QL Today


QL today is the premier QL magazine at the moment. All has not been well with its UK distribution. This is the money trouble I alluded to in march of this year. The row rumbles on with an explanation from the accused and a commentary from the owner of QL Today. We humble UK subscribers are deftly reminded that for this final issue of volume 13 we are charity cases.

All this makes me think I should post a list of all the public fights that have battered and diminished ql users over the years. I will leave that for a future post.

Back to QL Today, contents include - actually I am not going to list them, here is the index page :)



Back to sprite troubles for now.