Syntax Error scr_ command

Helpful tips and guides, also new users can ask for help here.
Post Reply
thorsinclair
Trump Card
Posts: 198
Joined: Mon Jan 10, 2011 5:08 pm

Syntax Error scr_ command

Post 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


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Syntax Error scr_ command

Post 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


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
dilwyn
Mr QL
Posts: 2753
Joined: Wed Dec 01, 2010 10:39 pm

Re: Syntax Error scr_ command

Post 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


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Syntax Error scr_ command

Post 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


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
thorsinclair
Trump Card
Posts: 198
Joined: Mon Jan 10, 2011 5:08 pm

Re: Syntax Error scr_ command

Post 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


Post Reply