FAQ  •  Register  •  Login

About POS

<<

programandala.net

Posts: 98

Joined: Fri Apr 09, 2010 12:50 am

Location: España/Hispanujo/Spain

Post Sun Apr 18, 2010 8:25 pm

About POS

I just needed the POS function to adapt a code of mine from FreeBASIC... But I didn't suspect POS is already defined in ZX Basic! I realized when the compiler halted: it seems two POS functions are too much :)

By the way, this was my definition:

  Code:
#define systemSPOSN 23688

function pos() as ubyte

   return 34-peek(systemSPOSN)

end function


First I made some tests, because I wasn't sure if the object code produced by the compiler uses the ROM routines and so the related system variables are updated as well. I find out the content of the S POSN system variable is not the same when the same code is executed by Sinclair Basic or compiled by ZX Basic:

  Code:
#define systemSPOSN 23688

cls
print at 0,0;peek(systemSPOSN) ' prints 34
print at 1,10;peek(systemSPOSN) ' prints 24
print at 2,20;peek(systemSPOSN) ' prints 14
print at 3,25;peek(systemSPOSN) ' prints 9
stop

' Sinclair Basic prints one less (33, 23, 13 and 8)!


Yes, the same program in Sinclair Basic returns lower values. It's interesting.

Anyway, it's great POS already exists. I took a look at its source file and the rest of library files. There are many interesting undocumented functions.

I created the POS page in the wiki.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sun Apr 18, 2010 8:36 pm

Re: About POS

programandala.net wrote:I just needed the POS function to adapt a code of mine from FreeBASIC... But I didn't suspect POS is already defined in ZX Basic! I realized when the compiler halted: it seems two POS functions are too much :)

By the way, this was my definition:

  Code:
#define systemSPOSN 23688

function pos() as ubyte

   return 34-peek(systemSPOSN)

end function


First I made some tests, because I wasn't sure if the object code produced by the compiler uses the ROM routines and so the related system variables are updated as well. I find out the content of the S POSN system variable is not the same when the same code is executed by Sinclair Basic or compiled by ZX Basic:

  Code:
#define systemSPOSN 23688

cls
print at 0,0;peek(systemSPOSN) ' prints 34
print at 1,10;peek(systemSPOSN) ' prints 24
print at 2,20;peek(systemSPOSN) ' prints 14
print at 3,25;peek(systemSPOSN) ' prints 9
stop

' Sinclair Basic prints one less (33, 23, 13 and 8)!


Yes, the same program in Sinclair Basic returns lower values. It's interesting.

Anyway, it's great POS already exists. I took a look at its source file and the rest of library files. There are many interesting undocumented functions.

I created the POS page in the wiki.


Thank you very much! ;-) That's the wiki is for. I was thinking we should put required #include line also, shouldn't we?
<<

programandala.net

Posts: 98

Joined: Fri Apr 09, 2010 12:50 am

Location: España/Hispanujo/Spain

Post Sun Apr 18, 2010 8:54 pm

Re: About POS

boriel wrote:I was thinking we should put required #include line also, shouldn't we?


At first I didn't understand what you mean... Then I realized I was compiling with the --sinclair option. I tried without it, and POS was not avalaible any more :) By the way, why is it considered a Sinclair Basic issue? I supossed the --sinclair option added only some Sinclair Basic specific commands, like POINT and others.

Anyway, of course the wiki should include the needed #include or option for every external command. I think we should define standard sections for every page. The FreeBASIC docs uses: Syntax, Usage, Parameters, Return value, Description, Example, Differences with QB (Sinclair Basic for us), See also... Some of them are redundant in many pages. A clear and updated documentation is very important in order to use the program. Since I'm writing a complex program in ZX Basic, I'm willing to work on the wiki at the same time.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sun Apr 18, 2010 9:07 pm

Re: About POS

programandala.net wrote:
boriel wrote:I was thinking we should put required #include line also, shouldn't we?


At first I didn't understand what you mean... Then I realized I was compiling with the --sinclair option. I tried without it, and POS was not avalaible any more :) By the way, why is it considered a Sinclair Basic issue? I supossed the --sinclair option added only some Sinclair Basic specific commands, like POINT and others.

Anyway, of course the wiki should include the needed #include or option for every external command. I think we should define standard sections for every page. The FreeBASIC docs uses: Syntax, Usage, Parameters, Return value, Description, Example, Differences with QB (Sinclair Basic for us), See also... Some of them are redundant in many pages. A clear and updated documentation is very important in order to use the program. Since I'm writing a complex program in ZX Basic, I'm willing to work on the wiki at the same time.


What --sinclair does is just include all the libraries containing SCREEN$, POINT and ATTR functions. But these libraries also contain POS and COL among other functions. Perhaps we should place these function (POS, COL) into another file?
<<

programandala.net

Posts: 98

Joined: Fri Apr 09, 2010 12:50 am

Location: España/Hispanujo/Spain

Post Sun Apr 18, 2010 9:38 pm

Re: About POS

boriel wrote:What --sinclair does is just include all the libraries containing SCREEN$, POINT and ATTR functions. But these libraries also contain POS and COL among other functions. Perhaps we should place these function (POS, COL) into another file?


I think so. They have nothing to do with Sinclair Basic.
<<

britlion

Posts: 766

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Tue Apr 20, 2010 4:42 am

Re: About POS

I hope they work. I included them under "library things" :-)

http://www.boriel.com/wiki/en/index.php ... ry#Library

Return to ZX Basic Compiler

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO