Syntax Error scr_ command

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

Syntax Error scr_ command

Postby thorsinclair » Thu Jul 28, 2011 10:52 am

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
QL Wafer Drive
Posts: 1423
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Syntax Error scr_ command

Postby tofro » Thu Jul 28, 2011 7:31 pm

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: 1362
Joined: Wed Dec 01, 2010 10:39 pm
Location: Wales
Contact:

Re: Syntax Error scr_ command

Postby dilwyn » Sun Jul 31, 2011 3:03 pm

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


Dilwyn
All things QL: see www.dilwyn.me.uk
User avatar
tofro
QL Wafer Drive
Posts: 1423
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Syntax Error scr_ command

Postby tofro » Sun Jul 31, 2011 3:17 pm

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: 172
Joined: Mon Jan 10, 2011 5:08 pm

Re: Syntax Error scr_ command

Postby thorsinclair » Mon Aug 01, 2011 11:54 am

@Dilwyn @Tobias,

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

Best,
Thor



Return to “Help for New Users”

Who is online

Users browsing this forum: No registered users and 1 guest