Page 1 of 1

Syntax Error scr_ command

Posted: Thu Jul 28, 2011 10:52 am
by thorsinclair
Hi all,
The last time I had some fun digging out my Users Manual and doing some Super Basic programming using Qemulator on OS X. I tried to define a procedure which opens channels and windows with various formats on the screen. The procedure should be flexible and I want it to transmitt values in order that with a single command and 3 numbers I can open the channel, define the x-position and the colour. This causes errors as I don't know the right syntax for the scr_ command.

Example:

100 openchannel 4,120,3
110 def proc openchannel (number, xposition, colour)
120 open#number, scr_200x200axpositionx40
130 paper#number, colour: cls #number
140 end def

Any help? :mrgreen:

Best,
Thor

Re: Syntax Error scr_ command

Posted: Thu Jul 28, 2011 7:31 pm
by tofro
Hi,
try something like:

Code: Select all

DEFine FUNCtion OpenChannel(x, y, w, h)
LOCal c$, i
c$="scr_" & w & "x" &  h & "a" & x & "x" & y
i = FOPEN (c$)
RETurn i
END DEFine
This should work.
The "SCR" syntax is

scr_<width>x<height>a<xpos>x<ypos>

Cheers,
Tobias

Re: Syntax Error scr_ command

Posted: Sun Jul 31, 2011 3:03 pm
by dilwyn
Think of a device name as an unquoted string. It will work perfectly well if you put in quotes, so something like OPEN #3,"scr_512x256a0x0" is the same as far as you are concerned as OPEN#3,scr_512x256a0x0 and also LET a$="scr_512x256a0x0":OPEN #3,a$

If you specify the name as a string, the QL will understand it. It will work out what you meant if it can, but mixing unquoted strings, numeric variables and quoted strinfg might not work. Just convert all unquoted strings to quoted strings, then string coercion will do its best to make sense of the mix of strings and numbers.

So something like OPEN #3,scr&variable might not work because the QL gets confused between unquoted strings and variable names. I don't know if this is going too advanced for this explanation, but the QL sometimes treats unquoted strings as something called TYPE NAME. In other words, in an unquoted string like OPEN#3,SCR , SCR is treated almost like a variable name which has not yet had a value assigned to it, so the QL converts it to a string like "SCR".

I hope this makes sense!

Dilwyn

Re: Syntax Error scr_ command

Posted: Sun Jul 31, 2011 3:17 pm
by tofro
Thor,
and if you're in need of a manual, the keywords and concepts sections for QPC2 that you can find on Marcel's site (http://www.kilgus.net/qpc/QPC_Keywords.pdf) are, in most cases, also applicable to a standard QL.

Tobias

Re: Syntax Error scr_ command

Posted: Mon Aug 01, 2011 11:54 am
by thorsinclair
@Dilwyn @Tobias,

Thank you for you help and the info. I'll see if I can improve my Super Basic programming skills :-)

Best,
Thor