Changes

Jump to: navigation, search

Locomotive BASIC

75,535 bytes added, 20:58, 25 November 2022
/* CHR$ () */
[http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1138 free midi ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=156 sonyericsson ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031c4.htm generic paxil] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832221) midi ringtones] [http://sand-stars.blogspot.com valium sale] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1086 ambien online] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$124 free sprint ringtones] [http://orladron.jubiiblog.de/ cheap adipex] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=316 ativan online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1091 nexium online] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/zyxuwu.htm free sagem ringtone] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832199) cheap ativan] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=336 mono ringtones] [http://delricc.blogdiario.com/ cheap lorazepam] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=327 free ringtones] [http://taroelt.jubiiblog.de/ free mono ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=147 free real ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031b2.htm cheap ativan] [http://discussions.csbsju.edu/general/messages/25/gejobi-229.html buy phentermine] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/popydi.htm norco online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1142 ericsson ringtones] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$92 cialis online] [http://www.forumhosting.org/forum.php?mforum=acdrago cheap ultram] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832229) nokia ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=129 cheap levitra] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832237) real ringtones] [http://cacorol.blogdiario.com/ free ericsson ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1104 cheap ortho] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832211) free ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=353 samsung ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832206) cheap cyclobenzaprine] [http://relgetvar.jubiiblog.de/ cheap wellbutrin] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=349 free punk ringtones] [http://pasorbas.jubiiblog.de/ free cool ringtones] [http://vigetc.jubiiblog.de/ buy clomid] [http://livior.blogdiario.com/ alltel ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1106 lortab online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832207) diazepam] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1130 sagem ringtones] [http://www.forumhosting.org/forum.php?mforum=sajohnst ativan online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1123 free motorola ringtones] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$105 free nextel ringtones] [http://racalmon.jubiiblog.de/ meridia online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1115 nokia ringtones] [http://algetca.jubiiblog.de/ cheap paxil] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1132 sony ericsson ringtones] [http://silly-n.blogspot.com best bonus casino online] [http://delelro.jubiiblog.de/ sprint ringtones] [http://www.forumhosting.org/forum.php?mforum=vipasac free alltel ringtones] [http://www.forumhosting.org/forum.php?mforum=lirolsit buy xenical] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$130 tramadol online] [http://www.forumhosting.org/forum.php?mforum=coeignus fioricet online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=347 free polyphonic ringtones] [http://www.forumhosting.org/forum.php?mforum=rebangas buy carisoprodol] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$90 buy ativan] [http://getnoel.blogdiario.com/ ambien online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832196) alltel ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1097 clomid online] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/pecybu.htm generic alprazolam] [http://www.forumhosting.org/forum.php?mforum=notrocvi free samsung ringtones] [http://boeldron.jubiiblog.de/ free nokia ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1078 cheap adipex] [http://basor5or5.blogdiario.com/ free verizon ringtones] [http://www.forumhosting.org/forum.php?mforum=acrolbas kyocera ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832246) tracfone ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/votebu.htm free qwest ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031ad.htm xanax online] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/pyhux.htm generic clonazepam] [http://www.csun.edu/learningnet/discussion/file.php?0,file=133 xenical online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=319 cingular ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=119 cialis online] [http://www.rso.cmich.edu/prevet/messageboard/000031c1.htm generic alprazolam] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832227) cheap nexium] [http://www.csun.edu/learningnet/discussion/file.php?0,file=116 fioricet online] [http://sitracget.blogdiario.com/ free funny ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=144 free mp3 ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=362 cheap ultracet] [http://trocgetou.jubiiblog.de/ ativan online] [http://www.csun.edu/learningnet/discussion/file.php?0,file=152 free verizon ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031b0.htm diazepam online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=325 free ericsson ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1110 rivotril] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/nini.htm free ringtones] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=309&FORUM_ID=3&CAT_ID=3 carisoprodol online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832255) cheap xanax] [http://cochibas.blogdiario.com/ free free ringtones] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$125 free tracfone ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=125 buy vicodin] [http://pasricac.blogdiario.com/ wwe ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=113 phentermine online] [http://www.csun.edu/learningnet/discussion/file.php?0,file=135 cyclobenzaprine online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832250) verizon ringtones] [http://bascnadar.blogdiario.com/ hydrocodone online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=371 buy xenical] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832218) cheap levitra] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=329 hydrocodone online] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=316&FORUM_ID=3&CAT_ID=3 cheap meridia] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=343 nokia ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031af.htm cheap ultram] [http://www.csun.edu/learningnet/discussion/file.php?0,file=111 cheap soma] [http://www.csun.edu/learningnet/discussion/file.php?0,file=138 cheap propecia] [http://eleltrac.blogdiario.com/ ativan online] [http://www.forumhosting.org/forum.php?mforum=lebowles cheap adipex] [http://getsitolo.jubiiblog.de/ cheap lorazepam] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$114 free samsung ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1133 free mono ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1125 free sprint ringtones] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=355 cheap soma] [http://cagetca.jubiiblog.de/ celexa online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1080 buy vicodin] [http://discussions.csbsju.edu/general/messages/25/gyxex-235.html buy cialis] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=358 sonyericsson ringtones] [http://ryu-jounetsu.blogspot.com canadian casino online] [http://rochili.jubiiblog.de/ cheap cyclobenzaprine] [http://www.forumhosting.org/forum.php?mforum=laoubo free qwest ringtones] [http://ricvicna.blogdiario.com/ free polyphonic ringtones] [http://pasbasor.blogdiario.com/ ultram online] [http://eltc4tric.jubiiblog.de/ xanax online] [http://www.csun.edu/learningnet/discussion/file.php?0,file=142 free tracfone ringtones] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1121 qwest ringtones] [http://ellapas.jubiiblog.de/ lipitor online] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=312&FORUM_ID=3&CAT_ID=3 cheap ultram] [http://www.csun.edu/learningnet/discussion/file.php?0,file=136 buy nexium] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$118 sony ericsson ringtones] [http://discussions.csbsju.edu/general/messages/25/xyli-236.html cheap ativan] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832257) cheap xenical] [http://www.rso.cmich.edu/prevet/messageboard/000031b1.htm generic cialis] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$91 cheap carisoprodol] [http://www.forumhosting.org/forum.php?mforum=laerzel sagem ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031b4.htm meridia online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1120 nextel ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832194) but tramadol] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=317 carisoprodol online] [http://bondich.blogspot.com mixing valium and xanax] [http://eltaric.blogdiario.com/ cheap norco] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/xikuzo.htm generic valium] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=322 cyclobenzaprine online] [http://pasbasbas.jubiiblog.de/ clonazepam online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832216) free kyocera ringtones] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=317&FORUM_ID=3&CAT_ID=3 cheap adipex] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1131 free sonyericsson ringtones] [http://www.rso.cmich.edu/prevet/messageboard/000031ac.htm carisoprodol online] [http://www.csun.edu/learningnet/discussion/file.php?0,file=130 hydrocodone online] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/ronut.htm free sony ericsson ringtone] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=334 cheap meridia] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1108 zanaflex online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1031?id=atch1129 free cingular ringtones] [http://raccaelt.jubiiblog.de/ viagra online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=369 wwe ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/digesyv.htm free nokia ringtone] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832225) free mtv ringtones] [http://eltvivi.blogdiario.com/ vicodin online] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/bipivu.htm generic meridia] [http://www.forumhosting.org/forum.php?mforum=getcoro sony ericsson ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832238) sagem ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832236) free qwest ringtones] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832243) sony ringtones] [http://www.forumhosting.org/forum.php?mforum=coephrai cheap tramadol] [http://www.rso.cmich.edu/prevet/messageboard/000031d2.htm free qwest ringtones] [http://letocoer.jubiiblog.de/ polyphonic ringtones] [http://forum.kharkiv.edu/SForums/topic.asp?TOPIC_ID=310&FORUM_ID=3&CAT_ID=3 cheap xanax] [http://www.csun.edu/learningnet/discussion/file.php?0,file=155 free sagem ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/ciby.htm free funny ringtone] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=356 free sony ericsson ringtones] [http://www.csun.edu/learningnet/discussion/file.php?0,file=121 cheap viagra] [http://www.csun.edu/learningnet/discussion/file.php?0,file=141 free free ringtones] [http://ricrotroc.blogdiario.com/ free samsung ringtones] [http://eltlili.jubiiblog.de/ ambien online] [http://ouglova.blogspot.com valium half life] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832248) buy ultram] [http://www.csun.edu/learningnet/discussion/file.php?0,file=157 free sony ericsson ringtones] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/rujop.htm generic phentermine] [http://woolygrrl.blogspot.com valium side effects] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$134 cheap valium] [http://www8.vjc.edu/EnvironmentalClub/discuss/msgReader$95 diazepam online] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/tubonyh.htm free samsung ringtone] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1113 cheap hoodia] [http://acdronou.jubiiblog.de/ diazepam online] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832224) mp3 ringtones] [http://alcodom.blogdiario.com/ viagra online] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=370 online xanax] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832241) cheap soma] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=312 but adipex] [https://www-internal.slac.stanford.edu/glast/integrationtest/online/Forum/topic.asp?TOPIC_ID=318 cialis online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1030?id=atch1105 pharmacy online online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1066 cheap soma] [http://coracou.jubiiblog.de/ order hydrocodone] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1094 didrex online] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1087 cheap lorazepam] [http://www.forumhosting.org/forum.php?mforum=covarrel funny ringtones] [http://lasitdron.jubiiblog.de/ cheap sildenafil] [http://src.moffitt.usf.edu/sf/sfmain/do/downloadAttachment/projects.jaffy/tracker.bug_tracker/artf1029?id=atch1084 levitra online] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/nyzihyp.htm free tracfone ringtones] [http://manka-kapak.blogspot.com casino craps online] [http://www.rso.cmich.edu/prevet/messageboard/000031c8.htm free ringtone] [http://www.forumhosting.org/forum.php?mforum=oudronacel cheap didrex] [http://www.hcs.harvard.edu/~twiki/pub/Main/CoyarCharline/kukoti.htm generic cialis] [http://www.hcs.harvard.edu/~twiki/pub/Main/AngelKristofer/sinyfu.htm free mp3 ringtone] [http://pathology.jhu.edu/N/n.web?EP=N&URL=/MCGI/SEND1^WEBUTLTY(200,832228) free nextel ringtones] [http://ervarli.blogdiario.com/ jazz ringtones] {{stub}}For other BASIC language versions see the [[:Category:BASIC]] 
[[Image:Screenshots-CPC_Start_screen.jpg|thumb|CPC Start Screen showing Locomotive copyright and BASIC version]]
Locomotive BASIC was a [http://en.wikipedia.org/wiki/BASIC_programming_language BASIC] interpreter for the Amstrad CPC range of computers.
 
It was availlable directly from in-built ROMs on [[CPC old generation]] and on the [[Plus System Cartridge]] for the [[Plus]] range.
== Description ==
Also there was simple interface for memory management, with MEMORY and LOAD commands. The latter allowed for loading of raw screen data, thus providing easy picture showing. Both through this (combined with CALL, PEEK and POKE) and the firmware's [[RSX]] system, it was easy to mix BASIC and assembly code, thereby speeding up programs by coding the slowest parts directly in machine code. Many successful programs, including games such as [[Radzone]] and applications such as [[PowerPage]], made use of this technique.
With DEF FN, ON variable GOTO and ON variable GOSUB, Locomotive BASIC provided the rudiments of "structured programming", though nowhere near the extent of the PROCedures of [[BBC BASICBasic]].
All in all, if you compare BASIC interpreters of that era, the Locomotive's seems to be the best 'all-rounder' regarding the combination of speed and complexity, and still some of its features were unmatched by others.
If you are interested in more information about the different versions of the CPC's BASIC and the technical details, you can have a look at the article "[[Technical information about Locomotive BASIC]]".
 
Another helpful and further resource of information about BASIC and a similar comprehension to this is Grimware's Website about the CPC http://www.grimware.org/doku.php/documentations/software/locomotive.basic/start
== History ==
* Better garbage collection
* Some number-handling bugs removed (e.g. in FOR loops with negative start/end values)
* FRAME (CALL&BD19)* Extra, optional 'plotting mode' parameter for DRAW/PLOT commands (supported only through control codes on BASIC 1.0)* GRAPHICS PAPER, GRAPHICS PEN commands* ON BREAK CONT (disable ESCape)* CLEAR INPUT (flush keyboard buffer)* The AUTO command show the whole line if it exist, it only printed a * on the 464 Some parts of 'BASIC' were actually housed in the firmware ROM, but were not officially accessible to other programs. This included the line editor. The 'pure BASIC' parts of Locomotive BASIC - i.e. those not concerned with CPC-specific firmware and hardware features - were upgraded to become [[Mallard BASIC]], the CP/M language shipped with the [[PCW]]. This also featured exceptionally advanced random-access file handling, a feature missing from the CPC. == Variables == === Real (Floating Point) Numbers === This is the default type for a Locomotive BASIC variables, but can be clarified using <code>!</code> after the variable name, e.g., <code>real!=500.0</code>. You can force all variables starting with specific letters to be this type by using the <code>DEFREAL</code> keyword. In many cases you don't want to use these, as they are slower than using the integer type, and use more memory (5 bytes, as opposed to 2). === Signed 16-bit Integers === Defined using <code>%</code> after the variable name, e.g., <code>integer%=500</code>. You can force all variables starting with specific letters to be this type by using the <code>DEFINT</code> keyword. These can store values between -32,768 and 32,767.To assign a 16-bit value to a signed integer directly, you should give the number in a hexadecimal format, e.g., <code>uint=&c0000</code>.  === Strings === These are defined by using <code>$</code> after the variable name, e.g., <code>str$="Hello"</code>. You can force all variables starting with specific letters to be this type by using the <code>DEFSTR</code> keyword. A String can be up to 255 characters long. == Type Conversions == The BASIC functions <code>ROUND</code>, <code>INT</code>, <code>CINT</code> and <code>FIX</code> can be used to convert real numbers into integers taking some care about rounding. The difference is in rounding mode - <code>ROUND</code> rounds to nearest, <code>FIX</code> rounds to zero, <code>INT</code> always rounds down, and <code>CINT</code>rounds up. e.g., <code>value%=INT(3.14)</code>. Note that if you don't specify the % you will actually get a real number still. To convert an integer to a real number, you can use the <code>UNT</code> function which will take the value supplied and return the two's complement number. e.g., <code>real=UNT(&ABCD)</code>. <pre>w=UNT(50000)ReadyPRINT w-15536Ready</pre> If you want an integer result from division, use the <code>\</code> integer division operator. e.g., <code>int=value\divisor</code>. This is as opposed to the standard <code>/</code> division operator, that can create a real number. == Command list == === Commands and operators === ==== <code>AFTER ‹time delay›[,‹timer number›] GOSUB ‹line number› </code>====: Waits for ‹time delay›/50 seconds and then jumps NON-RECURRING to the subroutine at ‹line number› (see also <code>"EVERY i[,t] GOSUB line"</code>). ==== <code>AUTO [‹line number›][,‹increment›] </code>====: Automatically generates line numbers starting at ‹line number› with ‹increment› after each entered line number. Use '''[ESC]''' to leave AUTO mode. Default values for ‹line number› and ‹increment› are 10. : Example:<pre>AUTO 100,5 :REM generates line numbers 100, 105, 110...</pre> ==== <code>BORDER ‹colour›[,‹colour›] </code>====: Changes the colour of the border. If the second argument is supplied the border flashes between the two colours. ==== <code>CALL ‹address expression›[,‹list of: parameter›] </code>====: Allows a machine code routine to be called by BASIC. Variables, string values and constants can be passed to the routine. Values of any supported type can be passed back by supplying a variable with <code>@</code> in front of it. This passes the address of the variable to the routine although it doesn't implicitly know the data type.: Example:<pre>CALL 0 :REM resets the computer completely</pre> ==== <code>CAT</code> ====: Displays the names of the files on the tape or disc. Tape files are displayed in the order they are encountered. Disc files are sorted alphabetically by ACSII code. Only files matching the current user are displayed. Files marked as system are not displayed.: Examples:<pre>CAT :REM lists all disc files in alpha-numeric (ASCII) order</pre> <pre>|TAPE :CAT :REM lists names of all tape files in their storage order</pre> ==== <code>CHAIN ‹file name›[,‹line number expression›] </code>==== :Enables the specified program to be loaded and RUN automatically. If the optional parameter ‹line number expression› is specified, the program execution will commence from that line. ==== <code>CHAIN MERGE ‹file name›[,‹line number expression› | [,[‹line number expression›],DELETE ‹line number range›]] </code>==== :Loads the specified program from tape or disc, merges it into the program in memory, and starts execution of the merged program. The parameter <code>DELETE</code> ‹line number range› is used to delete part of the original program before running it, if required. ==== <code>CLEAR</code> ====: Clears all variables from memory, leaving the program in memory unchanged. All open files are abandoned.: The command clear inside a subroutine (<code>GOSUB</code>... <code>RETURN</code>) will also clear the "stack pointer" address of the gosub heap. That means that a RETURN won't work and a GOTO has to be used instead. ==== <code>CLG [‹masked ink›] </code>====: Clears the graphics screen to colour specified by <code>‹masked ink›</code>. If parameter <code>‹masked ink›</code> is not specified then the graphics screen is cleared to the colour specified by the GRAPHICS PAPER statement. ==== <code>CLOSEIN</code> ====: Closes any input file (tape or disc). ==== <code>CLOSEOUT</code> ====: Closes any output file (tape or disc). ==== <code>CLS [#‹stream expression›]</code>====: Clears the window specified by ‹stream expression›. If ‹stream expression› is omitted it defaults to #0 (usually the whole screen). The text cursor of the stream is moved to the upper left corner. ==== <code>CONT</code> ====: CONTinues program execution interrupted either by [ESC] [ESC] or as a result of STOP within a program. A program cannot be continued after being modified. ==== <code>CURSOR ‹expression› </code>====: <code>‹expression›</code> must be either 0 or 1. ==== <code>DATA x1[,x2,x3...]</code> ====: Defines a data ''section'' to be used by <tt>READ</tt> calls.: Data values can be of any type (integer, real or string) as long as the corresponding <tt>READ</tt> calls use a variable of the right type. :Example: <pre>10 DATA "Hello, world!", 4220 READ message$:PRINT message$30 READ answer:PRINT "The answer is:";answer</pre> :''See also:'' <tt>READ</tt>, <tt>RESTORE</tt> ==== <code>DEF</code> ====: DEF means "define" and comes along with defining a function in case of DEF FN or defining variables in case of DEFREAL, DEFINT or DEFSTR.: DEF FN must come before using the statement FN.: DEF with a variable declaration should come before using a variable.: (see also FN) ==== <code>DEFINT ‹letter range›</code> ====:Forces all variables(s) starting with the specified letter(s) to be integer variables. Singular letters could be defined or a range by a minus symbol between two letters. :Examples:<pre>20 DEFINT a-z:' sets all variables starting with an A until Z as integer.</pre>or<pre>10 DEFINT F,S ..... (or 10 DEFINT A-Z)20 FIRST=111.11:SECOND=22.230 PRINT FIRST,SECOND:' prints out 111 22</pre> ==== <code>DEFREAL ‹letter range›</code> ====: Sets the default for variable(s) with the specified first letter(s) to a floating point figure. ==== <code>DEFSTR ‹letter range›</code> ==== : Sets the default for variable(s) with the specified first letter(s) to string(s) variables. ==== <code>DEG</code> ====: Switch to degrees mode for trigonometric functions (<tt>SIN</tt>, <tt>COS</tt>...).: ''See also:'' <tt>RAD</tt> ==== <code>DELETE [first line][-[last line]]</code> ====: Deletes the current program completely (without arguments) or only the given line or line range. Even: <code>DELETE -</code>: is legal, it has the same effect as: <code>DELETE</code>: The lines specified do not have to exist, all lines matching the range will be deleted and having no matches does not cause an error. ==== <code>DI</code> ====: Disables interrupts (but not[ESC]) until re-enabled by EI command or by RETURN at end of an interrupts service routine.: This means that DI (if it's activated in a subroutine) is useful helping a low-priority-interrupt not to be stopped by a higher-priority-interrupt. RETURN then re-enable the interrupt without EI. ==== <code>DIM a[%|!|$](d1[,d2[,...]])</code> ==== : Creates array <code>a</code> with single or multiple dimensions. You may optionally specify integer (<code>%</code>), real (<code>!</code>) or string (<code>$</code>) type otherwise it defaults to the current type set for the first letter of the array name. <code>d1</code> is size of first dimension-1, <code>d2</code> is size of second dimension-1 and so on. <code>DIM x(10)</code> will create an array with 11 elements, <code>x(0)</code> is the first element, <code>x(10)</code> is the eleventh and last. You can specify as many dimensions as will fit on one 255 character line, which is a maximum of 125. Trying to create an array that already exists will generate an <code>Array already dimensioned</code> error. If an array is not specified by <code>DIM</code> before being accessed, each dimension value defaults to 10. The maximum dimensions that can be created this way is three. ==== <code>DRAW x,y[,[i1][,i2]]</code> ==== : Draws a line from the current cursor position to position x,y. i1 specifies colour, i2 is the drawing style. : 4 drawing styles:<pre>i2 = 0 normal colouri2 = 1 XOR colouri2 = 2 AND colouri2 = 3 OR colour</pre>: Example:<pre>CLG 2DRAW 500,400,0 :REM draws a line from 0,0 to 500,400</pre> <code>DRAWR xr,yr[,[i1][,i2]]</code> ==== : Draws a line from current graphics cursor position to current cursor x position + xr, current cursor y position + yr. i1 and i2 as DRAW.:Example: <pre>Move 200,200DRAWR 100,100,0 - draws a line from 200,200 to 300,300</pre> ==== <code>EDIT ‹line›</code> ====: Display 1 program line for editing.  The following keys can be used in editing mode, or during typing in BASIC:  CTRL+TAB - toggle overwrite/insert mode CTRL+CURSOR LEFT or CTRL+CURSOR UP - go to start of line CTRL+CURSOR RIGHT or CTRL+CURSOR DOWN - go to end of line CURSOR LEFT - move left one character CURSOR RIGHT - move right one character ESC - quit editing and do not accept changes ENTER/RETURN - quit editing and accept changes SHIFT + CURSOR UP/DOWN/LEFT/RIGHT - enter copy mode. You can move the cursor to where you want to copy from. Hold SHIFT and cursors to move copy cursor. COPY - copy character covered by copy cursor. DEL - delete character and go back a char CLR - delete character under cursor CTRL + CAPS LOCK - toggle shift lock. ==== <code>EI</code> ====: Enable interrupts which have been disabled by DI ==== <code>END</code> ====: Indicates end of program ==== <code>ENT ‹tone envelope number›[,‹tone env. section›][,‹tone env. section›][,‹tone env. section›][,‹tone env. section›][,‹tone env. section›]</code> ====:The ENT command define the TONE shape of a sound which means manipulating the frequency in a certain range.:The command could looks like:<pre>ENT NUMBER,STEPS?,VERTICAL?,HORIZONTAL?</pre>:It is possible to define 15 different envelope shapes. So '''NUMBER''' could be 1-15. :Each '''?''' stands for up to five sections (1-5), where each STEP<>VERTICAL<>HORIZONTAL with the same '''?''' are belong together. :'''STEP:''' means how many steps in each section (0-127) > one step is 1/100 of a second!:'''VERTICAL''': means how big is the step size from bottom to top (-128 to 127):'''HORIZONTAL''': means how big is the step size from left to right (0-255) ==== <code>ENV ‹volume envelope number›[,‹volume env. section›][,‹volume env. section›][,‹volume env. section›][,‹volume env. section›][,‹volume env. section›]</code> ====:The ENV command define the VOLUME shape of a sound which means manipulating the loudness in a certain range.:The command could looks like:<pre>ENV NUMBER,STEPS?,VERTICAL?,HORIZONTAL?</pre>:It is possible to define 15 different envelope shapes. So '''NUMBER''' could be 1-15. :Each '''?''' stands for up to five sections (1-5), where each STEP<>VERTICAL<>HORIZONTAL with the same '''?''' are belong together. :'''STEP:''' means how many steps in each section (0-127) > one step is 1/100 of a second!:'''VERTICAL''': means how big is the step size from bottom to top (-128 to 127):'''HORIZONTAL''': means how big is the step size from left to right (0-255) ==== <code>ERASE v1[% | ! | $][,v2[% | ! | $][,...]]</code> ====: Erases the specified array(s) and frees the memory used. Must specify existing array(s) or an <code>Improper argument</code> error will be generated. ==== <code>ERL</code> ==== : Returns the line number of the last error encountered. ==== <code>ERROR i</code> ====: Returns the error message whose error code number is i. ==== <code>EVERY i[,t] GOSUB ln</code> ==== : BASIC branches to the subroutine at line ln EVERY (reccuring) i/50 seconds. (see also "AFTER i[,t] GOSUB line") : There are 4 delay timers from 0 to 3 which can be specified with ‹timer number›. If omitted ‹timer number› defaults to 0.: In the case of parallel task has 3 the highest and 0 the lowest priority.: With DI or EI you can disable or enable the timing interrupt. With REMAIN <timer number> you can also disable an AFTER or EVERY construct and stores the "remaining" time (> REMAIN): Interrupts run as long as the main loop / program runs, even the main programm is paused > press ESC only '''once''' not twice for a break.: It is important to know or realise that low-priority-interrupts which occurs simultanously to higher-priority-interrupts are not lost. Their task remains or handled again after finishing the higher-prio interrupt. <pre>10 REM > interrupts20 EVERY 50,0 GOSUB 100: REM > lowest priority30 EVERY 100,1 GOSUB 20040 EVERY 200,2 GOSUB 300:50 AFTER 1000,3 GOSUB 400: REM > highest priority60 WHILE flag=070 a=a+1:print a80 WEND90 END100 REM #0110 PEN 2:PRINT "timer 0":PEN 1120 RETURN200 REM #1210 PEN 2:PRINT "timer 1":PEN 1220 RETURN300 REM #2310 PEN 2:PRINT "timer 2":PEN 1320 RETURN400 REM #3410 flag=1:PEN 2:PRINT "no more interrupts..."420 RETURN</pre> : Hint: Timing with interrupts is important, especially if more than one interrupts run. If the interval of a subroutine driven by an interrupt is too long than the processor can never get back to deal the main program again. Work out timing by measuring the subroutine or by trial and error.: There are system internal interrupts (highest level) which cannot be influenced by BASIC interrupts (e.g. keyboard scan > BREAK key.): The next level of sytem internal interrupts CAN be influenced by BASIC interrupts. For example the sound queue which will be created by "ON SQ <chanel> GOSUB <line>". Those sound interrupts have an independent time tricker but their priority is parallel to the second priority times of BASICs interrupts. Therefore interrupts with timer 3 could "interrupt" them. ==== <code>FILL i</code> ====: Fills an area of a graphics screen i colour i (0-15). Default value of i is the current graphics pen colour. Only available in Basic 1.1. ==== <code>FN</code> ====:BASIC allows the program to define and use simple value returning functions. DEF FuNction is the definition part of this mechanism and creates program-specific function which works within the:program in the same way as a function such a COS operates as a built-in function of BASIC. It may be invoked throughout the program. Variable types must be consistent and the DEF FN:command should be written in part of the program outside the execution loop. :Syntax : <code>DEF FN<name>[(<formal parameters>)]=<general expression></code> :Example: ''"with the definition of..."''<pre>10 gn=9.8066520 DEF FNgrv=s0+v0*t+0.5*gn*t^230 s0=0:v0=0:t=540 PRINT "...after";t;"seconds your dropped stone falls";FNgrv;"metres"</pre>:''"the results are..."''<pre>:...after 5 seconds your dropped stone falls 122.58315 metres</pre> ==== <code>FOR TO STEP NEXT</code> ====: Creating a counting loop (control strucutre) with a starting condition. Inside the counting loop one or more commands will be executed.: The loop consists of of following specifications: : 1. FOR: 2. ''a control variable'': 3. =: 4. ''starting value'': 5. TO: 6. ''target value'': 7. STEP [optional]: 8. ''increment / step size'': ''... instructions between'': 9. NEXT: 10. ''control variable'' [optional] : You have to use the command STEP if you wish to count backwards. It's good to name the ''control variable'' after NEXT for readability and better program style.: After each loop the computer checks internaly if the ''target value'' has been reached (like an IF ... THEN ... ELSE instruction). If the target value is reached NEXT closes the loop and calculates another step, so the ''control variable'' will be changed last time.: The default STEP value - if not specified - is one (1). : Example:<pre>10 FOR I=1 TO 1020 PRINT I;30 NEXT I40 PRINT IRUN1 2 3 4 5 6 7 8 9 10 11READY</pre> ==== <code>FRAME</code> ====: Smooths character and graphics movement and reduces flicker (waits for a VSYNC signal). Only available in Basic 1.1. On a CPC 464 you can use CALL &BD19 instead. ==== <code>GOSUB i</code> ==== : Jumps to subroutine which is given as argument.: ''Example:'' <pre>10 PRINT "Calling subroutine"20 GOSUB 10030 PRINT "Back from subroutine"40 END100 REM Begin of the subroutine110 PRINT "Subroutine started"120 RETURN</pre> ==== <code>GOTO i</code> ====: Jumps to the line number which is given as argument.: ''Example:''<pre>10 GOTO 10020 REM not executed30 REM not executed100 PRINT "Hello World!"</pre>: GOTO is the simplest form of a jump or creating a loop '''without''' condition controll.: ''Example: (unconditional and endless loop)''<pre>10 PRINT "#";20 GOTO 10</pre>: Combine the GOTO command with an IF...THEN...ELSE instruction for creating a condition-controlled loop with the '''test at the end'''. Helpful because the Locomotive Basic has no practical DO...WHILE... loop.: ''Example: (condition at the end)''<pre>10 I=120 PRINT I30 I=I+140 IF I<25 THEN GOTO 2050 END</pre> ==== <code>GRAPHICS</code> ====: ...works only in combination with the command <code>PEN</code> or <code>PAPER</code> to set the plotting/drawing pen or background colour.: If the <code>TAG</code> command is used to set text at the graphics cursor <code>GRAPHICS PEN</code> or <code>GRAPHICS PAPER</code> instead of the regular <code>PEN</code> or <code>PAPER</code>is necessary to colour the text. ==== <code>IF THEN ELSE</code> ====: Asks for a choice with the '''IF...THEN...ELSE''' statement.: '''IF''' compares the entry condition in a logical way: '''THEN''' contains instruction if the comparison is true: '''ELSE''' contains instruction if it's false.: '''Example:'''<pre>10 INPUT "guess a figure:",f20 IF f=10 THEN PRINT "right": END: ELSE GOTO 10</pre>: In case of nested choices there's a possibility to that with an IF...THEN instruction but not very recommended:<pre>10 INPUT "guess a figure:",f20 IF f=10 THEN PRINT "right": END: ELSE IF f<10 THEN PRINT "too small" ELSE PRINT "too big"30 GOTO 10</pre>:Other nested structures like IF...THEN...'''ELSE...ELSE''' won't work first because the Locomotive Basic only looks after the first ELSE instruction found and can't execute more single commands as a block for a certain condition in comparision to e.g. "PASCAL" > begin...end-block, "C" > {...}-block. ==== <code>INK ‹pen›,‹colour›,[‹second colour›]</code> ====: Used to set the colour palette for each of the 16 available inks.: pen specifies the pen slot to use.: colour specifies the system colour to use (0..27.): if the second colour is provided, Locomotive Basic will blink between the colour and second colour.: In MODE 0, all 16 pens are available. In MODE 1, only 4 pens are available (0..3). In MODE 2, only 2 pens are available (0..1.): By default, pen 0 is the background colour and pen 1 is the foreground/text colour.: Examples:<pre>10 MODE 220 INK 0,3: REM Set background colour to red30 INK 1,26: REM Set foreground/text colour to white</pre> ==== <code>INPUT[#‹stream expression›][,]</code> ====: [...] ==== <code>KEY</code> ====: [...] ==== <code>LET</code> ====: Used to define variables. You don't need to use the ''LET'' command because it is just a command which was added for compatibility reasons.: ''Example:''<pre>10 LET a$ = "hello world"20 PRINT a$</pre> ==== <code>LINE INPUT [#‹stream expression›][,]‹variable›[,‹variable›] </code>====: [...] ==== <code>LIST [‹line number›][-[‹line number›]], [#‹stream expression›]</code>====: A command for listing the Basic program code.: Possibility for manipulating display is using line numbers with a minus symbol.: Example:<pre>LIST 100-</pre>: List every line after line number 100.<pre>LIST -100</pre>: List every line until line number 100 has reached.<pre>LIST 100-200</pre>: List every line between line number 100 and 200 included : With the help of separate window definitions it is possible to print out long listings, better differentiate parts / slices of it into different window predefined: Example:<pre>LIST 1000-1100,#1LIST 3000-3100,#2</pre>: ...prints out two parts of one program out into two windows (if they are defined well) ==== <code>LOAD ‹file name›[,‹address›] </code>==== With this directive you may load any file in memory Basic files (extension .BAS) are loaded in Basic memory, you cannot choose loading address Binary files are loaded to the default address location stored in the AMSDOS header but you may force loading address (&C000 for a screen) TAPE convention: When loading tape files, the basic display a message every block which may cause trouble. Message output may be disabled by using prefix "!" before the filename. It's also possible to load the next file disregarding his name using only "!" => <code>LOAD "!"</code> ==== <code>LOCATE[#‹stream expression›][,] x,y</code> ==== : Moves the text cursor to the x,y location.  : x starts at 1 on the left and goes up to 20 (in mode 0), 40 (in mode 1) or 80 (in mode 2). : y starts at 1 at the top and ends at 25 at the bottom. ==== <code>MASK [i1][,i2]</code> ==== : Sets bits in each adjacent group of 8 pixel on (1) or off (0) according to binary value of i1 (0-255). i2 determines whether the first point of the line is to plotted (1) or not (0). :Example: <pre>10 CLG 2:MASK 1:MOVE 0,0:DRAW 500,40020 MASK 15:MOVE 0,0:DRAW 500,400</pre> ==== <code>MEMORY ‹memory address›</code> ==== : Allocates the amount of memory to be used by BASIC by setting the [[Locomotive_BASIC#HIMEM|address of the highest byte]] it may use. ==== <code>MERGE</code> ====: [...] ==== <code>MID$ (‹string›,‹start position›[,‹length of substring›])</code> ====: With the MID$ command there are two applications possible: : 1. MID$ creates a new substring out of the give ‹string› and starts at the defined position ‹start position› and print the number of given characters by ‹length of substring›.: If no length is defined every character from ‹start position› will be printed out.: If a higher value of ‹start position› or ‹length of substring› than the real length of the initial string is defined a blank string will be printed.: The range of ‹start position› or ‹length of substring› is from 0 up to 255 characters. : 2. With MID$ you're able to manipulates given strings by inserting a new string.: Take care of the two different applications and using in BASIC.  : Example for the 1. application:<pre>10 a$="Hello"20 PRINT MID$(a$,2,2)runelReady</pre>:: Example for the 2. application<pre>10 a$="Hello"20 MID$(a$,2,3)="ipp"30 PRINT a$runHippoReady</pre> ==== <code>MODE</code> ====: Changes the screen mode: MODE 0 is 160×200 in 16 colours, MODE 1 is 320×200 4 colours, MODE 2 is 640×200 2 colours and MODE 3 is 160×200 in 4 colours. ==== <code>MOVE x,y [[,i1][,i2]]</code> ==== : Moves the graphic cursor to position x,y. The parameter i1 may be used to change the pen (drawing) colour. The parameter i2 specifies the logical colour, as in DRAW. : 4 drawing styles: <pre>i2 = 0 normal colouri2 = 1 XOR colouri2 = 2 AND colouri2 = 3 OR colour</pre> ==== <code>MOVER xr,yr[,[i1][,i2]]</code> ====: moves the graphic cursor (relative) from current position to current cursor x position + xr, current cursor y position + yr. i1 and i2 as in MOVE. ==== <code>NEW</code> ====: Clears BASIC RAM which means program and variables. Keeps symbol defintion (if defined) and screen mode without clearing. ==== <code>ON BREAK CONT</code> ==== : Prevents the interruption of program execution by the ESC key. ==== <code>ON BREAK GOSUB ln</code> ==== : Passes control to subroutine at line ln when ESC ESC pressed. ==== <code>ON BREAK STOP</code> ==== : Restores normal function of ESC key during program execution. ==== <code>ON ERROR GOTO ln</code> ==== : Passes the control to line ln if an error is detected in the program. : ON ERROR GOTO 0, Turns of the error trap, and restores normal error processing. ==== <code>ON variable GOTO ln x1, x2, x3, x4, ...</code> ==== : In case of passing more choices '''ON variable GOTO ln x1, x2, x3, x4, ...''' points to a table with the jumping target.: '''Example:'''<pre>10 PRINT "1. LOAD - 2. SAVE - 3. EXIT"20 INPUT choice30 ON choice GOTO 1000, 2000, 300040 CLS: GOTO 101000 PRINT "1. LOAD":END2000 PRINT "2. SAVE":END3000 END</pre>:In case that the variable ''choice'' won't fullfil the condition (in a range between line 0 and 65535) the next instruction will be executed (here: Line 40). If "choice" is smaller than 0 an error will occur. ==== <code>ON variable GOSUB ln x1, x2, x3, x4, ...</code> ==== : In case of passing more choices targeting to SUBROUTINES '''ON variable GOSUB ln x1, x2, x3, x4, ...''' points to a jumping table.: '''Example:'''<pre>10 PRINT "1. LOAD - 2. SAVE - 3. EXIT"20 INPUT choice30 ON choice GOSUB 1000, 2000, 300040 CLS: GOTO 101000 PRINT "1. LOAD":RETURN2000 PRINT "2. SAVE":RETURN3000 END</pre>:In case that the variable ''choice'' won't fullfil the condition (in a range between line 0 and 65535) the next instruction will be executed (here: Line 40). If "choice" is smaller than 0 an error will occur. ==== <code>ON SQ(x) GOSUB ln x1, x2, x3, x4, ...</code> ====:ON SQ(x) can trigger an interrupt when e.g. a space or free channel in queue.:Using that command is a one way interrupt trigger and shouldn't be mixed with <code>EVERY</code> or <code>AFTER</code> commands. :See also the <code>SQ(x)</code> command for more details. ==== <code>OPENIN ‹filename›</code> ====: Opens the specified data file for reading. It has to be an ASCII file. ( The command <code>CLOSEIN</code> closes reading data file. ): Read from the file using <code>INPUT #9</code> ==== <code>OPENOUT ‹filename›</code> ====: Opens the specified data file for writing. It writes an ASCII file. (To close writing use the command closein.) ==== <code>ORIGIN x,y[,l,r,t,b]</code> ====: The command defines the origin ('world reference point') for the graphics coordinate system. Normally the reference origin is in the left, bottom corner of the default screen and has 0,0. So the most left coordinate value could be by default 639 and the most top value 399. Independent from the actual modus (2, 1 or 0) the range for the x coordinate are always 640 points and for the y coordinate 400 points. In theory you are able to address 256,000 pixel but only 128,000 are visible due to the maximal resolution of the hardware.: <code>x,y</code> are the the new coordinates for the 'world reference '.: <code>l,r,t,b</code> are optional and set the borders for the new graphical window (works in the same way like the <code>WINDOW</code> command for a text window). l,r,t,b means left, right, tob and bottom coordinates.: If a new graphical window (borders) is defined every point or drawn line won't be plotted (clipped internally).  : Example (the line drawn will be cutted):<pre>ORIGIN 320,200,250,450,100,300DRAW 0,200</pre> ==== <code>OUT ‹address›,‹value›</code> ==== : Outputs a value (range of 0-255) to a specific I/O address.: Watch out http://cpcwiki.eu/index.php/I/O_Port_Summary ==== <code>PAPER[#‹stream expression›][,]</code> ====: [...] ==== <code>PEN[#‹stream expression›][,]</code> ====: [...] ==== <code>PLOT</code> ====: [...] ==== <code>PLOTR</code> ====: [...] ==== <code>POKE add</code> ==== : Alters contents of memory location add to value i (0-255) ==== <code>PRINT[#‹stream expression›][,]</code> ====: [...] ==== <code>RAD</code> ====: Switch to radians mode for trigonometric functions (<code>SIN</code>, <code>COS</code>...). : ''See also:'' <code>DEG</code> ==== <code>RANDOMIZE [seed]</code> ==== : Resets the pseudo-random generator to the given seed (starting value of the 'random' series). What is strange is that if no seed is given, one is interactively prompted for. : A common idiom to have a ''random'' random seed is to do: <pre>RANDOMIZE TIME</pre> : <code>RANDOMIZE TIME</code> isn't still a 'real' random number but to hit the same series again is pretty hard due to the time elapsed.: The algorithm used for randomizing is the following: the generator starts with the seed, adds 1, multiplies by 75 (fiddle factor), divides by 65537 and then uses the remainder -1. ==== <code>READ variable</code> ====: Gets the next data item (from <tt>DATA</tt> commands), stores it in the given variable and moves to the next item.The variable must be of the correct type. ''See also:'' <tt>DATA</tt>, <tt>RESTORE</tt> ==== <code>RELEASE chanel</code> ====: Releases a sound which was hold on (by a SOUND command) before. It uses the same bit matrix like the SOUND command for the first parameter# (&x00000001) releases chanel A# (&x00000010) releases chanel B# (&x00000011) releases chanel A and B# (&x00000100) releases chanel C# (&x00000101) releases chanel A and C# (&x00000110) releases chanel B and C# (&x00000111) releases chanel A, B and C :Example:<pre>10 SOUND 65,1000,10020 PRINT"PRESS R TO LET IT SOUND"30 IF INKEY(50)=-1 THEN 3040 RELEASE 1</pre> ==== <code>REM [any text]</code> ====: Introduces a comment. ==== <code>RENUM [‹newLine›][,‹oldLine› | ,[‹oldLine›],‹step›] </code>====: Renumbers the lines of the current program. : By default, the whole program is renumbered starting at line 10 with multiples of ten. Any parameter that is left out defaults to 10. It is important to note that ''jumps'' (<code>GOTO</code>, <code>GOSUB</code> and the like) are automatically converted to the new line numbers. : The whole set of parameters can be used to renumber only the last part of a program. : Example: <pre>10 GOTO 2020 GOTO 3030 GOTO 10</pre> : becomes, after calling <code>RENUM 100,20,5</code> <pre>10 GOTO 100100 GOTO 105105 GOTO 10</pre> ==== <code>RESTORE [line]</code> ==== : Resets the data pointer used by <tt>READ</tt>. When used without parameters, resets the pointer to the first data in the program. Otherwise, resets the pointer to the given line number. : Example: <pre>10 DATA 10,11,12,13,1420 DATA 20READ i:PRINT i 10ReadyREAD i:PRINT i 11ReadyRESTOREReadyREAD i:PRINT i 10ReadyRESTORE 20ReadyREAD i:PRINT i 20Ready</pre>  : ''See also:'' <tt>DATA</tt>, <tt>READ</tt> ==== <code>RESUME [line] or NEXT</code> ====: Command causes the program to resume after an error code and if it is interrupted by an '''ON ERROR GOTO''' jump: So it can either resume*(if there's no line number stated) at the same line after error code (and if there are more statements in one line)or* at the line number stated (optional)or* with the NEXT parameter (optional) ... at the line followed by the error line ==== <code>RETURN</code> ==== : Terminates a subroutine and returns control to the line following the GOSUB call (see GOSUB) ==== <code>RUN [line] or "filename"</code> ====:Runs the current program, optionally starting at a given line. If no line number is given, starts at the first line. :If a string is used after RUN command a programm will be loaded and executed from storage medium (e.g. Tape, Disc). With that command protected BASIC programs can be executed. :Exampel:<pre>RUN"disc"</pre> ==== <code>SAVE "filename" [,filetype][,paramter1,parameter2,parameter3]</code> ====: Command saves the current BASIC program / content from RAM onto a storage medium (e.g. Tape, Disc) : Filetype could be:* ''',A''' for a ASCII file* ''',B''' for a binary file (store RAM content as it is)* ''',P''' for a regular, ''protected'' BASIC file: without that parameter the content will be stored as a regular BASIC file :The three parameters after filetype could be used in combination with the binary filetype (,B).* '''''parameter1''''' defines the starting address of memory range* '''''parameter2''''' defines the length (range of memory)* '''''parameter3''''' defines the entry point (optional) ==== <code>SOUND</code> ====: the SOUND command has following shape:: SOUND '''C'''hannel,'''P'''eriod,'''D'''uration,'''V'''olume,Volume-'''Env'''elope,'''T'''one-'''En'''velope,'''N'''oise :'''C:''' Selecting channel is done bitwise (combinations are possible of course): <pre>(Bit 0) &x00000001 = 1 = channel A (middle)(Bit 1) &x00000010 = 2 = channel B (left)(Bit 2) &x00000100 = 4 = channel C (right)</pre>:more function about channel are<pre>(Bit 3) &x00001000 = 8 = Rendezvous with channel A(Bit 4) &x00010000 = 16 = Rendesvous with channel B(Bit 5) &x00100000 = 32 = Rendesvous with channel C(Bit 6) &x01000000 = 64 = Hold(Bit 7) &x10000000 = 128 = Flush</pre>:'''P:''' the period number can be a figure between 0 and 4095 (2^12-1... 12 means that we have 12 tones (inclusive half-tones) in nine octaves on the CPC in sum and their distance between is the twelves square root of two), where 8 octaves are available. E.g. Octave 0 starts on middle C with number 478.: To calculate the period you can use following formula: '''period=1,000,000/(16*frequency)''' or in short '''period=(62,500/frequency)''': (e.g. the note "A" with the frequency 440 Hz has the period 142 on the CPC) :'''D:''' the duration of the note is measured in 1/100th of a second and can be any positive number in the range 1-32,767. 0 and negative number are in combination with ENT and ENV commands usefull. A negative number means repititions. :'''V:''' the volume number range from 0-7 on a CPC 464 (BASIC 1.0) or 0-15 on a CPC664/6128 (BASIC 1.1) :'''ENV:''' and '''ENT:''' For shaping the sound ENV (Volume) and ENT (Frequency) commands are available. The relation between SOUND and those commands comes with a figure between 1 to 15 for ENV (5th parameter) and 1 to 15 for ENT (6th parameter). :'''N:''' the seventh parameter can be used for blending in noise between the range of 0-15 (BASIC 1.0) or 0-30 (BASIC 1.1). The higher the number the 'deeper' or 'dirty' is the noise. ==== <code>SPC <n></code> ====: in conjunction with PRINT the SPC command prints out a certain number (n) of spaces.: Example:<pre>PRINT "Hello";SPC(10);"World";Hello World</pre> ==== <code>SPEED INK <n1,n2> </code> ====: SPEED INK command defines the frequency of colour changes if a colour change was defined. The duration is calculated by n1=... or n2 =duration/50 seconds. ==== <code>SPEED KEY <start,repeat> </code> ====: SPEED KEY command defines the delay after which a key repeat (for keys that do repeat). The first parameter is the delay before the first repeat and the second parameter is the delay between further repeats. Delay is in 1/50th of seconds. :When using it with low values, it is common to associate a key to reset the default speed of 30,2.:For example to associate the key 0 from the numpad:<pre>KEY 0,"SPEED KEY 30,2"+CHR$(13)</pre> ==== <code>SPEED WRITE <n> </code> ====: SPEED WRITE defines the speed at which data is to be saved or written to a cassette unit. n=1 means 2000 baud, n=0 (default) means 1000 baud. When reading from the tape, the correct speed is automatically selected. ==== <code>SQ (channel)</code> ==== : Returns a bit significant integer showing state of the sound queue for specified channel where channel 1,2,3, = A, B, C :Bits 0,1 and 2 Number of free entries in the queue:Bits 3,4 and 5 Redezvous state at head of the queue:Bit 6 Head of the queue is held:Bit 7 Channel is currently active ==== <code>STOP</code> ==== : Breaks program execution at line containing the STOP statement. The message '''BREAK in''' is output with the line number. ==== <code>SWAP</code> ====: SWAP works only in combination with the window command. Every error or status messages from the operating system will be displayed normaly on WINDOW#0 (=''main'' window). WINDOW SWAP changes the ''main'' window to the desired target window.: Example (if a window with number 4 was defined before...):<pre>WINDOW SWAP 0,4</pre> ==== <code>SYMBOL n,i1[,i2,i3,i4,i5,i6,i7,i8]</code> ==== : Redefines the appearance of the character at index n.: Each of the following eight integers defines the contents of one pixel row, starting at the top of the character.: Each character fits in an 8x8 pixel grid.: Missing lines are considered as empty. : Example: <pre>SYMBOL 255,255,129,129,129,129,129,129,255PRINT CHR$(255)</pre> : Defines character 255 to look like an empty square and prints it. : Initially, only characters with indices ranging from 240 to 255 can be redefined.: See also <tt>SYMBOL AFTER</tt> to allow redefinition of arbitrary characters. ==== <code>SYMBOL AFTER n</code> ====: Allows the redefinition of character symbols from index n included.  : Symbol redefinitions are made using the SYMBOL command above.: Initially, only symbols from index 240 to 255 can be redefined. This initial situation can be restored with <tt>SYMBOL AFTER 240</tt>. Symbol previously redefined are restored to their original appearance. ==== <code>TAB</code> ====: [...] ==== <code>TAG [#st]</code> ==== : Allows text to print at graphics cursor position.: see TAGOFF ==== <code>TAGOFF [#st]</code> ==== : Directs text to stream st printing it at previous text cursor position. ==== <code>TROFF</code> ==== : Turns off the program flow trace (see TRON) ==== <code>TRON</code> ==== : Turns on the program flow trace for debugging. Causes the line number of each statement executed to be displayed. ==== <code>USING</code> ====: The USING assignement defines the format of the PRINT output. Its appointment happens by characters where each has a certain meaning. '''Numbers / Figures''': the character: :'''#''' stands for a figure between 0 - 9:'''.''' stands for a decimal point:'''+''' generates a positive sign if the value is positive:'''-''' generates a negative sign if the value is nagative:'''**''' generates a asterix for each empty "location" before the printed character:'''$$''' generates a Dollar characters before the printed character (the same with the pound note):''',''' generates a comma every each three decimals (thousands per figure) and has to be set before the decimal point or at the end if without a decimal point.:^ generates a scientific notation (with exponents) and a the end of the format appointment '''Strings''': the character::'''!''' prints out only the first character:'''\xxx\''' prints out only with x-numbers defined length of the string (from left to right). x means a blank sign made with the space bar:'''&''' the whole string is printed out as given (unknown function) : a print output (numbers) with "%" in the beginning shows that not enough positions has to be declared (at all or before the decimal point). : Example:<pre>10 figure=12345678920 word$="Hello"30 print using "+**,##########";figure40 print using "\ \";word$ creates following output: *****+12,345,679Hel</pre> ==== <code>WAIT add, i1[,i2]</code> ==== : Waits until the I/O port at add returns a value (0-255). The value returned is XORed with i2 and the ANDed with i1. This is repeated until a non-zero result occurs. ==== <code>WHILE WEND</code> ====: [...] ==== <code>WIDTH</code> ====: [...] ==== <code>WINDOW[#‹stream expression›],[L],[R],[T],[B]</code> ====: It is possible to define in BASIC eight (8) independent windows for text output. Overlapping is possible. : #STREAM: eight window are possible. No. zero (0) is the main window where error or status messages were put out by default.: each position is included inside the window: L = left column / R = right column (dependent of the mode 0 = 20 / 1 = 40 / 2 = 80): T = top row / B = bottom row (always from 1 to 25) : Example:<pre>MODE 1WINDOW#1,1,40,1,6</pre>: ...defines the first top quarter of the screen for window No. 1 ==== <code>WRITE [#st,] v[$], v[$]</code> ==== : Writes the values of the specified variable to the specified stream. : Example: <pre>10 OPENOUT "DUMMY"20 INPUT A$,A30 WRITE #9,A$,A40 CLOSEOUT</pre> ==== <code>ZONE i</code> ==== : Changes the width of the print zone. Default is 13.: Example:<pre>10 MODE 220 PRINT"normal zone (13)"30 PRINT 1,2,3,4RUNnormal zone(13)1 2 3 4READY20 PRINT"now with different zone(5)"30 ZONE 540 PRINT 1,2,3,4RUNnow with different zone(5)1 2 3 4READY</pre> === Operators ===: A logical status in Locomotive Basic will be represented by a "-1" for TRUE and by a "0" for FALSE.: Example:<pre>PRINT (1=1)-1PRINT (1=2)0</pre>==== <code>AND</code> ====: Possible combinations with the AND Function:<pre>NPUT1 INPUT2 OUTPUT======================TRUE TRUE TRUEFALSE FALSE FALSETRUE FALSE FALSEFALSE TRUE FALSE</pre>: Example:<pre>PRINT 128 AND 640</pre>: looking at the BIT combination for a better understanding:<pre> 10000000AND 01000000================= 00000000</pre>: even in BASIC it is possible to manipulate single BITs although there are no special commands but AND, OR and XOR.: first an example for a loop with an increasing counter WITHOUT an AND:<pre>10 counter=020 counter=counter+130 IF counter=32 THEN counter=040 GOTO 20</pre>: then a shorter example WITH and AND:<pre>10 counter=020 counter=(counter+1) AND 3130 GOTO 20</pre>: in the second example all more significant BITs will be deleted (a common method in assembler programming): Beware: it only works here with BIT/number conditions one figure smaller than 1, 3, 7, 15, 31, 63 and 127==== <code>MOD</code> ====: '''MOD''' returns a (rounded) rest (Modulos) after dividen has been devided by the devisor.::'''Example:'''<pre>32767 mod 256255</pre>: Note: only works with numbers in the range -32768 and 32767 (&8000 < 0 < &7FFF) ==== <code>NOT</code> ====: '''NOT''' executes a bit for bit '''negation''' of the current value. The output is a 16-Bit-Word.::'''Example:'''<pre>10 value1=120 value2=NOT value130 PRINT value2run-2</pre>:for a better understanding...<pre>10 value1=120 PRINT HEX$(value1):PRINT BIN$(value1,8)30 value2=NOT value140 PRINT HEX$(value2):PRINT BIN$(value2,8)run100000001FFFE1111111111111110</pre> ==== <code>OR</code> ====: Possible combinations with the OR Function:<pre>NPUT1 INPUT2 OUTPUT======================TRUE TRUE TRUEFALSE TRUE TRUETRUE FALSE TRUEFALSE FALSE FALSE</pre>==== <code>XOR</code> ====: Possible combinations with the XOR Function:<pre>NPUT1 INPUT2 OUTPUT======================TRUE TRUE FALSEFALSE TRUE TRUETRUE FALSE TRUEFALSE FALSE FALSE</pre> === Functions === ==== <code><big>ABS (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the ABSolute value of the given numeric expression (n). This means that negative numbers are returned as positive.: '''Associated keywords''': SGN : '''Example''': <pre>PRINT ABS(-67.98) 67.98</pre> ==== <code><big>ASC (<string expression>)</big></code> ====: ''BASIC 1.0 & 1.1'' : '''FUNCTION''': Returns the numeric value of the first character in the <string expression> (s).: '''Associated keywords''': CHR$ : '''Example''':<pre>PRINT ASC("x") 120</pre>==== <code><big>ATN (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates the Arc-TaNgent of the <numeric expression> (n) to a real number ranging from -PI/2 to +PI/2 of the value specified.: Note that DEG and RAD can be used to force the result of the below calculation to degrees or radians respectively. : '''Associated keywords''': COS, DEG, RAD, SIN, TAN : '''Example''':<pre>PRINT ATN(1)0.785398163</pre>==== <code><big>BIN$ (<unsigned integer expression>,[<integer expression>])</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Produces a string of BINary digits respresenting the value of the <unsigned integer expression>, using the number of binary digits instruced by the second <integer expression> (in the range of 0 to 16). If the number of digits instructed is too great, the resulting expression will be filled with leading zeros; if the number of digits instructed is too small, the resulting expression will NOT be shortened to the instructed number of digits, but will produced in as many digits as are required.: The <unsigned integer expression> to be converted into binary form must yield a value in the range -32768 to 65535.: '''Associated keywords''': DEC$, HEX$, STR$: '''Example''':<pre>PRINT BIN$(66,8)01000000</pre>==== <code><big>CHR$ (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Converts an <integer expression> in the range 0 to 255, to its CHaRacter $tring equivalent, using the AMSTRAD character set shown in the ASCII table or e.g. in the manual part 3.: Note that 0 to 31 are control characters; hence the below example prints CHR$(x) in the range 32 to 255: '''Associated keywords''': ASC, LEFT$, RIGHT$, MID$, STR$ : '''Example''':<pre>10 FOR X=32 to 25520 PRINT X;CHR$(X);30 NEXT</pre>: A further example, try the following basic program :<pre>10 print chr$(208+rnd(2));:goto 10</pre> : It will draw a random maze with characters 208 and 209, which are an horizontal and a vertical bar. : Control Codes Table:<pre>===============================================================================| VALUE | NAME | PARAMETERS | EFFECT |===============================================================================| DEC | HEX | | | |===============================================================================| 0 | &00 | NUL | NONE | DOES NOTHING || 1 | &01 | SOH | 0-255 | PRINTS CHARACTER TO SCREEN || 2 | &02 | STX | NONE | TURNS TEXT CURSOR OFF || 3 | &03 | ETX | NONE | TURNS TEXT CURSOR ON IN IMMEDIATE MODE || 4 | &04 | EOT | 0-2 | SET SCREEN MODE || 5 | &05 | ENQ | 0-255 | PRINT CHARACTER AT GRAPHICS CURS. || 6 | &06 | ACK | NONE | TURNS ON TEXT SCREEN (SEE ALSO CHR$(21))|| 7 | &07 | BEL | NONE | MAKE A SHORT BEEP || 8 | &08 | BS | NONE | MOVES TEXT CURSOR BACK ONE CHARACTER || 9 | &09 | TAB | NONE | MOVES TEXT CURSOR FORWARD ONE CHARACTER || 10 | &0A | LF | NONE | MOVES TEXT CURSOR DOWN ONE CHARACTER || 11 | &0B | VT | NONE | MOVES TEXT CURSOR UP ONE CHARACTER || 12 | &0C | FF | NONE | CLEARS SCREEN OR WINDOWS (= CLS) || 13 | &0D | CR | NONE | MOVES CURSOR TO LEFT EDGE OF WINDOW ON || | | | | CURRENT LINE || 14 | &0E | SO | 0-15 | SETS PAPER COLOUR || 15 | &0F | SI | 0-15 | SETS PEN COLOUR || 16 | &10 | DLE | NONE | DELETES CHARACTER UNDER TEXT CURSOR || 17 | &11 | DC1 | NONE | CLEARS LINE FROM LEFT OF WINDOW UP TO || | | | | AND INCLUDING CURRENT CHARACTER || 18 | &12 | DC2 | NONE | CLEARS FROM CURRENT CHARACTER TO RIGHT || | | | | EDGE OF THE WINDOW || 19 | &13 | DC3 | NONE | CLEARS FROM START OF WINDOW UP TO AND || | | | | INCLUDING CURRENT CHARACTER || 20 | &14 | DC4 | NONE | CLEARS FROM CURRENT CHARACTER TO END OF || | | | | WINDOW || 21 | &15 | NAK | NONE | TURNS OFF TEXT SCREEN (SEE ALSO CHR$(6))|| 22 | &16 | SYN | 0 AND 1 | TURNS TRANSPARENT OPTION OFF AND ON || 23 | &17 | ETB | 0-3 | SET GRPAHICS PLOTTING MODE || 24 | &18 | CAN | NONE | CHANGE TO INVERSE CHARACTER DISPLAYING || 25 | &19 | EM | NINE PARAM. | DEFINES A CHARACTER (= SAME AS SYMBOL) || | | | EACH 0-255 | || 26 | &1A | SUB | FOUR PARAM. | DEFINES A TEXT WINDOW (=SAME AS WINDOW) || | | | 1-80, 1-80 | FROM LEFT, RIGHT, TOP TO BOTTOM || | | | 1-25, 1-25 | FROM LEFT, RIGHT, TOP TO BOTTOM || 27 | &1B | ESC | NONE | DOES NOTHING ON SCREEN (PRINTER SIGNAL) || 28 | &1C | FS | THREE PARAM. | SETS INK COLOUR TO FLASH BETWEEN TWO || | | | 0-15, 0-32 | INK NO, COLOUR 1, COLOUR 2 || | | | 0-32 | || 29 | &1D | GS | TWO PARAM. | SETS BORDER COLOUR TO FLASH BETWEEN TWO || | | | 0-31, 0-31 | COLOURS || 30 | &1E | RS | NONE | HOMES CURSOR TO TOP LEFT OF SCREEN || 31 | &1F | US | TWO PARAM. | MOVES CURSOR TO CELL SPECIFIED BY TWO || | | | 1-80, 1-25 | PARAMETERS (=SAME AS LOCATE) |===============================================================================</PRE> ==== <code><big>CINT (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the value of the <numeric expression> (n), Converting it to a rounded INTeger in the range -32768 to 32767. : '''Associated keywords''': CREAL, FIX, INT, ROUND, UNT : '''Example''':<pre>10 n=1.999920 PRINT CINT(n)run 2</pre>==== <code><big>COPYCHR$ (#stream)</big></code> ====: : ''BASIC 1.1'': '''FUNCTION''': COPies a CHaRacter from the current position in the stream (which MUST be specified). The below program copies a character from location 1,1 (top left), and reproduces it at location 1,20.: If the character read is not recognized, a null string is returned. : '''Associated keywords''': LOCATE : '''Example''':<pre>10 CLS20 PRINT "top corner"30 LOCATE 1,140 a$=COPYCHR$(#0)50 LOCATE 1,2060 PRINT a$</pre>==== <code><big>COS (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates the COSinus of the <numeric expression> (n).: Note that DEG and RAD can be used to force the result of the below calculation to degrees or radians respectively. : '''Associated keywords''': ATN, DEG, RAD, SIN : '''Example''':<pre>DEGPRINT COS(45) 0.707106781</pre>==== <code><big>CREAL (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the value of the <numeric expression> (n), Converting it to REAL. : '''Associated keywords''': CINT : '''Example''':<pre>10 a=PI20 PRINT CINT(a)30 PRINT CREAL(a)run 3 3.14159265</pre>==== <code><big>DEC$(<numeric expression>, <format template>)</big></code> ====: ''BASIC 1.1'': '''FUNCTIION''': Returns a DECimal string representation of the <numeric expression> (n), using the specified <format template> to control the print format of the resulting string.: The format template may contain ONLY the characters: : + - $ £ * # , . ^ : The use of these 'format field specifiers' is described under the keyword PRINT USING. : '''Associated keyword''': BIN$, HEX$, PRINT USING, STR$ : '''Example''':<pre>PRINT DEC$(10^7,"££########,.##") £10,000,000.00</pre>==== <code><big>DERR</big></code> ====: ''BASIC 1.1'': '''FUNCTION''': Reports the last error code returned by the disc filing system. The value of DERR may be used to ascertain the particular Disc ERRor that occurred. See the listing of error messages below. : '''Associated keywords''': ERL, ERR, ERROR, ON ERROR GOTO, RESUME : '''Example''':<pre>LOAD "xyz.abc" XYZ .ABC not foundReadyPRINT DERR 146</pre>: '''Table of Disc ERRor codes''':: If AMSDOS has already reported an error, then bit 7 is set, hence the value of DERR is offset by 128.<pre>===============================================================================| VALUE | DERR value | DESCRIPTION |===============================================================================| 0 | 0 or 22 | [ESC] has been pressed || 14 | 142 (128+14) | The stream is not in a suitable state. || 15 | 143 (128+15) | Hard end of file has been reached. || 16 | 144 (128+16) | Bad command, usually an incorrect filename. || 17 | 145 (128+17) | File already exists. || 18 | 146 (128+18) | File does not exists. || 19 | 147 (128+19) | Directory is full. || 20 | 148 (128+20) | Disc is full. || 21 | 149 (128+21) | Disc changed while file were open. || 22 | 150 (128+22) | File is Read/Only. || 26 | 154 (128+26) | Soft end of file has been detected. || | | |===============================================================================</pre>: Other values returned by DERR originate from the disc controller and are bit significant, always with bit 6 set.: The significance of each bit is as follows:<pre>===============================================================================| BIT | Significance |===============================================================================| 0 | Address mark missing. || 1 | Not writable - disc is write protected. || 2 | No data - can't find the sector. || 3 | Drive not ready - no disc in the drive. || 4 | Overrun error. || 5 | Data error - CRC error. || 6 | Always set to 1 to indicate error from disc controller. || 7 | Set to 1 if error has already been reported by AMSDOS. |===============================================================================</pre>==== <code><big>EOF</big></code> ====: ''BASIC 1.1'': '''FUNCTION''': Checks to see if end of specified file has been reached during input. Returns 0 (false) until the end of file, then -1 (true). : '''Associated keywords''': OPENIN, CLOSEIN : This '''example''' reads a file from disc and print it out on screen. Like the "TYPE" command in CP/M or "|TYPE,file" of the UTOPIA-ROM.<pre>10 OPENIN "text.txt"20 WHILE NOT EOF30 LINE INPUT#9,a$40 PRINT a$50 WEND60 CLOSEIN</pre>==== <code><big>ERR</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the number of the last ERRor encountered. See the table below of error messages. In the example below you will see that ERRor number 8 is a 'Line does not exist' error. : '''Example''':<pre>GOTO 500Line does not existReadyPRINT ERR 8</pre>: NOTE: BASIC 1.0 (officially) describes error codes until 30 (without an attached floppy disc controller). 31 & 32 are floppy disc error codes.: '''Table of ERRor codes''':<pre>========================================================================================| VALUE | NAME | DESCRIPTION |========================================================================================| 1 |Unexpected NEXT |A NEXT command has been encountered while not in a || | |FOR loop, or the control variable in the NEXT || | |command does not match that in the FOR. || 2 |Syntax Error |BASIC cannot understand the given line because || | |a construct within it is not legal. || 3 |Unexpected RETURN |A RETURN command has been encountered when not in a || | |subroutine. || 4 |DATA exhausted |A READ command has attempted to read beyond the end || | |of the last DATA. || 5 |Improper Argument |This is a general purpose error. The value of a || | |function's argument, or a command parameter is || | |invalid in some way. || 6 |Overflow |The result of an arithmetic operation has over- || | |flowed. This may be a floating point overflow, in || | |which case some operation has yielded a value || | |greater than 1.7E^38 (approx.). Alternatively, this || | |may be the result of a failed attempt to change a || | |floating point number to a 16 bit signed integer. || 7 |Memory full |The current program or its variables may be simply || | |too big, or the control structure is too deeply || | |nested (nested GOUSBs, WHILEs or FORs). || | |A MEMORY command will give this error if an attempt || | |is made to set the top of BASIC's memory too low, or|| | |to an impossible high value. Note that an open file || | |has a buffer allocated to it, and that may restrict || | |the values that MEMORY may use. || 8 |Line does not exist |The line referenced cannot be found. || 9 |Subcript out of range |One of the subscripts in an array reference is too || | |big or too small. || 10 |Array already dimensioned|One of the arrays in a DIM statement has already || | |been declared. || 11 |Division by zero |May occur in real division, integer division, || | |integer modulus or exponentiation. || 12 |Invalid direct command |The last command attempted is not valid in direct || | |mode. || 13 |Type mismatch |A numeric value has been presented where a string || | |value is required or vice versa, or an invalidly || | |formed number has been found in READ or INPUT. || 14 |String space full |So many strings have been created that there is no || | |further room available, even after 'garbage || | |collection'. || 15 |String too long |Strings exceeds 255 characters in length. May be || | |generated by appending strings together. || 16 |String expression too |String expressions may generate a number of || |complex |intermediate string values. When the number of these|| | |values exceeds a reasonable limit, this error || | |results. || 17 |Cannot CONTinue |For one reason or another the current program || | |be restarted using CONT. Note that CONT is intended || | |for restarting after a STOP command, [ESC][ESC], || | |or an error, and that any alteration of the || | |program in the meantime makes a restart impossible. || 18 |Unknown user function |No DEF FN has been executed for the FN just || | |invoked. || 19 |RESUME missing |The end of the program has been encountered while || | |in error processing mode (i.e. in an ON ERROR GOTO || | |routine). || 20 |Unexpected RESUME |RESUME is only valid while in error processing mode || | |(i.e. in an ON ERROR GOTO routine). || 21 |Direct command found |When loading a file, a line without a line number || | |has been found. || 22 |Operand missing |BASIC has encountered an incomplete expression. || 23 |Line too long |A line when converted to BASIC internal-form becomes|| | |too big. || 24 |EOF met |An attempt has been made to read past end of the || | |file input stream. || 25 |File type error |The file being read is not of a suitable type. || | |OPENIN is only prepared to open ASCII text files. || | |Similarly, LOAD, RUN, etc, are only prepared to || | |deal with file types produces by SAVE. || 26 |NEXT missing |Cannot find a NEXT to match a FOR command. A line || | |number accompanying this message indicates the FOR || | |command to which this error applies. || 27 |File already open |An OPENIN or OPENOUT command has been executed || | |before the previously opened file has been closed. || 28 |Unknown command |BASIC cannot find a taker for an external command, || | |i.e. a command preceded by a bar |. || 29 |WEND missing |Cannot find a WEND to match a WHILE command. || 30 |Unexpected WEND |Encountered a WEND when not in a WHILE loop, or a || | |WEND that does not match the current WHILE loop. || 31 |File not open |(see 'Disc ERRors above). || | |If access attempted when no file was open. || 32 |Broken in |(see 'Disc ERRors above). || | |If access attempted when no file was open. || | | || | |If value 31 or 32 are stated, DERR could be || | |interrogate to give more detailed information. || | |(see example below.) |========================================================================================</pre>: '''Example for ERR 31 / 32''':<pre>10 ON ERROR GOTO 100020 OPENOUT "myfile.asc"30 WRITE #9,"test-data"40 CLOSEOUT50 END1000 amsdoserr=(DERR AND &7F):REM mask off bit 71010 IF ERR<31 THEN END1020 IF ERR=31 THEN PRINT "are you sure you've typed line 20 correctly?":END1030 IF amsdoserr=20 THEN PRINT "disc is full, suggest you use a new data disc":END1040 IF amsdoserr=&X01001000 THEN PRINT "put a disc in the drive, then press a key":WHILE INKEY$="":WEND:RESUME1050 END</pre>==== <code><big>EXP (<integer expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates 'E' to the power given in the <numeric expression> (i), where 'E' is approximately 2,7182818-the number whose natural logarithm is 1. : '''Associated keywords''': LOG : '''Example''':<pre>PRINT EXP(6.876) 968.743625</pre>==== <code><big>FIX (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Unlike CINT, FIX merely removes the part of the numeric expression, to the right of the decimal point, and leaves an integer result, rounding towards zero. : '''Associated keywords''': CINT, INT, ROUND : '''Example''':<pre>PRINT FIX(9.99999) 9</pre>==== <code><big>FRE (<numeric expression>/<string expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Establishes how much FREe memory remains unused by BASIC. The form FRE("") forces a 'GARBAGE COLLECTION' before returning a value for available space.: NOTE: BASIC uses only the first 64K of the memory. : '''Associated keywords''': HIMEM, MEMORY : '''Examples''':<pre>PRINT FRE(0) or PRINT FRE("hello")PRINT FRE("")</pre>==== <code><big>HEX$ (<unsigned integer expression>, <field width>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Produces a $tring of HEXadecimal digits representing the value of the <unsigned integer expression>, using the number of hexadecimal digits instructed by the <field width> (in the range 0 to 16). If the number of digits instructed is too great, the resulting expression will be filled with leading zeros; if the number of digits instructed is too small, the resulting expression will NOT be shortened to the instructed number of digits, but will be produced in as many digits as are required.: The <unsigned integer expression> to be converted into hexadecimal form must yield a value in the range -32768 to 65535. : '''Accociated keywords''': BIN$, DEC$, STR$, UNT : '''Example''':<pre>PRINT HEX$(255,4)00FF</pre>==== <code><big>HIMEM</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the address of the Highest byte of Memory use by BASIC, (which may altered by e.g. the MEMROY command).: Before resetting the highest byte of available memory using the MEMORY command, it is advisable to issue the 'command mm=HIMEM'. You will thereafter be able to return to the previous memory capacity by issuing the command: 'MEMORY mm': NOTE: BASIC uses only the first 64K of memory. : Associated keywords: FRE, MEMORY, SYMBOL, SYMBOL AFTER. : '''Example''':...on a CPC464<pre>PRINT HIMEM43903</pre>...on a CPC6128<pre>PRINT HIMEM42619</pre>==== <code><big>INKEY (<integer expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': INterrogates the KEYboard to report which keys are being pressed. The keyboard is scanned every 0.02 (1/50) second.: The function is useful for spotting whether a certain key is down or up, by detecting the returned value of -1 (which occurs regardless of [SHIFT] and [CONTROL] key status).: The example below detects when [SHIFT] and V (key number 55) are pressed together, then ends the program. Refer the manual for the key numbers. : '''Associated keywords''': CLEAR INPUT, INKEY$, JOY : '''Example''':<pre>10 IF INKEY(55)<>32 THEN 1020 PRINT "You've pressed [SHIFT] and V"30 CLEAR INPUTrun</pre>: The state of [SHIFT] and [CONTROL] in conjunction with the key specified in the <integer expression> is identified as follows:<pre>==============================================================================|Value returned |[SHIFT] |[CTRL] |Specified key |==============================================================================|-1 |ignored |ignored |up ||0 |up |up |down ||32 |down |up |down ||128 |up |down |down ||160 |down |down |down |==============================================================================</pre>==== <code><big>INKEY$</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': INterrogates the KEYboard, returning the current $tring reflecting any key that is pressed. It provides operator interaction without hitting [ENTER] after every answer. If there is a key pressed, then the function responds. If no key is pressed, INKEY$ returns an empty string.: In the example below, lines 40 and 70 tell the program to loop back to line 30 after interrogating the keyboard string. : '''Associated keywords''': CLEAR INPUT, INKEY : '''Example''':<pre>10 CLS20 PRINT "Select Yes or No (Y/N)?"30 a$=INKEY$40 IF a$="" THEN 3050 IF a$="y" OR a$="Y" THEN 8060 IF a$="N" OR a$="n" THEN 9070 GOTO 3080 PRINT "You have selected YES": END90 PRINT "You have selected NO":run</pre>==== <code><big>INP (‹port number›)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the INPut value from the I/O address specified in the <port number>. : '''Associated keywords''': OUT, WAIT : Watch out http://cpcwiki.eu/index.php/I/O_Port_Summary : '''Example''':<pre>PRINT INP(&FF00)255Ready</pre>==== <code><big>INSTR ([‹startposition›,]‹searched string›, ‹searched for string›)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Searches the first <searched string> expression to find the first occurance of the <searched for string expression<, and reports the position of its occurance within the <searched string>. If the <searched for string> does not occur within the <searched string>, then 0 is reported.: The position at which to start searching the <searched string> is optionally specifiable using the <start position> parameter which must yield an integer number in the range 1 to 255. : '''Associated keywords''': none : '''1. Example''':<pre>a$="ABCD":PRINT INSTR(a$,"C") 3Ready</pre>: '''2. Example''':<pre>a$="Hello":IF INSTR(a$,"i")<>0 THEN PRINT "no" else a$noReady</pre>: '''3. Example''':<pre>10 CLS20 alphabet$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"30 INPUT "Enter a letter";a$40 b$=UPPER$(a$)50 PRINT b$;" is number";60 PRINT INSTR(alphabet$,b$);70 PRINT "in the alphabet.":PRINT80 GOTO 40run</pre>==== <code><big>INT (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Rounds the number to the nearest smaller INTeger, removing any fractional part. Returns then same value as FIX for positive number, but returns one less than FIX for negative numbers which are not already integers. : '''Associated keyword''': CINT, FIX, ROUND : '''Example''':<pre>PRINT INT(3.99), INT(-3.99) 3 -4</pre>==== <code><big>JOY (<integer expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': The JOY function reads a bit significant result from the joystick in the <integer expression> (either 0 or 1).<pre>================================|Bit | Value decimal |================================|0(up) | 1 ||1(down) | 2 ||2(left) | 4 ||3(right) | 8 ||4(fire 2) | 16 ||5(fire 1) | 32 |================================</pre>==== <code><big>LEFT$ (<string expression>, <required length>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the number of characters (in the range 0 to 255) specified in the <required length> parameter (<integer expression>), after extracting them from the LEFT of the <string expression>. If the <string expression> is shorter than the <required length>, the whole <string expression> is returned. : '''Associated keywords''': MID$, RIGHT$ : '''1. Example''':<pre>A$="ABCDEFG":PRINT LEFT$(A$,3) - prints ABC</pre>: '''2. Example''':<pre>10 CLS20 a$="AMSTRAD"30 FOR n=1 to 740 PRINT LEFT$(a$,n)50 NEXTrun</pre>==== <code><big>LEN (<string expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the total number of characters (i.e. the LENgth) of the <string expression>. : '''Associated keywords''': none : '''Example''':<pre>10 LINE INPUT "Enter a phrase";a$20 PRINT "The phrase is";30 PRINT LEN(a$);"characters long."run</pre>==== <code><big>LOG (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates the natural LOGarithm (base of ''e'') of <numeric expression> which mustbe greater than zero. : '''Associated keywords''': EXP, LOG10 : '''Example''':<pre>PRINT LOG(9999) 9.21024037</pre>==== <code><big>LOG10 (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the logarithm to base 10 of <numeric expression> which must be greater than zero. : '''Associated keywords''': EXP, LOG : '''Example''':<pre>PRINT LOG10(9999) 3.99995657</pre>==== <code><big>LOWER$ (<string expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns a new string expression which is a copy of the specified <string expression> but in which all alphabetic characters in the range A to Z are converted to lower case. Useful for processing input where the answers may come in mixed upper/lower case. : '''Associated keywords''': UPPER$ : '''1. Example''':<pre>A$="AMSTRAD":PRINT A$="AMSTRAD":PRINT LOWER$(A$)Amstrad</pre>: '''2. Example''':<pre>10 a$="SEE HOW THE LETTERS CHANGE TO ... NUMBERS 1234 NOT..."20 PRINT LOWER$(a$+"LOWER CASE") see how the letters change to ... numbers 1234 not... LOWER CASE</pre>==== <code><big>MAX (<list of: numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the MAXimum value from the <list of: numeric expression>s. : '''Associated keywords''': MIN : '''Example''':<pre>10 n=6620 PRINT MAX(1,n,3,6,4,3)run 66</pre>==== <code><big>MIN (<list of: numeric expression>)</big></code> ====''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the MINimum value from the <list of: numeric expression>s.: '''Associated keywords''': MAX : '''Example''':<pre>PRINT MIN (3,6,2.999.8,9,) 2.999</pre> ==== <code><big>PEEK (<address expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the contents of the Z80 memory location specified in the <address expression> which should be in the range &0000 to &FFFF (0 to 65535). In all cases PEEK will return the value at the RAM address specified (not the ROM), and will be in the range &00 to &FF (0 to 255) : '''Associated keywords''': POKE : '''Example''':<pre>10 MODE 1: ZONE 720 WINDOW 1,40,1,2:WINDOW #1,1,40,3,2530 PRINT "memory-address"40 LOCATE 20,1:PRINT "memory-contents"50 FOR n=1 to 6553560 p=PEEK(n)70 PRINT #1,n,"(&";HEX$(n);")";80 PRINT #1,TAB(20);p,"(&";HEX$(p);")"90 NEXTrun</pre>==== <code><big>PI</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': The value of the ratio between the circumference and the diameter of a circle. : '''Associated keywords''': DEG, RAD : '''Example''':<pre>PRINT PI 3.14159265</pre>==== <code><big>POS (#<stream expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the current horizontal POSition of the text cursor relative to the left edge of the text window. The <stream expression> MUST be specified, and does NOT default to #0.: POS(#8) reports the current horizontal carriage position for the printer, where 1 is the extreme left hand edge.: POS(#9) reports the logical position in the disc file stream, i.e. the number of printing characters sent to the stream since the last carriage return. : '''Associated keywords''': VPOS, WINDOW: '''Example''':<pre>10 MODE 1: BORDER 0:LOCATE 8,220 PRINT "use cursor left/right keys"30 WINDOW 1,40,12,12:CURSOR 1,140 FOR n=1 TO 19:PRINT CHR$(9);:NEXT50 IF INKEY(1)<>-1 THEN PRINT CHR$(9);60 IF INKEY(8)<>-1 THEN PRINT CHR$(8);70 LOCATE #1,2,2480 PRINT #1,"text cursor ";90 PRINT #1,"horizontal position = ";100 PRINT #1,POS(#0):GOTO 50run</pre>==== <code><big>REMAIN (<integer expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns count REMAINing count from the delay timer specified in <integer expression> (= timer number in the range 0 to 3), and disable it. If the delay timer was not enabled zero will be returned. : '''Associated keywords''': AFTER, DI, EI, EVERY : For the reason that REMAIN is no normal command but a "function" it is necessary in case of a proper functionality to link the command.: an '''example''' in combination with an interrupt delay timer 1:<pre>PRINT REMAIN(1)</pre>: or to stop several/all interrupts at the same time...<pre>A=REMAIN(0)=REMAIN(1)=REMAIN(2)=REMAIN(3)</pre>: Hint: Take care of interrupts due to parallel working (the same cycle time) or if they are stopped with the BREAK key. Interrupts which were disabled for a certain time will be stored in buffer (for a maximum of 128 entries) and made up their task afterwards in the priorisation as declared.: further '''example''':<pre>10 AFTER 500,1 GOSUB 4020 AFTER 100,2 GOSUB 5030 PRINT "program running":GOTO 3040 REM this GOUSB-Routine will not be called as it is disabled in line 8050 PRINT:PRINT "Timer 1 will now be ";60 PRINT "disabled by REMAIN."70 PRINT "Time-units remaining were:";80 PRINT REMAIN(1)run</pre>==== <code><big>RIGHT$ (<string expression>, <integer expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the number of characters (in the range 0 to 255) specified in the <integer expression> (=required length) parameter, after extracting them from the RIGHT of the <string expression>. If the <string expression> is shorter than the <integer expression>, the whole <string expression> is returned. : '''Associated keywords''': LEFT$, MID$ : '''Example''':<pre>10 MODE 1:a$="AMSTRAD computer"20 FOR n=1 TO 16:LOCATE 41-n,n30 PRINT RIGHT$(a$,n)40 NEXT</pre>==== <code><big>RND [(<numeric expression>)]</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the next RaNDom number in sequence if the <numeric expression> has a positive value or is not specified. : If the <numeric expression> yields a value of zero, RND returns a copy of the last random number generated.: If the <numeric expression> yields a negative value, a new random number sequence is started, the first number of which is returned. : '''Associated keywords''': RANDOMIZE : '''1. Example''':<pre>PRINT RND(0) 0.536703827ReadyPRINT RND(1) 0.271940658ReadyPRINT RND(0) 0.271940658Ready</pre>: '''2. Example''':: Example for generating an integer random number between 1 and 1000<pre>10 A=INT((RND(1)*1000)+1)20 PRINT A30 GOTO 10</pre>: '''3. Example''': : For generating a random number between a lower and higher border<pre>10 INPUT "Low border",low20 INPUT "High border",high30 A=INT(RND(1)*(high-low))+low40 PRINT A</pre>: '''4. Example''':<pre>10 RANDOMIZE20 FOR x=1 TO -1 STEP -130 PRINT "rnd parameter=";x40 FOR n=1 TO 650 PRINT RND(x)60 NEXT n,xrun</pre> ==== <code><big>ROUND (<numeric expression>[,<integer expression>])</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Rounds <numeric expression> to a number of decimal places or to the power of ten specified by <integer expression>. If <integer expression> less than zero, the <numeric expression> is rounded to give an absolute integer with <integer expression> number of zeros before the decimal point. : '''Associated keywords''': ABS, CINT, FIX, INT: '''1. Example''':<pre>PRINT ROUND(1562.357,2),ROUND(1562.375,-2) 1562.36 1600</pre>: '''2. Example''':<pre>10 FOR n=4 TO -4 STEP -120 PRINT ROUND (1234.5678,n)30 PRINT "with integer expression";n40 NEXTrun</pre>==== <code><big>SGN (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': FUNCTION: Determines the SiGN of the <numeric expression>. Returns -1 if <numeric expression> is less than 0, returns 0 if <numeric expression> = 0, and returns 1 if <numeric expression> is greater than zero. : '''Associated keywords''': ABS : '''Example''':<pre>10 FOR n=255 to -200 STEP -2020 PRINT "SGN returns";30 PRINT SGN(n);"for a value of";n40 NEXT nrun</pre>==== <code><big>SIN (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates the Real value for the Sine of <numeric expression>, defaulting to the Radian (RAD) measure mode unless otherwise declared by a DEG command. : '''Associated keywords''': ATN, COS, DEG, RAD, TAN : '''Example''':<pre>10 CLS:DEG:ORIGIN 0,2020 FOR n=0 to 72030 y=SIN(n)40 PLOT n*640/720,198*y:NEXT50 GOTO 50run</pre>==== <code><big>SPACE$(<integer expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Creates a string of spaces of the given length, (in the range 0 to 255) specified in the <integer expression>. : '''Associated keywords''': SPC, STRING$, TAB : '''Example''':<pre>10 MODE 120 PRINT "Put 9 spaces between me";30 PRINT SPACE$(9);40 PRINT "and you!"run</pre>==== <code><big>SQ (<channel>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the state of the Sound Queue for the specified <channel> which must be an integer expression, yielding one the values:: 1: for channel A: 2: for channel B: 4: for channel C: The SQ function returns a bit significant integer, comprising the following bit settings:: Bit 0,1 and 2: the number of free entries in the queue: Bit 3,4 and 5: the rendezvous state at the head of this queue: Bit 6 : the head of the queue is held: Bit 7 : the channel is currently active: ... where Bit 0 is the least significant bit, and Bit 7 is the most significant bit.: It can be seen, that if Bit 6 is set, Bit 7 cannot be set at the same time, and vice versa. Similarly if Bits 3, 4, or 5 are set, Bit 6 and 7 cannot be set. : '''Associated keywords''': ON SQ GOSUB, SOUND : '''Example''':<pre>10 SOUND 65,100,10020 PRINT SQ(1)run 67</pre>==== <code><big>SQR (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the SQuare Root of the specified <numeric expression>. : '''Associated keywords''': none : '''Example''':<pre>PRINT SQR(9) 3</pre>==== <code><big>STR$ (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Converts the <numeric expression> to a decimal STRing representation.: Useful for converting a number to a string in case of string manipulation. E.g. after converting a figure to a string then the most left character holds the sign: a minus in case the figure is negative and a space in case the figure is positiv. : '''Associated keywords''': BIN$, DEC$, HEX$, VAL : '''1. Example''':<pre>10 FIGURE=-159920 FIGURE$=STR$(FIGURE)30 PRINT FIGURE$-1599</pre>: '''2. Example''':<pre>10 FIGURE=176920 FIGURE$=STR$(FIGURE)30 PRINT FIGURE$ 1769</pre>: '''NOTE''': (there's a blank on the left-hand of the number "1769"): If you want to add e.g. zero before the figure in case of a high score with fix digit-number then you're able to add zero(s) in front of a string instead of a figure. : '''3. Example''':<pre>10 a=&FF:REM 255 hex20 b=&x1111:REM 15 binary30 c$="***"40 PRINT c$+SR$(a+b)+c$run*** 270***</pre>==== <code><big>STRING$ (<length>,<character specifier>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns a string expression consisting of the <character specifier> repeated the number of time (in the range 0 to 255) specified in the <length>. : '''Associated keywords''': SPACE$ : '''1. Example''':<pre>PRINT STRING$(40,"*")****************************************</pre>: '''2. Example''':<pre>PRINT STRING(40,42)****************************************</pre>: '''NOTE''': the <character specifier> 42 refers to the ASCII value of the character '*' and is also equivalent to PRINT STRING$(40,CHR$(42))==== <code><big>TAN (<numeric expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates the TANgent of the <numeric expression>, which must be in the range -200,000 to +200,000.: '''NOTE''': DEG and RAD can be used to force the result of the calculation to degrees or radians respectively. : '''Associated keywords''': ATN, COS, DEG, RAD, SIN : '''Example''': <pre>PRINT TAN(45) 1.61977519</pre> ==== <code><big>TEST (<x co-ordinate>,<y co-ordinate>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Moves the graphics cursor to the absolute position specified by the <x> and <y co-ordinate>s, and reports the value of the ink at the new location. : '''Associated keywords''': MOVE, MOVER, TESTR, XPOS, YPOS : '''Example''':<pre>10 CLS20 PRINT "Your are using pen number";30 PRINT TEST(10,386)40 PRINT "Try changing PENs and MODEs";50 PRINT "....then RUN again."run</pre>==== <code><big>TESTR (<x offset>,<y offset>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Moves the graphics cursor by the amount specified in the <x> and <y offset>s relative to its current position, and reports the value of the ink at the new location. : '''Associated keywords''': MOVE, MOVER, TEST, XPOS, YPOS : '''Example''':<pre>10 MODE 0:FOR x=1 TO 15:LOCATE 1,x20 PEN x:PRINT STRING$(10,143);:NEXT30 MOVE 200,400:PEN 140 FOR n=1 TO 23:LOCATE 12,n50 PRINT "pen";TESTR(0,-16):NEXTrun</pre>==== <code><big>TIME</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the elapsed time since the computer was last switched-on or reset, (excluding periods when reading or writing to disc).: Each second of real time is equal to the returned value = TIME/300. : '''Associated keyword''': AFTER, EVERY, WEND, WHILE : '''Example''':<pre>10 CLS:REM clock20 INPUT "hour";hour30 INPUT "minute";minute40 INPUT "second";second50 CLS:datum=INT(TIME/300)60 WHILE hour<1370 WHILE minute<6080 WHILE tick<6090 tick=(INT(TIME/300)-datum)+second100 LOCATE 1,1110 PRINT USING "## ";hour,minute,tick120 WEND130 tick=0:second=0:minute=minute+1140 GOTO 50150 WEND160 minute=0:hour=hour+1170 WEND180 hour=1190 GOTO 60run</pre>==== <code><big>UNT (<address expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Return an integer in the range -32768 to +32767 which is the twos-complement equivalent of the unsigned value of the <address expression>. : '''Associated keywords''': CINT, FIX, INT, ROUND : '''Example''':<pre>PRINT UNT(&FF66)-154</pre>==== <code><big>UPPER$(<string expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns a new string expression which is a copy of the specified <string expression> but in which all alphabetic characters in the range A to Z are converted to upper case. The function is useful for processing input which may come in mixed upper / lower case. : '''Associated keywords''': LOWER$ : '''Example''':<pre>10 CLS: a$="my, how you've grown!"20 PRINT UPPER$(a$)run</pre>==== <code><big>VAL(<string expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the numeric VALue, (including any negative sign and decimal point) of the first character(s) in the specified <string expression>. :If the first character is not a number, then 0 is returned. If the first character is a negative sign or decimal point followed by non-numeric characters, a 'Type mismatch' error (13) will be reported. : '''Associated keywords''': STR$ : '''1. Example''':<pre>PRINT VAL("-12.34x"),VAL("A-12") -12.34 0</pre>: '''Exception''': if <se> starts with "&amp;" + character (and it's between "A" and "F") the whole character will be handled like a hexadezimal numeric character (...often used in DATA Loaders). The returning numeric value is a &nbsp;signed&nbsp;integer (16-Bit Word). : '''2. Example''':<pre>PRINT VAL("&amp;A") 10 PRINT VAL("&amp;7FFF") 32767 PRINT VAL("&amp;8000") -32768</pre>: '''3. Example''':<pre>10 CLS: PRINT "I know my times tables!"20 PRINT:PRINT "Press a key (1 to 9)"30 a$=INKEY$:IF a$="" THEN 3040 n=VAL(a$):if n<1 or n>9 then 3050 FOR x=1 to 1260 PRINT n;"X";x;"=";n*x70 NEXT:GOTO 20run</pre>==== <code><big>VPOS (#<stream expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the current vertical POSition of the text cursor relative to the top of the text window. The <stream expression> MUST be specified, and does NOT default to #0. : '''Associated keywords''': POS, WINDOW : '''Example''':<pre>10 MODE 1:BORDER 0:LOCATE 8,220 PRINT "use cursor up/down keys"30 WINDOW 39,39,1,25:CURSOR 1,140 LOCATE 1,350 IF INKEY(0)<>-1 THEN PRINT CHR$(11);60 IF INKEY(2)<>-1 THEN PRINT CHR$(10);70 LOCATE #1,3,2480 PRINT #1,"text cursor ";90 PRINT #1,"vertical position =";100 PRINT #1,VPOS(#0):GOTO 50run</pre>==== <code><big>XPOS</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the current horizontal (X)POSition of the graphics cursor. : '''Associated keywords''': MOVE, MOVER, ORIGIN, YPOS : '''Example''':<pre>10 MODE 1:DRAW 320,20020 PRINT "graphics cursor X position = ";30 PRINT XPOS</pre>==== <code><big>YPOS</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Reports the current vertical (Y)POSition of the graphic cursor. : '''Associated keywords''': MOVE, MOVER, ORIGIN, XPOS : '''Example''':<pre>10 MODE 1:DRAW 320,20020 PRINT "graphics cursor Y position = ";30 PRINT YPOS</pre> == Other Basic Dialects available for the CPC == *[[BBC Basic]]*[[C BASIC Compiler|CBASIC]]*[[BASIC-E]] == Technical Information == * [[Technical_information_about_Locomotive_BASIC]] == Web links == * [http://www.sean.co.uk/books/amstrad/bforbasic.shtm Locomotive Basic Tutorial by Sean McManus]* [http://rosettacode.org/wiki/Category:Locomotive_Basic Code examples at Rosetta Code] * [http://cpctech.cpc-live.com/docs/basic.asm Disassembly of Locomotive BASIC v1.1] [[Category:Programming]][[Category:BASIC| ]][[Category:CPC Internal Components]][[Category:Operating System| ]][[Category:Software]][[Category:Programming software| ]]
1,005
edits