Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Atari BASIC
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===String handling=== Atari BASIC copied the string-handling system of [[HP Time-Shared BASIC|Hewlett-Packard BASIC]],<ref>{{cite book |title=HP 2000/Access BASIC Reference Manual |publisher=Hewlett Packard |date=May 1976 |pages=e |url=http://bitsavers.org/pdf/hp/2000TSB/22687-90001_AccessBasic9-75.pdf }}</ref> where the basic data type is a single character, and strings are arrays of characters. Internally, a string is represented by a pointer to the first character in the string and its length. To initialize a string, it must be DIMensioned with its maximum length. For example: <syntaxhighlight lang="basic"> 10 DIM A$(20) 20 PRINT "ENTER MESSAGE: "; 30 INPUT A$ 40 PRINT A$ </syntaxhighlight> In this program, a 20 character string is reserved, and any characters in excess of the string length will be truncated. The maximum length of a string is 32,768 characters. There is no support for arrays of strings. A string is accessed using array indexing functions, or [[array slicing|slicing]]. <code>A$(1,10)</code> returns a string of the first 10 characters of <code>A$</code>. The arrays are 1-indexed, so a string of length 10 starts at 1 and ends at 10. Slicing functions simply set pointers to the start and end points within the existing allocated memory. Arrays are not initialized, so a numeric array or string contains whatever data was in memory when it was allocated. The following trick allows fast string initialization, and it is also useful for clearing large areas of memory of unwanted garbage. Numeric arrays can only be cleared with a FOR...NEXT loop: <syntaxhighlight lang="basic"> 10 REM Initialize A$ with 1000 characters of X 20 DIM A$(1000) 30 A$="X":A$(1000)=A$:A$(2)=A$ </syntaxhighlight> String concatenation works as in the following example. The target string must be large enough to hold the combined string or an error will result: <syntaxhighlight lang="basic"> 10 DIM A$(12),B$(6) 20 A$="Hello ":B$="there!" 30 A$(LEN(A$)+1)=B$ 40 PRINT A$ </syntaxhighlight> Values in DATA statements are comma-delimited and untyped. Consequently, strings in DATA statements are not typically enclosed by quote marks. As a result, it is not possible for data items to contain a comma but they can incorporate double-quotes. Numeric values in DATA statements are read as strings or as numbers according to the type of the variable they are read into. The READ statement cannot be used with array variables.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Atari BASIC
(section)
Add topic