Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
act
TOOLBOX.ACT 1.2 kB 1 05-Jul-2015 15:26 Roland B. Wassenberg TOOLBOX.ACT
atr
Toolbox.atr 92.2 kB 1 05-Jul-2015 15:26 Roland B. Wassenberg Toolbox.atr
pdf
actiontoolbx.PDF 156.0 kB 1 19-Dec-2010 22:06 Carsten Strotmann
gif
actiontoolbx.gif 29.3 kB 1 19-Dec-2010 22:06 Carsten Strotmann

This page (revision-13) was last changed on 05-Jul-2015 15:29 by Roland B. Wassenberg  

This page was created on 19-Dec-2010 22:06 by Carsten Strotmann

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 1 changed one line
!!! ACTION! Wordfind and Matchup Routines
!General Information
Author: Kevin Sharratt\\
Language: ACTION!\\
Compiler/Interpreter: ACTION!\\
Published: ANTIC Vol. 7, #6 (10/ 88)\\
----
!!!ACTION! Toolbox
!Lightning-fast command finder
At line 3 changed one line
from ANTIC October 1988
''Two powerful and widlely useful routines for the ACTION! programming language. These programs work on all 8-bit Atari computers of any memory size, with disk or cassette. The ACTION! cartridge from ICD/OSS is required.''
At line 5 changed one line
[{Image src='actiontoolbx.gif'}]
Whether you're using ACTION! to build "The Wizards of Zondar" or "The Ultimate Chef's Companion," your programming toolbox will be incomplete without a procedure that removes individual words from a string you've entered - and a procedure that compares those words with a list of known words in hopes of a match.
At line 14 added 106 lines
For efficiency and versatility, the following two procedures fill the gap nicely and can easily be customized by experienced ACTION! programmers.
!1: WORDFIND
This procedure strips each Word, one at a time, from String--which is a global __BYTE ARRAY__ similar to a BASIC string variable. In the process it discards the spaces between Words, no matter how many times you pressed the [SPACEBAR].
In its first loop, __Wordfind()__ searches String for a non-space character, incrementing the Index into the array as it goes. Upon finding one, it stores the Index value in Start. The next loop searches for a space - and the end of the Word - while continuing to increment Index.
When another space or the end of the array is found, the procedure writes the characters between Start and Index into the global Word. Since Index, too, is a global variable, calling __Wordfind()__ again will result in the next consecutive Word. Therefore, Index must be set to 1 before each new string is examined.
!2: MATCHUP
In most applications, after you isolate a single Word you'll want to check it against the commands with which your program is prepared to deal. __Matchup()__ can help you here.
This procedure requires that each global List of commands contains only elements of the same length. For example:
{{{
Comlist1 = "EAST WEST NORTH SOUTH"
Comlist2 = "EAWENOSO"
}}}
In Comlist1 the Increment is five--meaning that a new command begins every five characters. Comlist2 has shortened those same commands to two characters. In either case, __Matchup()__ must be called using three parameters: the potential Command to be compared, the List of known commands and the Increment of the list.
__Matchup()__ then jumps through the list by Increments, searching the first character of each command for a match. Upon finding one, it compares the remaining characters. If all the characters match, it alters the global variable Match to show where in the list the command was found. For example, after calling __Matchup(Word, Comlist1 ,5)__ you find that Match=6. You then know that "Word" matched the command beginning at character 6 - in this case, WEST.
__Matchup()__ will not search past either the given Increment or a space. Thus, if you call it to examine the word WESTERLY against Comlist1, Match would still equal 6. If no match is found, Match will equal 0. As a global, Match can be used in any number of procedures, but it is always reset by the next call to __Matchup()__.
!CALLER EXAMPLE
Carefully type in Listing One, TOOLBOX.ACT, and store a copy to disk before you compile and run it.
The sample __Caller()__ procedure shows you how to use __Wordfind()__ and __Matchup()__. In this example, Comlist, the command list, is "DOG CAT COW MULE". When run, the program asks you to type one of the four Words in the command list. Then the program finds the Word in the command list and prints the word and its position in the string.
----
''Kevin Sherratt is a full-time science fiction writer and part-time programmer from London, Ontario. He is currently working on an 800XL text adventure game. This is his first appearance in Antic.''
----
Listing 1
{{{
; ACTION! TOOLBOX
; BY KEVIN SHERRATT
; (c)1988, ANTIC PUBLISHING
MODULE
BYTE Index,
Match
BYTE ARRAY String,
Word,
Comlist
PROC Wordfind()
BYTE Start,
Counter
FOR Counter=Index TO String(0)
DO
IF String(Index)<>32 THEN
EXIT
FI
Index==+1
OD
Start=Index
FOR Counter=Index TO String(0)
DO
IF String(Index)=32 THEN
EXIT
FI
Index==+1
OD
ScopyS(Word,String,Start,Index)
RETURN
PROC Matchup(BYTE ARRAY Command, List BYTE Increment)
BYTE Counter1,
Counter2
Match=0
FOR Counter1=1 TO List(0) STEP Increment
DO
IF Command(1)=List(Counter1) THEN
Match=1
FOR Counter2=2 TO Increment
DO
IF List(Counter1+Counter2-1)=32 THEN
EXIT
ELSEIF Command(Counter2)<>List(Counter1+Counter2-1) THEN
Match=0:EXIT
FI
OD
FI
IF Match=1 THEN
EXIT
FI
OD
IF Match=1 THEN
Match=Counter1
FI
RETURN
PROC Caller()
Comlist="DOG CAT COW MULE"
Print("TYPE ONE OF THE FOLLOWING: ")
PrintE(Comlist)
InputS(String)
Index=1
Wordfind()
Matchup(Word, Comlist, 4)
PrintE(Word)
PrintBE(Match)
RETURN
}}}
----
Version Date Modified Size Author Changes ... Change note
13 05-Jul-2015 15:29 5.323 kB Roland B. Wassenberg to previous
12 05-Jul-2015 15:26 5.279 kB Roland B. Wassenberg to previous | to last
11 08-Feb-2011 20:49 5.144 kB Gromit to previous | to last
10 08-Feb-2011 20:48 5.144 kB Gromit to previous | to last
9 08-Feb-2011 20:47 5.14 kB Gromit to previous | to last
8 08-Feb-2011 20:46 5.138 kB Gromit to previous | to last
7 03-Feb-2011 14:45 0.133 kB Gromit to previous | to last
6 03-Feb-2011 14:45 0.191 kB Gromit to previous | to last ACTION Toolkit ==> ACTION Toolbox
5 03-Feb-2011 14:45 0.176 kB Gromit to previous | to last ACTION Toolkit ==> ACTION Toolbox
4 03-Feb-2011 14:43 0.176 kB Gromit to previous | to last ACTION Wordfind and Matchup ==> ACTION Toolkit
3 03-Feb-2011 14:43 0.161 kB Gromit to previous | to last ACTION Wordfind and Matchup ==> ACTION Toolkit
2 19-Dec-2010 22:08 0.161 kB Carsten Strotmann to previous | to last
1 19-Dec-2010 22:06 0.106 kB Carsten Strotmann to last
« This page (revision-13) was last changed on 05-Jul-2015 15:29 by Roland B. Wassenberg  
G’day (anonymous guest) My Prefs
© 2010-2021 AtariWiki
All content in the Wiki is licensed under Creative Commons Share Alike License, unless otherwise noted.
JSPWiki v2.8.3