Special variables: Difference between revisions
{{header|ZX Spectrum Basic}} |
|||
Line 352: | Line 352: | ||
The ZX Spectrum uses single letter variables names. None of these are special variables. There are a set of system variables held at a fixed memory addresses, which can be accessed via PEEK and POKE functions. The system variables and addresses are: |
The ZX Spectrum uses single letter variables names. None of these are special variables. There are a set of system variables held at a fixed memory addresses, which can be accessed via PEEK and POKE functions. The system variables and addresses are: |
||
23552 KSTATE - Keyboard state. |
* 23552 KSTATE - Keyboard state. |
||
23560 LAST K - Newly pressed key. |
* 23560 LAST K - Newly pressed key. |
||
23561 REPDEL - Delay (in 50ths of a second) before keyboard starts repeating. |
* 23561 REPDEL - Delay (in 50ths of a second) before keyboard starts repeating. |
||
23562 REPPER - Delay (in 50ths of a second) between keyboard repetions. |
* 23562 REPPER - Delay (in 50ths of a second) between keyboard repetions. |
||
23563 DEFADD - Address of arguments for a user defined function. |
* 23563 DEFADD - Address of arguments for a user defined function. |
||
23565 K DATA - Second byte of colour controls sequences from keyboard. |
* 23565 K DATA - Second byte of colour controls sequences from keyboard. |
||
23566 TVDATA - Colour and location information for television set. |
* 23566 TVDATA - Colour and location information for television set. |
||
23568 STRMS - Addresses of channels attached to streams. |
* 23568 STRMS - Addresses of channels attached to streams. |
||
23606 CHARS - 256 less than the address of the current character set |
* 23606 CHARS - 256 less than the address of the current character set |
||
23608 RASP - Length of the warning buzz. |
* 23608 RASP - Length of the warning buzz. |
||
23609 PIP - Length of the keyboard click. |
* 23609 PIP - Length of the keyboard click. |
||
23610 ERR NR One less than the error code and starts at 255 (for -1) |
* 23610 ERR NR One less than the error code and starts at 255 (for -1) |
||
23611 FLAGS - Various flags to control the BASIC system. |
* 23611 FLAGS - Various flags to control the BASIC system. |
||
23612 TV FLAG - Flags associated with the television output. |
* 23612 TV FLAG - Flags associated with the television output. |
||
23613 ERR SP - Address of item on machine stack to be used as error return. |
* 23613 ERR SP - Address of item on machine stack to be used as error return. |
||
23615 LIST SP - Return address from automatic listing. |
* 23615 LIST SP - Return address from automatic listing. |
||
23617 MODE - Cursor type |
* 23617 MODE - Cursor type |
||
23618 NEWPPC - Line number to be jumped to. |
* 23618 NEWPPC - Line number to be jumped to. |
||
23620 NSPPC - Statement number in line to be jumped to |
* 23620 NSPPC - Statement number in line to be jumped to |
||
23621 PPC - Line number of statement currently being executed. |
* 23621 PPC - Line number of statement currently being executed. |
||
23623 SUBPPC - Statement number within the line that is currently being executed. |
* 23623 SUBPPC - Statement number within the line that is currently being executed. |
||
23624 BORDCR - Colour of the border (overscan area) and input area (times 8) |
* 23624 BORDCR - Colour of the border (overscan area) and input area (times 8) |
||
23625 E PPC - Current line number (for list editing) |
* 23625 E PPC - Current line number (for list editing) |
||
23627 VARS - Address of the variables. |
* 23627 VARS - Address of the variables. |
||
23629 DEST - Address of variable in assignment. |
* 23629 DEST - Address of variable in assignment. |
||
23631 CHANS - Address of channel data. |
* 23631 CHANS - Address of channel data. |
||
23633 CURCHL - Address of information being used for input and output. |
* 23633 CURCHL - Address of information being used for input and output. |
||
23635 PROG - Address of the BASIC program. |
* 23635 PROG - Address of the BASIC program. |
||
23637 NXTLIN - Address of the next line in the program. |
* 23637 NXTLIN - Address of the next line in the program. |
||
23639 DATADD - Address of terminator of the last DATA item. |
* 23639 DATADD - Address of terminator of the last DATA item. |
||
23641 E LINE - Address of command being typed in. |
* 23641 E LINE - Address of command being typed in. |
||
23643 K CUR - Address of the cursor. |
* 23643 K CUR - Address of the cursor. |
||
23645 CH ADD - Address of the next character to be interpreted |
* 23645 CH ADD - Address of the next character to be interpreted |
||
23647 X PTR - Address of the character after the syntax error marker. |
* 23647 X PTR - Address of the character after the syntax error marker. |
||
23649 WORKSP - Address of temporary work space. |
* 23649 WORKSP - Address of temporary work space. |
||
23651 STKBOT - Address of bottom of calculator stack. |
* 23651 STKBOT - Address of bottom of calculator stack. |
||
23653 STKEND - Address of start of free space. |
* 23653 STKEND - Address of start of free space. |
||
23655 BREG - The B register of the calculator. |
* 23655 BREG - The B register of the calculator. |
||
23656 MEM - Address of area used for calculator memory. |
* 23656 MEM - Address of area used for calculator memory. |
||
23658 FLAGS2 - Miscellaneous flags. |
* 23658 FLAGS2 - Miscellaneous flags. |
||
23659 DF SZ - The number of lines in the input area. |
* 23659 DF SZ - The number of lines in the input area. |
||
23660 S TOP - The number of the top program line in automatic listings. |
* 23660 S TOP - The number of the top program line in automatic listings. |
||
23662 OLDPPC - Line number to which CONTINUE jumps. |
* 23662 OLDPPC - Line number to which CONTINUE jumps. |
||
23664 OSPPC - Number within line of statement to which CONTINUE jumps. |
* 23664 OSPPC - Number within line of statement to which CONTINUE jumps. |
||
23665 FLAGX - Various flags. |
* 23665 FLAGX - Various flags. |
||
23666 STRLEN - Length of string type destination in assignment. |
* 23666 STRLEN - Length of string type destination in assignment. |
||
23668 T ADDR - Address of next item in the syntax table. |
* 23668 T ADDR - Address of next item in the syntax table. |
||
23670 SEED - The random number seed. |
* 23670 SEED - The random number seed. |
||
23672 FRAMES - A 3 byte frame counter incremented every 20ms. |
* 23672 FRAMES - A 3 byte frame counter incremented every 20ms. |
||
23675 UDG - Address of the user defined graphics |
* 23675 UDG - Address of the user defined graphics |
||
23677 COORDS Coordinates of the last point plotted. |
* 23677 COORDS Coordinates of the last point plotted. |
||
23679 P POSN - Column number for the position of the printer carriage. |
* 23679 P POSN - Column number for the position of the printer carriage. |
||
23680 PR CC - Address of next free position in the printer buffer. |
* 23680 PR CC - Address of next free position in the printer buffer. |
||
23682 ECHO E - Column and line number positions in the input buffer. |
* 23682 ECHO E - Column and line number positions in the input buffer. |
||
23684 DF CC - Display address for the current print position. |
* 23684 DF CC - Display address for the current print position. |
||
23686 DFCCL - Display address in the input area. |
* 23686 DFCCL - Display address in the input area. |
||
23688 S POSN - Column and row number of the print position. |
* 23688 S POSN - Column and row number of the print position. |
||
23690 SPOSNL - Column and row number for the print position in the input area. |
* 23690 SPOSNL - Column and row number for the print position in the input area. |
||
23692 SCR CT - Scroll counter - Number of lines left before stopping with Scroll? |
* 23692 SCR CT - Scroll counter - Number of lines left before stopping with Scroll? |
||
23693 ATTR P - Permanent current colours attributes |
* 23693 ATTR P - Permanent current colours attributes |
||
23694 MASK P - Permanent current colour attribute mask |
* 23694 MASK P - Permanent current colour attribute mask |
||
23695 ATTR T - Temporary current colour attributes |
* 23695 ATTR T - Temporary current colour attributes |
||
23696 MASK T - Temporary current colour attribute mask |
* 23696 MASK T - Temporary current colour attribute mask |
||
23697 P FLAG - More flags. |
* 23697 P FLAG - More flags. |
||
23698 MEMBOT - Memory area address used by the calculator |
* 23698 MEMBOT - Memory area address used by the calculator |
||
23728 NMIADD - The address of the users Non Maskable Interrupt service routine. 23730 RAMTOP - Address of last byte of BASIC system area. |
* 23728 NMIADD - The address of the users Non Maskable Interrupt service routine. * 23730 RAMTOP - Address of last byte of BASIC system area. |
||
23732 P-RAMT - Address of last byte of physical RAM. |
* 23732 P-RAMT - Address of last byte of physical RAM. |
||
<lang zxbasic>10 PRINT "The border colour is "; PEEK (23624): REM bordcr |
<lang zxbasic>10 PRINT "The border colour is "; PEEK (23624): REM bordcr |
Revision as of 09:35, 12 June 2011
Special variables have a predefined meaning within the programming language. The task is to list the special variables used within the language.
AWK
There are two types of special variables within AWK: Control variables and Informative variables.
- dollarint variables - The dollarint special variables represent fields within a record
- ARGC - An informative variable that provides command line parameter information
- ARGV - An informative array that provides command line parameter information
- CONVFMT - A control variable that specifies the conversion format of numerical strings
- ENVIRON - An informative array that contains the environment strings
- FILENAME - An informative variable that provides the current input [filename]
- FNR - An informative variable that provides the record number within the current file
- FS - A control variable that specifies the input field separator
- NF - An informative variable that provides the number of fields within the current record
- NR - An informative variable that provides the total number of records processed
- OFMT - A control variable that specifies the output format of numerical values
- OFS - A control variable that specifies the output field separator
- ORS - A control variable that specifies the output record separator
- RLENGTH - An informative variable that provides the length of the currently matched substring
- RS - A control variable that specifies the input record separator
- RSTART - An informative variable that provides the start index of the currently matched substring
- SUBSEP - A control variable that specifies the subscript separator for multidimensional arrays
Icon and Unicon
Icon and Unicon have special variables known as keywords which are syntactically are preceded by an &. <lang Unicon>
- &keyword # type returned(indicators) - brief description
- indicators:
- * - generates multiple values
- = - modifiable
- ? - may fail (e.g. status inquiry)
- U - Unicon
- G - Icon or Unicon with Graphics
&allocated # integer(*) - report memory allocated in total and by storage regions &ascii # cset - ASCII character set &clock # string - time of day &col # integer(=G) - column location of pointer &collections # integer(*) - garbage collection activity in total and by storage region &column # integer(U) - source code column &control # null(?G) - control key state &cset # cset - universal character set ¤t # co-expression - current co-expression &date # string - today's date &dateline # string - time stamp &digits # cset - digit characters &dump # integer(=) - termination dump &e # real - natural log e &error # integer(=) - enable/disable error conversion/fail on error &errno # integer(?) - variable containing error number from previous posix command &errornumber # integer(?) - error number of last error converted to failure &errortext # string(?) - error message of last error converted to failure &errorvalue # any(?) - erroneous value of last error converted to failure &errout # file - standard error file &eventcode # integer(=U) - program execution event in monitored program &eventsource # co-expression(=U) - source of events in monitoring program &eventvalue # any(=U) - value from event in monitored program &fail # none - always fails &features # string(*) - identifying features in this version of Icon/Unicon &file # string - current source file &host # string - host machine name &input # file - standard input file &interval # integer(G) - time between input events &lcase # cset - lowercase letters &ldrag # integer(G) - left button drag &letters # cset - letters &level # integer - call depth &line # integer - current source line number &lpress # integer(G) - left button press &lrelease # integer(G) - left button release &main # co-expression - main task &mdrag # integer(G) - middle button drag &meta # null(?G) - meta key state &mpress # integer(G) - middle button press &mrelease # integer(G) - middle button release &now # integer(U) - current time &null # null - null value &output # file - standard output file &pick # string (U) - variable containing the result of 3D selection &phi # real - golden ratio &pos # integer(=) - string scanning position &progname # string(=) - program name &random # integer(=) - random number seed &rdrag # integer(G) - right button drag ®ions # integer(*) - region sizes &resize # integer(G) - window resize &row # integer(=G) - row location of pointer &rpress # integer(G) - right button press &rrelease # integer(G) - right button release &shift # null(?G) - shift key state &source # co-expression - invoking co-expression &storage # integer(*) - memory in use in each region &subject # string - string scanning subject &syserr # integer - halt on system error &time # integer(=) - elapsed time in milliseconds &trace # integer(=) - trace program &ucase # cset - upper case letters &version # string - version &window # window(=G) - the current graphics rendering window &x # integer(=G) - pointer horizontal position &y # integer(=G) - pointer vertical position
- keywords may also fail if the corresponding feature is not present.
- Other variants of Icon (e.g. MT-Icon) will have different mixes of keywords.</lang>
J
special local variables
The names x y u v m n
are used as parameters in explicit J definitions:
y: right argument x: (optional) left argument u: left argument to an adverb or conjunction v: right argument to a conjunction m: left noun argument to an adverb or conjunction (value error if verb provided) n: right noun argument to a conjunction (value error if verb provided)
Note that the result of an adverb or conjunction that uses either x or y and one of these other names is always a verb. In this case, x and/or y represent arguments passed to the derived verb.
These names may be used as regular names, but that is bad practice except in the context of debugging or illustration.
special global variables
In J 602: Names in locale z are in the path for all locales, including the default locale (base) -- these provide "language features":
names_z_'' ARGV BINPATH CR CRLF DEL Debug EAV EMPTY FF FIXFONT FIXFONTWH IF64 IFCONSOLE IFGTK IFJ6 IFJAVA IFJHS IFUNIX IFWIN IFWIN32 IFWINCE IFWINE IFWINNT JVERSION LF LF2 Note PROFONT SYSPPC TAB UNAME adverb apply assert bind boxopen boxxopen break bx clear coclass cocreate cocurrent codestroy coerase cofullname coinsert coname conames conew conjunction conl copath coreset cutopen datatype def define do drop dyad each edit empty erase every exit expand fetch inv inverse items jcwdpath jhostpath jpath jpathsep jsystemdefs leaf list load loadd loadp mbopen mbsave monad nameclass namelist names nc nl noun on open pick require rows script scriptd scripts setbreak sign sminfo smoutput sort split startupconsole startupide table take tmoutput toCRLF toHOST toJ tolower toupper type ucp ucpcount utf8 uucp verb wcsize wd wdbox wdcenter wdclipread wdclipwrite wde wdfit wdforms wdget wdhandler wdinfo wdishandle wdisparent wdmove wdpclose wdqshow wdquery wdreset wdselect wdstatus winpathsep
Names in the locales j and jijs are available by explicity referencing those locales and are used to provide "system features" and "ide features":
names_j_'' BOXES BROWSER CONFIRMCLOSE DIRTREEX DISPLAYLOAD EPSREADER FORMAT FORMSIZES GetSystemMetrics IFJIJX INPUTLOG INPUTLOGFILE LOADED P2UPFONT PATHJSEP PATHSEP PDFREADER PRINTERFONT PRINTOPT PUBLIC READONLY SCRIPTS SHOWSIP SMPRINT SM_CMONITORS SM_CXVIRTUALSCREEN SM_CYVIRTUALSCREEN SM_XVIRTUALSCREEN SM_YVIRTUALSCREEN STARTUP SYSTEMFOLDERS TARGET USERFOLDERS WINPOS XDIFF addfname boxdraw buildpublic classwizard cleantable config cutnames deb debug demos dirmatch dltb edit editfind editinputlog editinputprompt exist extijs fexist fif filenewform fileprint fileprintsetup filex fixWINPOS formedit formeditrun forms fullname getinputlog getpath getscripts gettarget gettargetlocale globaldefs gridwizard help htmlhelp jpath lab lastactive loadp open openfiles origin pacman printfiles prints projectmanager save saveuserfolders scriptmake scripts wpreset wpsave wpset names_jijs_'' EMPTY FIXFONTDEF FKEYS FTYPES IFIOX IFMAX IFREADONLY IFSAVED IFSHOW JIJS JIJSMAC JRECENT NEWUSER PPSCRIPT QFORMX RECENT RECENTFILE RECENTLOC RECENTMAX SCMP SMBLK SMDESK SMHWNDP SMINIT SMNAME SMPATH SMSEL SMSIZE SMSTYLE SMTEXT SMTORG aboutj boxfkeys boxskeys checkreadonly cleartemp close closeijs closeijx closewindows comparesvn create cutpara deb destroy exitijs filecase fkeycase fkeylist fkeyrun fkeyselect fkeyselect1 flerase flexist flopen flread flwrite foldpara foldtext getSMSEL getactsize getcascade getcascade1 getcascades getfile getformx getline getsaveas getscrollpos getselection getskey id2loc id2name id2names id2type ide_maximize ide_minimize ide_restore ifshiftkey iftempscript info intn jijs_aboutj_button jijs_actrl_fkey jijs_bctrl_fkey jijs_bctrlshift_fkey jijs_cancel jijs_close jijs_close_button jijs_dctrl_fkey jijs_default jijs_demos_button jijs_ectrl_fkey jijs_ectrlshift_fkey jijs_editconfigure_button jijs_editcopy_button jijs_editcut_button jijs_editdirmatch_button jijs_editexport_button jijs_editfif_button jijs_editfind_button jijs_editformedit_button jijs_editinputlog_button jijs_editlint_button jijs_editpaste_button jijs_editreadonly_button jijs_editredo_button jijs_editselectall_button jijs_editundo_button jijs_f1_fkey jijs_f1ctrl_fkey jijs_f1shift_fkey jijs_fctrl_fkey jijs_fctrlshift_fkey jijs_filecleartemp_button jijs_fileexit_button jijs_filenewclass_button jijs_filenewijs_button jijs_fileopen_button jijs_fileopensystem_button jijs_fileopenuser_button jijs_fileprint_button jijs_fileprintsetup_button jijs_filerecent_button jijs_fkeys_button jijs_forms_button jijs_gctrl_fkey jijs_hctrl_fkey jijs_helpconstants_button jijs_helpcontext_button jijs_helpcontrols_button jijs_helpdictionary_button jijs_helpforeigns_button jijs_helpgeneral_button jijs_helpgl2cmd_button jijs_helphelp_button jijs_helpindex_button jijs_helpphrases_button jijs_helpprimer_button jijs_helprelease_button jijs_helprelnotes_button jijs_helpuser_button jijs_helpvocab_button jijs_helpwdcmd_button jijs_helpwdover_button jijs_ictrl_fkey jijs_jctrl_fkey jijs_kctrl_fkey jijs_kctrlshift_fkey jijs_labadvance_button jijs_labauthor_button jijs_labchapters_button jijs_labs_button jijs_lctrl_fkey jijs_lctrlshift_fkey jijs_max_button jijs_mctrl_fkey jijs_nctrl_fkey jijs_nctrlshift_fkey jijs_octrl_fkey jijs_pctrl_fkey jijs_qctrl_fkey jijs_rctrl_fkey jijs_rctrlshift_fkey jijs_rundebug_button jijs_runfile_button jijs_runfiled_button jijs_runline_button jijs_runpacman_button jijs_runprojman_button jijs_runselection_button jijs_runwindow_button jijs_runwindowd_button jijs_save_button jijs_saveas_button jijs_sctrl_fkey jijs_sellower_button jijs_selminus_button jijs_selplus_button jijs_selplusline1_button jijs_selplusline2_button jijs_selsort_button jijs_seltoggle_button jijs_selupper_button jijs_selwrap_button jijs_tctrl_fkey jijs_tile_button jijs_tileacross_button jijs_tilecascade_button jijs_togglebox_button jijs_wctrl_fkey jijs_wctrlshift_fkey jrecent_cancel jrecent_close jrecent_enter jrecent_lb_button jrecent_open_button jrecent_run jrecent_run_button jrecent_rund_button jrecent_view_button lint marksavedid name2id new newijs newijx nounrep openijs parentname pathname pmovex qsmact qsmall qsmallforms qsmallijs qsmlastijs qsmlastxs qsmout qsmsize query quote rdist readid readid16 readonlydefault recent_open recent_put recent_read recent_run recent_save resizefont restorefont roundint runcompare runexport runfile runimmx0 runimmx1 runline runselection runwindow save saveas saveopenwindows scmp_cancel scmp_close scmp_close_button scmp_current_button scmp_original_button scmp_revert_button scmp_run scmp_show select_line select_text set_fkeys set_skey1 set_skeys setfontall setpnall setreadonly sh smappend smclose smfocus smfocusact smfocusout smgetsel smmove smopen smprompt smread smreplace smsave smscroll smsel smselact smselout smsetcmd smsetsaved smsetselect smwrite sysmodifiers tile tile2fit tile2fit1 tileacross tilecascade tileget todelim tofoldername togglebox togglereadonly togglexs tolist topara ucpboxdraw unboxfkeys unboxskeys winmax
PARI/GP
There are three special variables in GP: Pi
(3.14...), Euler
(Euler's gamma), and I
(the imaginary unit).
PARI has many special variables. Probably the most important is avma
, the current stack pointer, and the related top
and bot
; see section 4.3 of the User's Guide to the PARI Library.
Other important special variables are:
- Universal objects
gen_0
,gen_1
,gen_2
,gen_m1
,gen_m2
,ghalf
, andgnil
. (The manual erroneously omits the last on this list.) These can be identified withis_universal_constant()
. Note thatgen_I
is not a universal object but a function. - Defaults:
DEBUGLEVEL
andDEBUGMEM
- Prime-related variables
_maxprime
(traditionally accessed viamaxprime()
) anddiffptr
- Others:
precdl
,overflow
,hiremainder
, ...
The PARI developer's guide lists two more:
PARI_SIGINT_block
: When this is nonzero, SIGINT is blocked.PARI_SIGINT_pending
: When this is nonzero, a SIGINT has been blocked but not yet handled.
PureBasic
PureBasic has no 'special variables'. It does define constants that reflect compiler settings that can be tested and used as a part of compiling. All other non-explicitly declared values that vary during runtime are returned by functions.
Python
By default, Python starts execution in a namespace which has these globals defined: <lang Python>print dir()</lang>
- Output
['__builtins__', '__doc__', '__file__', '__name__', '__package__']
Tcl
There are three major categories of special variables in Tcl: global variables special to the Tcl language, global variables set by Tcl-based interpreters, and local variables with special interpretations.
Language Globals
These variables are defined by the standard implementation of Tcl, and are present in all Tcl interpreters by default.
- env
- This global array is Tcl's interface to the process's environment variables.
- errorCode
- This global scalar holds a machine-readable description of the last error to occur. (Note that prior to Tcl 8.6, internally-generated exceptions often used NONE for this value.)
- errorInfo
- This global scalar holds a stack trace from the last error to occur.
- tcl_library
- This global scalar holds the location of Tcl's own internal library.
- tcl_version, tcl_patchLevel
- This global scalar holds the version of Tcl in use. From Tcl 8.5 onwards, these hold the same (detailed) value.
- tcl_pkgPath
- This global scalar holds a Tcl list of directories where Tcl looks for packages by default. This is used to initialize the auto_path global variable.
- auto_path
- This global scalar holds a Tcl list of directories where Tcl looks for packages (and auto-loaded scripts, though this facility is deprecated).
- tcl_platform
- This global array holds a description of the platform on which Tcl is executing.
- tcl_precision
- This global scalar holds the number of significant figures to use when converting a floating-point value to a string by default. From Tcl 8.5 onwards it should not be changed. (If you are thinking of using this, consider using the
format
command instead.) - tcl_rcFileName
- This global scalar holds the name of a file to
source
when the interpreter starts in interactive mode. - tcl_rcRsrcName
- This global scalar is only used on classic Mac OS (now deprecated); consult the documentation for more information.
- tcl_traceCompile
- If enabled at library configuration time, this global scalar allows tracing of the compilation of bytecode in the interpreter.
- tcl_traceExec
- If enabled at library configuration time, this global scalar allows tracing of the execution of bytecode in the interpreter.
- tcl_wordchars, tcl_nonwordchars
- These global scalars hold regular expression fragments that describe the current platform's interpretation of what is and isn't a word.
Interpreter Globals
These global variables are only features of the most common Tcl-based shells, tclsh and wish.
- argc
- This global scalar holds the number of arguments (after the script) passed to the Tcl interpreter.
- argv
- This global scalar holds a Tcl list of the arguments (after the script) passed to the Tcl interpreter.
- argv0
- This global scalar holds the name of the main script to execute that was passed to the Tcl interpreter, or the name of the interpreter itself in interactive mode.
- tcl_interactive
- This global scalar holds whether this interpreter is working in interactive mode (i.e., needs to print command prompts, run a REPL, etc.)
- tcl_prompt1, tcl_prompt2
- These global scalars allow customization of the prompt strings in interactive mode.
- geometry
This global scalar holds the user-supplied preferred dimensions of the initial window. Only used by interpreters that load the Tk library.
Local Special Variables
This is a language feature of procedures.
- args
- This local variable holds the Tcl list of arguments supplied to the current procedure after all the other formal arguments have been satisfied. Note that it needs to be explicitly listed in the formal arguments and be last in the list of formal arguments to have this behavior.
ZX Spectrum Basic
The ZX Spectrum uses single letter variables names. None of these are special variables. There are a set of system variables held at a fixed memory addresses, which can be accessed via PEEK and POKE functions. The system variables and addresses are:
- 23552 KSTATE - Keyboard state.
- 23560 LAST K - Newly pressed key.
- 23561 REPDEL - Delay (in 50ths of a second) before keyboard starts repeating.
- 23562 REPPER - Delay (in 50ths of a second) between keyboard repetions.
- 23563 DEFADD - Address of arguments for a user defined function.
- 23565 K DATA - Second byte of colour controls sequences from keyboard.
- 23566 TVDATA - Colour and location information for television set.
- 23568 STRMS - Addresses of channels attached to streams.
- 23606 CHARS - 256 less than the address of the current character set
- 23608 RASP - Length of the warning buzz.
- 23609 PIP - Length of the keyboard click.
- 23610 ERR NR One less than the error code and starts at 255 (for -1)
- 23611 FLAGS - Various flags to control the BASIC system.
- 23612 TV FLAG - Flags associated with the television output.
- 23613 ERR SP - Address of item on machine stack to be used as error return.
- 23615 LIST SP - Return address from automatic listing.
- 23617 MODE - Cursor type
- 23618 NEWPPC - Line number to be jumped to.
- 23620 NSPPC - Statement number in line to be jumped to
- 23621 PPC - Line number of statement currently being executed.
- 23623 SUBPPC - Statement number within the line that is currently being executed.
- 23624 BORDCR - Colour of the border (overscan area) and input area (times 8)
- 23625 E PPC - Current line number (for list editing)
- 23627 VARS - Address of the variables.
- 23629 DEST - Address of variable in assignment.
- 23631 CHANS - Address of channel data.
- 23633 CURCHL - Address of information being used for input and output.
- 23635 PROG - Address of the BASIC program.
- 23637 NXTLIN - Address of the next line in the program.
- 23639 DATADD - Address of terminator of the last DATA item.
- 23641 E LINE - Address of command being typed in.
- 23643 K CUR - Address of the cursor.
- 23645 CH ADD - Address of the next character to be interpreted
- 23647 X PTR - Address of the character after the syntax error marker.
- 23649 WORKSP - Address of temporary work space.
- 23651 STKBOT - Address of bottom of calculator stack.
- 23653 STKEND - Address of start of free space.
- 23655 BREG - The B register of the calculator.
- 23656 MEM - Address of area used for calculator memory.
- 23658 FLAGS2 - Miscellaneous flags.
- 23659 DF SZ - The number of lines in the input area.
- 23660 S TOP - The number of the top program line in automatic listings.
- 23662 OLDPPC - Line number to which CONTINUE jumps.
- 23664 OSPPC - Number within line of statement to which CONTINUE jumps.
- 23665 FLAGX - Various flags.
- 23666 STRLEN - Length of string type destination in assignment.
- 23668 T ADDR - Address of next item in the syntax table.
- 23670 SEED - The random number seed.
- 23672 FRAMES - A 3 byte frame counter incremented every 20ms.
- 23675 UDG - Address of the user defined graphics
- 23677 COORDS Coordinates of the last point plotted.
- 23679 P POSN - Column number for the position of the printer carriage.
- 23680 PR CC - Address of next free position in the printer buffer.
- 23682 ECHO E - Column and line number positions in the input buffer.
- 23684 DF CC - Display address for the current print position.
- 23686 DFCCL - Display address in the input area.
- 23688 S POSN - Column and row number of the print position.
- 23690 SPOSNL - Column and row number for the print position in the input area.
- 23692 SCR CT - Scroll counter - Number of lines left before stopping with Scroll?
- 23693 ATTR P - Permanent current colours attributes
- 23694 MASK P - Permanent current colour attribute mask
- 23695 ATTR T - Temporary current colour attributes
- 23696 MASK T - Temporary current colour attribute mask
- 23697 P FLAG - More flags.
- 23698 MEMBOT - Memory area address used by the calculator
- 23728 NMIADD - The address of the users Non Maskable Interrupt service routine. * 23730 RAMTOP - Address of last byte of BASIC system area.
- 23732 P-RAMT - Address of last byte of physical RAM.
<lang zxbasic>10 PRINT "The border colour is "; PEEK (23624): REM bordcr 20 PRINT "The ramtop address is "; PEEK (23730) + 256 * PEEK (23731): REM ramtop 30 POKE 23609,50: REM set keyboard pip to 50</lang>