Re: [Ql-Users] Quanta Library Guide
The FOP_xxx functions (and all similar TK2 things) always tried to use the Data default next, if a direct call was unsuccessful. So, if I try to check Win1_test_, and it does not exist, Win1_ is checked next (if Data default), which is very likely to be successful. So you can't be sure, that the correct device was opened. That's why it is better, to set the Data default to "", then try, then set it back to where it was before. - Original Message - From: "Bob Spelten" To: Sent: Saturday, April 21, 2012 5:43 PM Subject: Re: [Ql-Users] Quanta Library Guide Op Sat, 21 Apr 2012 16:10:15 +0200 schreef Ralf Reköndt : Hmm, but the TK2 Manual states about OPEN_DIR, so, apart from Level 2, it should be possible. But what kind of directory, if not Level 2? Perhaps just the root one. Section 10 Open and Close The standard QL channel OPEN commands are redefined by Toolkit II to use the data directory. In addition, Toolkit II provides a set of functions for opening files either using a specified channel number (as in the standard QL commands), or they will find and return a vacant channel number. The functions also allow filing system errors to be intercepted and processed by SuperBASIC programs. Commands OPEN #channel, nameopen a file for read/write OPEN_IN #channel, name open a file for input only OPEN_NEW #channel, nameopen a new file OPEN_OVER #channel, name open a new file, if it exists it is overwritten OPEN_DIR #channel, nameopen a directory CLOSE #channelsclose channels The problem is related to the FTEST command trying to open a file rather than a directory to verify its existance. In SMSQ/E a directory can be opened as a file, but in QDOS I don't think it can. The correct way to check for the validity of devices and directories would be to attempt to open a directory, not a file (TRAP#2 with D0=1 and D3=4 rather than D3=1). The Function FOP_DIR can be used but is not very reliable. I did a quick QDOS test on my demo Q-emuLator where win1_ is a W$ folder, win2_ is a QL floppy. chn= FOP_DIR (win1_): PRINT FTYP(#chn): produced 255. chn= FOP_DIR (win1_mach_): PRINT FTYP (#chn): also produced 255 while mach_ is part of a filename and not a directory! Even chn FOP_DIR ("win1_ma"): PRINT FTYP (#chn): returned as valid directory. This was not the case with win2_, there a FTYP returned zero for everything. But chn= FOP_DIR (usb1): opened a channel to win2_, PRINT FTYP(#chn): returned zero and DIR usb1_ gave the name of the floppy and the sector count. So this is here not a good level 1 test to see if a device or directory actually exists. Minerva gave the same results. Mind you, even under QPC2 I can happily FOP_OVER (a_file) to my win8_, which is a QXL.WIN on the cdrom! Bob -- The BSJR QL software site at: http://members.upc.nl/b.spelten/ql/ ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Quanta Library Guide
Op Sat, 21 Apr 2012 16:10:15 +0200 schreef Ralf Reköndt : Hmm, but the TK2 Manual states about OPEN_DIR, so, apart from Level 2, it should be possible. But what kind of directory, if not Level 2? Perhaps just the root one. Section 10 Open and Close The standard QL channel OPEN commands are redefined by Toolkit II to use the data directory. In addition, Toolkit II provides a set of functions for opening files either using a specified channel number (as in the standard QL commands), or they will find and return a vacant channel number. The functions also allow filing system errors to be intercepted and processed by SuperBASIC programs. Commands OPEN #channel, nameopen a file for read/write OPEN_IN #channel, name open a file for input only OPEN_NEW #channel, nameopen a new file OPEN_OVER #channel, name open a new file, if it exists it is overwritten OPEN_DIR #channel, nameopen a directory CLOSE #channelsclose channels The problem is related to the FTEST command trying to open a file rather than a directory to verify its existance. In SMSQ/E a directory can be opened as a file, but in QDOS I don't think it can. The correct way to check for the validity of devices and directories would be to attempt to open a directory, not a file (TRAP#2 with D0=1 and D3=4 rather than D3=1). The Function FOP_DIR can be used but is not very reliable. I did a quick QDOS test on my demo Q-emuLator where win1_ is a W$ folder, win2_ is a QL floppy. chn= FOP_DIR (win1_): PRINT FTYP(#chn): produced 255. chn= FOP_DIR (win1_mach_): PRINT FTYP (#chn): also produced 255 while mach_ is part of a filename and not a directory! Even chn FOP_DIR ("win1_ma"): PRINT FTYP (#chn): returned as valid directory. This was not the case with win2_, there a FTYP returned zero for everything. But chn= FOP_DIR (usb1): opened a channel to win2_, PRINT FTYP(#chn): returned zero and DIR usb1_ gave the name of the floppy and the sector count. So this is here not a good level 1 test to see if a device or directory actually exists. Minerva gave the same results. Mind you, even under QPC2 I can happily FOP_OVER (a_file) to my win8_, which is a QXL.WIN on the cdrom! Bob -- The BSJR QL software site at: http://members.upc.nl/b.spelten/ql/ ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] C68 and the Quanta Library Guide
Afternoon Dave, On 20/04/12 09:18, Dave Walker wrote: The strfnd function is not a standard function in C so any you come > across are implementation defined. I am guessing that your code has > one with different semantics to the library one (which if I remember > correctly is based on the Lattice C implementation), so you need to > have a #undef statement to hide the library implementation. Hmm, interesting. When I first compiled this system, strfnd did indeed have three parameters and I never had to udef anything. It's with the latest version of C68 that I'm hitting the problem as the header defines only two. > I would guess that the three argument version you mentioned uses the 3rd argument to define continue behaviour which is why the problem with > LOCATE/CONTINUE. It does indeed define continue. The _oserr variable is different to errno. The idea is that errno is > used for standard errors and is part of the C standard while _oserr > is used for ones that are specific to the implementation. Yes, I realised that and changed everything back to _oserr again. > The standard _oserr variable is defined in the C startup module. I can see that from the MAP file created. However since an extra underscore gets added when viewing at the > linker level, I am guessing this means that your code refers to it > without the leading underscore somewhere. That's what I though, but I'm still hitting the error and I've taken all the source files and searched for oserr and everything has a leading (single) underscore. I've even gone as far as putting everything onto Linux and grepping for oserr, none of my source or header files have it without the underscore. > In this particular case you are getting away with it because it is a > simple variable and not a label for executing code. Very true, but I'm not convinced the bug is in my code, I'm still hunting though. This all compiled perfectly with an older version of C68. I note from the comments in one of my source files that it has been amended to compile under C68 versions 3.02 and 3.04 and the latest, 4.5 Beta. I may install an older version to see what's going on. Cheers, Norm. -- Norman Dunbar Dunbar IT Consultants Ltd Registered address: Thorpe House 61 Richardshaw Lane Pudsey West Yorkshire United Kingdom LS28 7EL Company Number: 05132767 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Quanta Library Guide
Yes. From: "Tony firshman" (Fom TK2 manual...) CLOSE #channelsclose channels What is the syntax? close #2,#3 ? ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
Hi Bryan, On 21/04/12 10:21, Bryan Horstmann wrote: The only things I know about Python are from the Cheat Sheet I mentioned earlier. But where are the equivalent of all the many other S*BASIC Keywords? Python isn't S*Basic, so most of the well known and loved S*Basic commands and keywords etc will not be there. Cheers, Norm. -- Norman Dunbar Dunbar IT Consultants Ltd Registered address: Thorpe House 61 Richardshaw Lane Pudsey West Yorkshire United Kingdom LS28 7EL Company Number: 05132767 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Quanta Library Guide
On 21 Apr 2012, at 10:10, Ralf Reköndt wrote: > > >CLOSE #channelsclose channels > What is the syntax? close #2,#3 ? Tony -- t...@firshman.co.ukhttp://firshman.co.uk Voice: +44 (0) 1442 828254 Fax: +44 (0) 1442 828255. Skype: tony firshman TF Services, 29 Longfield Road, Tring, Herts, HP23 4DG ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
Hi Derek, Why get the source to Python and produce a specific version for Sbasic. Because we can? I suppose we could, after all, we have C68 for QDOSMSQ why not Python? It would be a separate language though, not something to "compile" S*Basic. I suppose we could produce sPython, which would run / compile Sbasic source code. But there would have be a facility to add extensions and Toolkits to it. Python is a language in it's own right, like C or Basic or Assembly. S*Basic syntax etc will not be compatible with Python. (Unless someone builds a translator of course.) ... I use Mint 12, which has Python 3 built in on installation, been using this for a while now, all very nice and very similiar to Sbasic/Superbasic. I too have Mint 12 and my Python shows 2.7.2+ but maybe there was an option at install time to select Python 2.x or 3.x. Even on the Python web site they advise sticking with 2,x as there are more programs compatible with that version. Cheers, Norm. -- Norman Dunbar Dunbar IT Consultants Ltd Registered address: Thorpe House 61 Richardshaw Lane Pudsey West Yorkshire United Kingdom LS28 7EL Company Number: 05132767 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Quanta Library Guide
Some years back QLToday wrote about testing the machine you are using by reading the sys_vars (PEEK (sv +167)). The test on Q-emulator returns zero, as the standard QL, so this could be used to assume there is no Level2 device. This number is held in the 5 lowest bits, I believe 14, 15, 18 to 23, 25 to 27 & 29 are still free. To check for level 2 drivers present or not, use the IOF.XINF trap #3 with D0=hex4F (QDOS Reference Guide, section 15, page13). Norman Dunbar uses this call for the "LEVEL2" function in the djtoolkit, source of which is included with the package on toolkits page of my website showing how to use the test for Level2 drivers. Testing for QemuLator: This is a text which Daniele sent me some time back. As it was a while back, probably best to check with Daniele if this is still valid, or has been extended or whatever. == Use Trap #1 with D0.L = -26 to get some emulator info. The trap is designed to be usable by other emulators, but I don't think anybody else is using it, so it works only with Q-emuLator. In systems where the trap is not implemented you will get an error in D0.L (bad parameter, I think), in Q-emuLator you get 0 in D0.L. There are three commands, identified by the value in D1: D1.L = 0 Currently returns 0 in both D1.L and D2.L. I don't remember anymore for sure what the intended meaning was :(. I think D1 was the version of the D0=-26 TRAP implemented by the emulator (for example in the future there might be a version 1 TRAP that returns extra info, or allows more values in D1.L), and D2 is probably reserved for future use. Just ignore D1 and D2 and look only at D0 (0 = trap is supported, error = it is not), or directly call with D1.L = 1 or 2. = D1.L = 1 Returns in D1.L info about the host system: D1.L = $00aabbcc, where aa = host OS 0 = Windows 3 = Mac OS bb = host OS variant (for example, if aa was Unix, bb would identify whether it is BSD, Linux, etc.). Currently always zero. cc = emulator ID 1 = Q-emuLator Returns in D2.L the version of the emulator: D2.L = $xxyyzzww, where xx = major version number yy = middle version number zz = minor version number ww was supposed to be a global incremental number, but a 0-255 range is probably too little, so you can just ignore it. D3.L = type of build 0 = alpha 1 = beta 2 = release For example, D2.L = $02010005 and D3.L = 2 means version 2.1 D2.L = $01030218 and D3.L = 1 means version 1.3.2b == D1.L = 2 A1.L = pointer to memory buffer D2.L = length of buffer Fills the buffer with a short QL string identifying the emulator (for example "Q-emuLator 2.2"). Returns a buffer full error in D0 if the buffer is smaller than the string (and the buffer content is not valid in this case). == Daniele added at the time: Hope this helps. Most of this is untested so you may find some bugs. The only piece of software currently using one of these traps is the Q-emuLator's mouse driver (it refuses to install and prints an error if it's not running in Q-emuLator). ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Quanta Library Guide
Hmm, but the TK2 Manual states about OPEN_DIR, so, apart from Level 2, it should be possible. But what kind of directory, if not Level 2? Perhaps just the root one. Section 10 Open and Close The standard QL channel OPEN commands are redefined by Toolkit II to use the data directory. In addition, Toolkit II provides a set of functions for opening files either using a specified channel number (as in the standard QL commands), or they will find and return a vacant channel number. The functions also allow filing system errors to be intercepted and processed by SuperBASIC programs. Commands OPEN #channel, nameopen a file for read/write OPEN_IN #channel, name open a file for input only OPEN_NEW #channel, nameopen a new file OPEN_OVER #channel, name open a new file, if it exists it is overwritten OPEN_DIR #channel, nameopen a directory CLOSE #channelsclose channels The problem is related to the FTEST command trying to open a file rather than a directory to verify its existance. In SMSQ/E a directory can be opened as a file, but in QDOS I don't think it can. The correct way to check for the validity of devices and directories would be to attempt to open a directory, not a file (TRAP#2 with D0=1 and D3=4 rather than D3=1). ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Quanta Library Guide
Op Fri, 20 Apr 2012 09:00:18 +0200 schreef Daniele Terdina : SuQcess starts with testing the validity of devices and directories to prevent it from crashing later. For this the TK2 commands FTEST and FTYP are used but these don't seem to work on the device names used by Q-emuLator. Is this just an issue with the non-registered version? Is there any way to test for Q-emuLator from S*Basic so I can skip the test and hope for the best? The unregistered version tries to emulate the original file drivers, which are not "level 2". SuQcess seems too big for this version anyway. On a registered copy of Q-emuLator, and with level 2 drivers enabled, FTEST("mdv1_") should return 0 and your check will succeed. On the unregistered version it returns -7, and I think that's the correct behaviour: Although I can't currently check, I believe FTEST("mdv1_") would also return -7 when run on a QL, even if there is a cartridge in the drive. It would be interesting to check. I have no working level 1 QL here, but a test on my SGC-QL (QDOS-TK2) confirmed your suspicion that FTEST(mdv1_) returns -7 even on a level 2 system, after reading mdv1 correctly. The problem is related to the FTEST command trying to open a file rather than a directory to verify its existance. In SMSQ/E a directory can be opened as a file, but in QDOS I don't think it can. The correct way to check for the validity of devices and directories would be to attempt to open a directory, not a file (TRAP#2 with D0=1 and D3=4 rather than D3=1). There is no SuperBASIC keyword to test for Q-emuLator, but it would be easy to write one if needed, as there is a TRAP#1 command that can be used to detect Q-emuLator. Some years back QLToday wrote about testing the machine you are using by reading the sys_vars (PEEK (sv +167)). The test on Q-emulator returns zero, as the standard QL, so this could be used to assume there is no Level2 device. This number is held in the 5 lowest bits, I believe 14, 15, 18 to 23, 25 to 27 & 29 are still free. Bob -- The BSJR QL software site at: http://members.upc.nl/b.spelten/ql/ ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
Op Sat, 21 Apr 2012 12:42:05 +0200 schreef Ralf Reköndt : I think, that wasn't the question. Don't confuse this with QLiberator's option "Line Numbers". As far as I know, QLiberator does not need line numbers, but this is not possible via the interpreter. It is in fact possible with the QD5 Thing to compile source code without line numbers. I think, Turbo is just able to compile a loaded SuperBASIC program, so no way to compile without line numbers. QLiberator always compile from a QSAVEd file (or QD5 Thing). Cheers...Ralf - Original Message - From: "George Gwilt" To: Sent: Saturday, April 21, 2012 10:46 AM Subject: Re: [Ql-Users] Raspberry Pi - starts On 20 Apr 2012, at 21:40, Dilwyn Jones wrote: I always thought it was a pity superBasic demanded line numbers. They were not actually necessary, and if GOTO did not exist, not even used. I think QLiberator at least can compile without line numbers (never actually tried that). Perhaps George could tell us if Turbo can too. Turbo gives three options: omitting line numbers in the compiled program, including them without displaying them during compilation and including them as well as displaying them. George QD can be used to write SBasic without bothering about line numbers. GOTO's and GOSUB's can easily be avoided. The SBAS/QD thing lets me test-run it from there. I use BasicLinker to call Qliberator, this will add line numbers for the _sav file, which can be stripped again by Qlib. This also takes care of multiple RESTORE commands, as long as they are the only command on that line. Bob -- The BSJR QL software site at: http://members.upc.nl/b.spelten/ql/ ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
Yes, but always from a loaded SuperBASIC program... ;-) Turbo compiles from the tokenised SuperBASIC program. ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
On 21 Apr 2012, at 11:42, Ralf Reköndt wrote: > I think, that wasn't the question. Don't confuse this with QLiberator's > option "Line Numbers". > > As far as I know, QLiberator does not need line numbers, but this is not > possible via the interpreter. It is in fact possible with the QD5 Thing to > compile source code without line numbers. > > I think, Turbo is just able to compile a loaded SuperBASIC program, so no way > to compile without line numbers. QLiberator always compile from a QSAVEd file > (or QD5 Thing). Turbo compiles from the tokenised SuperBASIC program. George ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
I think, that wasn't the question. Don't confuse this with QLiberator's option "Line Numbers". As far as I know, QLiberator does not need line numbers, but this is not possible via the interpreter. It is in fact possible with the QD5 Thing to compile source code without line numbers. I think, Turbo is just able to compile a loaded SuperBASIC program, so no way to compile without line numbers. QLiberator always compile from a QSAVEd file (or QD5 Thing). Cheers...Ralf - Original Message - From: "George Gwilt" To: Sent: Saturday, April 21, 2012 10:46 AM Subject: Re: [Ql-Users] Raspberry Pi - starts On 20 Apr 2012, at 21:40, Dilwyn Jones wrote: I always thought it was a pity superBasic demanded line numbers. They were not actually necessary, and if GOTO did not exist, not even used. I think QLiberator at least can compile without line numbers (never actually tried that). Perhaps George could tell us if Turbo can too. Turbo gives three options: omitting line numbers in the compiled program, including them without displaying them during compilation and including them as well as displaying them. George ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
On 21/04/2012 09:35, Norman Dunbar wrote: Morning all, On 20/04/12 21:40, Dilwyn Jones wrote: This all sounds very interesting and possibly a fairly straightforward language for S*BASIC users to learn. I notice there's versions of Python for Windows as well as Linux etc. Anyone know if a Python program written on one platform such as Windows, be run on another such as Linux? Yes. There's a few ways to run a python program on Linux/Unix either by telling the python interpreter the name of the file: python filename.py or by putting this as the first line in the program: #!/usr/bin/env python then making it executable: chmod u+x filename.py then simply calling it: ./filename.py Under windows, only the first option is available and if the program contains the #!/usr/bin/env python line, it gets treated as a comment and completely ignored. There's also a python interpreter which sits there and waits for you to type something in, then "compiles" and executes it. > Guess if the programs are written and saved using a text editor there's a chance this might be possible, although probably endian issues might arise with numbers, for example? There's no problem with endians or numbers etc, well, not those problems anyway! There are gotchas to watch out for with numbers: print 3 / 4 0 The '/' operator is equivalent to integer DIV. If you want to get a floating point answer, you need to float one or both operands: print float(3) / float(4) 0.75 or print float(3) / 4 0.75 or, simply: print 3 / 4.0 0.75 Python is pretty nifty in it's ability to coerce variables from one type to another, so in the above, it sees one float argument and coerces the int argument into float and gives back a float answer. It doesn't coerce strings to floats, or ints: print '313' + 300 + '13' Traceback (most recent call last): File "", line 1, in print '313' + 300 + '13' TypeError: cannot concatenate 'str' and 'int' objects But you can do it implicitly: print int('313') + 300 + int('13') 626 And not necesarily in base 10 either: print int('313', 16) + 300 + int('13', 8) 1098 Which is obviously 787 + 300 + 11. Admittedly I know nothing about Python (yet... - it looks interesting) You may not know Python yet, but you are using it frequently! Calibre, your most favourite program of recent times, is written in Python. So you can see it's a capable programming language. The use of indents in interesting. You do do this in Python: #!/usr/bin/env python Dilwyn = 'Jones' Tony = 'Firshman' Malcolm = 'Cadman' if (Dilwyn == Tony): print "Tony and Dilwyn and the same person!" elif (Tony == Malcolm): print "Clones are people two!" else: print "Everyone is an individual." The colons mark the start of a block, which must be indented (4 spaces is the Python standard). The block ends when the indent comes back out. Typing the file above using into vi was interesting as it understands the indentation and did it for me automagically, probably based on the file name (ql.py). In case anyone is wondering, the "else" clause is executed. Arrays are the usual stuff but are called lists: ql_people = ["Dilwyn", "Tony", "Marcel", "Jochen", ] To print them out, for example: for person in ql_people: print "This person is: $s" % person They can also be dictionaries. These are like lists, but hava an access key, and use different open/close brackets: ql_people = {'Jones': 'Dilwyn', "Firshman": "Tony"} print ql_people['Jones'] Dilwyn So, you could use a dictionary to define a "record" of some sort: dj = {'name': 'Dilwyn Jones', 'age': 32, 'nationality': 'Welsh', 'lives in': 'Tal-y-Bont'} print dj {'nationality': 'Welsh', 'age': 32, 'name': 'Dilwyn Jones', 'lives in': 'Tal-y-Bont'} print dj['lives in'] Tal-y-Bont print dj['name'], dj['age'] Dilwyn Jones 32 You can even add functions to dictionaries. Then, a step up from dictionaries is a class. But I'll not bother with that, I think I've warbled on long enough! For Python beginners there are a couple of decent books, one of which I got free from Amazon for my Kindle: Hello Python: http://www.amazon.co.uk/Hello-Python-Anthony-Briggs/dp/1935182080/ref=sr_1_1?s=books&ie=UTF8&qid=1334995546&sr=1-1 Treading On Python Volume 1: http://www.amazon.co.uk/Treading-Python-Volume-1-ebook/dp/B00639H0AK/ref=sr_1_8?s=digital-text&ie=UTF8&qid=1334995630&sr=1-8 And a free online Python programming course: http://learnpythonthehardway.org/book/ It's quite an easy, neat language with many decent features, and (sorry Tony) far easier on the eye than Perl! Linux users probably already have Python 2.x installed. Python 3.0 is coming/available but changes quite a lot. Windows users can get an installer from ht
Re: [Ql-Users] Raspberry Pi - starts
On 20/04/2012 09:40, Dilwyn Jones wrote: So like all the BASICS, it is interpreted as it is run. Not quite the same. Yes- superBasic runs uncompiled but errors only show when they are encountered. Python (and perl - my preference) compiles first, syntax errors show then and it stops with error display - often wildly confusing if things lke closing quotes (or a dreaded ';' in Perl) is missed. Only if it compiles does it run the program. It will be interesting to see whether this happens, and which computer languages actually then get used. One of the really great features of python is no {} structure or semi-colons - it relies on indenting. This imposes good layout, which I in fact always attempt in perl ( and C). This all sounds very interesting and possibly a fairly straightforward language for S*BASIC users to learn. I notice there's versions of Python for Windows as well as Linux etc. Anyone know if a Python program written on one platform such as Windows, be run on another such as Linux? Guess if the programs are written and saved using a text editor there's a chance this might be possible, although probably endian issues might arise with numbers, for example? Admittedly I know nothing about Python (yet... - it looks interesting) I always thought it was a pity superBasic demanded line numbers. They were not actually necessary, and if GOTO did not exist, not even used. I think QLiberator at least can compile without line numbers (never actually tried that). Perhaps George could tell us if Turbo can too. GOTO and GOSUB are one thing, you can usually do without them. What about RESTORE line_number though? Dilwyn ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm The only things I know about Python are from the Cheat Sheet I mentioned earlier. But where are the equivalent of all the many other S*BASIC Keywords? Bryan H ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
On 20 Apr 2012, at 21:40, Dilwyn Jones wrote: >> >> I always thought it was a pity superBasic demanded line numbers. They were >> not actually necessary, >> and if GOTO did not exist, not even used. > I think QLiberator at least can compile without line numbers (never actually > tried that). Perhaps George could tell us if Turbo can too. Turbo gives three options: omitting line numbers in the compiled program, including them without displaying them during compilation and including them as well as displaying them. George ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
On 21/04/12 09:35, Norman Dunbar wrote: Python is pretty nifty in it's ability to coerce variables Oh no! The apostrophe! How did it get there? :-( Cheers, Norm. -- Norman Dunbar Dunbar IT Consultants Ltd Registered address: Thorpe House 61 Richardshaw Lane Pudsey West Yorkshire United Kingdom LS28 7EL Company Number: 05132767 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
On 20/04/12 23:07, Tony firshman wrote: One has a first line for Linux - #!/usr/bin/perl/ - which points to the compiler. It's better to use: #!/usr/bin/env perl because it's cross distro. Linux is standard, but different distro's put things in different locations. So, your file may not run on my laptop and vice versa if we used the hard coded path to the perl compiler (or whatever). Using /usr/bin/env will find the perl compiler no matter where it lives on my $PATH or yours. Of course, what puzzles me is the fact that I'm being told to avoid hard coding paths to perl, or python, or shells etc by hard coding the path to "env" instead - but I rather suspect that env *is* in a standard location. Cheers, Norm. -- Norman Dunbar Dunbar IT Consultants Ltd Registered address: Thorpe House 61 Richardshaw Lane Pudsey West Yorkshire United Kingdom LS28 7EL Company Number: 05132767 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [Ql-Users] Raspberry Pi - starts
Morning all, On 20/04/12 21:40, Dilwyn Jones wrote: This all sounds very interesting and possibly a fairly straightforward language for S*BASIC users to learn. I notice there's versions of Python for Windows as well as Linux etc. Anyone know if a Python program written on one platform such as Windows, be run on another such as Linux? Yes. There's a few ways to run a python program on Linux/Unix either by telling the python interpreter the name of the file: python filename.py or by putting this as the first line in the program: #!/usr/bin/env python then making it executable: chmod u+x filename.py then simply calling it: ./filename.py Under windows, only the first option is available and if the program contains the #!/usr/bin/env python line, it gets treated as a comment and completely ignored. There's also a python interpreter which sits there and waits for you to type something in, then "compiles" and executes it. > Guess if the programs are written and saved using a text editor there's a chance this might be possible, although probably endian issues might arise with numbers, for example? There's no problem with endians or numbers etc, well, not those problems anyway! There are gotchas to watch out for with numbers: print 3 / 4 0 The '/' operator is equivalent to integer DIV. If you want to get a floating point answer, you need to float one or both operands: print float(3) / float(4) 0.75 or print float(3) / 4 0.75 or, simply: print 3 / 4.0 0.75 Python is pretty nifty in it's ability to coerce variables from one type to another, so in the above, it sees one float argument and coerces the int argument into float and gives back a float answer. It doesn't coerce strings to floats, or ints: print '313' + 300 + '13' Traceback (most recent call last): File "", line 1, in print '313' + 300 + '13' TypeError: cannot concatenate 'str' and 'int' objects But you can do it implicitly: print int('313') + 300 + int('13') 626 And not necesarily in base 10 either: print int('313', 16) + 300 + int('13', 8) 1098 Which is obviously 787 + 300 + 11. Admittedly I know nothing about Python (yet... - it looks interesting) You may not know Python yet, but you are using it frequently! Calibre, your most favourite program of recent times, is written in Python. So you can see it's a capable programming language. The use of indents in interesting. You do do this in Python: #!/usr/bin/env python Dilwyn = 'Jones' Tony = 'Firshman' Malcolm = 'Cadman' if (Dilwyn == Tony): print "Tony and Dilwyn and the same person!" elif (Tony == Malcolm): print "Clones are people two!" else: print "Everyone is an individual." The colons mark the start of a block, which must be indented (4 spaces is the Python standard). The block ends when the indent comes back out. Typing the file above using into vi was interesting as it understands the indentation and did it for me automagically, probably based on the file name (ql.py). In case anyone is wondering, the "else" clause is executed. Arrays are the usual stuff but are called lists: ql_people = ["Dilwyn", "Tony", "Marcel", "Jochen", ] To print them out, for example: for person in ql_people: print "This person is: $s" % person They can also be dictionaries. These are like lists, but hava an access key, and use different open/close brackets: ql_people = {'Jones': 'Dilwyn', "Firshman": "Tony"} print ql_people['Jones'] Dilwyn So, you could use a dictionary to define a "record" of some sort: dj = {'name': 'Dilwyn Jones', 'age': 32, 'nationality': 'Welsh', 'lives in': 'Tal-y-Bont'} print dj {'nationality': 'Welsh', 'age': 32, 'name': 'Dilwyn Jones', 'lives in': 'Tal-y-Bont'} print dj['lives in'] Tal-y-Bont print dj['name'], dj['age'] Dilwyn Jones 32 You can even add functions to dictionaries. Then, a step up from dictionaries is a class. But I'll not bother with that, I think I've warbled on long enough! For Python beginners there are a couple of decent books, one of which I got free from Amazon for my Kindle: Hello Python: http://www.amazon.co.uk/Hello-Python-Anthony-Briggs/dp/1935182080/ref=sr_1_1?s=books&ie=UTF8&qid=1334995546&sr=1-1 Treading On Python Volume 1: http://www.amazon.co.uk/Treading-Python-Volume-1-ebook/dp/B00639H0AK/ref=sr_1_8?s=digital-text&ie=UTF8&qid=1334995630&sr=1-8 And a free online Python programming course: http://learnpythonthehardway.org/book/ It's quite an easy, neat language with many decent features, and (sorry Tony) far eas