Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Action! (programming language)
(section)
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!
== Language == === Data types === Action! has three fundamental [[data type]]s, all of which are numeric. '''BYTE''' is internally represented as an [[signedness|unsigned]] 8-[[bit]] integer. Values range from 0 to 255.<br> The CHAR keyword can also be used to declare BYTE variables. BYTE age=[21] ; declare age and initialize it to the value 21 BYTE leftMargin=82 ; declare leftMargin at address 82 '''CARD'''inal is internally represented as an [[signedness|unsigned]] 16-[[bit]] integer. Values range from 0 to 65,535. CARD population=$600 ; declare population and store it at address 1536 and 1537 CARD prevYear, curYear, nextYear ; use commas to declare multiple variables '''INT'''eger is internally represented as a [[signedness|signed]] 16-[[bit]] integer. Values range from -32,768 to 32,767. INT veryCold = [-10] INT profitsQ1, profitsQ2, ; declaring multiple variables can profitsQ3, profitsQ4 ; span across multiple lines Action! also has ARRAYs, POINTERs and user-defined TYPEs. No [[floating point]] support is provided. An example of a user-defined TYPE: TYPE CORD=[CARD x,y] CORD point point.x=42 point.y=23 === Reserved words === A [[reserved word]] is any identifier or symbol that the Action! compiler recognizes as something special. It can be an operator, a data type name, a statement, or a compiler directive. <nowiki>AND FI OR UNTIL = (</nowiki> <nowiki>ARRAY FOR POINTER WHILE <> )</nowiki> <nowiki>BYTE FUNC PROC XOR # .</nowiki> <nowiki>CARD IF RETURN + > [</nowiki> <nowiki>CHAR INCLUDE RSH - >= ]</nowiki> <nowiki>DEFINE INT SET * < "</nowiki> <nowiki>DO LSH STEP / <= '</nowiki> <nowiki>ELSE MOD THEN & $ ;</nowiki> <nowiki>ELSEIF MODULE TO % ^</nowiki> <nowiki>EXIT OD TYPE ! @</nowiki> === Example code === The following is example code for [[Sieve of Eratosthenes]] written in Action!. In order to increase performance, it disables the [[ANTIC]] graphics coprocessor, preventing its [[Direct memory access|DMA]] engine from "stealing" CPU cycles during computation. BYTE RTCLOK=20, ; addr of sys timer SDMCTL=559 ; DMA control BYTE ARRAY FLAGS(8190) CARD COUNT,I,K,PRIME,TIME PROC SIEVE() SDMCTL=0 ; shut off Antic RTCLOK=0 ; reset the clock to zero COUNT=0 ; init count FOR I=0 TO 8190 ; and flags DO FLAGS(I)='T ; "'T" is a compiler-provided constant for True OD FOR I=0 TO 8190 ; now run the sieve DO IF FLAGS(I)='T THEN PRIME=I+I+3 K=I+PRIME WHILE K<=8190 DO FLAGS(K)='F ; "'F" is a compiler-provided constant for False K==+PRIME OD COUNT==+1 FI OD TIME=RTCLOK ; get timer reading SDMCTL=34 ; restore screen PRINTF("%E %U PRIMES IN",COUNT) PRINTF("%E %U JIFFIES",TIME) RETURN
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)