-=> Quoting LANCE REYNOLDS to DOUG WILSON <=-
-=> FidoMail to 1:163/215, please.-=<
LR> Well, it compiles...
LR> main()
LR> {
LR> str fspec[30] = "c:\UPLD\SHAKEY.REP";
LR> str buf[30];
LR> int chr;
LR> int n1 = 3;
LR> int n2 = 4;
LR> int stat, t1, t2, t3, t4, t5, t6, t7; //max # of tracks is 16?
LR> t1 = "st and last name?", 0;
LR> t2 = "assword?", 0;
LR> t3 = "onstop, [C]ontinue? [ ] ", 0;
LR> t4 = "[L]ist, [C]ontinue? [ ] ", 0;
LR> t5 = "Press ENTER", 0;
LR> t6 = "Your command? ", 0;
LR> t7 = "our Message command? ", 0;
You have a problem with the above. Note the line:
int stat, t1, t2, t2 .....
That defines the _variables_ stat, t1, t2, etc as _integers_.
The next lines (t1 = "st and last name?") then try to set these
_integer_ variables to strings, and that won't do what you want it to
do. That's why the t1[] = "st and... " gives an error: the []
define an "array", and SALT doesn't accept arrays of integers. Let's
take a side trip here, since you asked about the [] in an earlier
post.
Consider your first variable definition:
str fspec[30] = "c:\UPLD\SHAKEY.REP";
That defines a string variable called "fspec" and sets its size to 30
characters. The [30] is an array subscript that defines the length
of the string the variable can hold. If you look at what SALT
produces from this statement, you'd see something like this:
Name Val Address
fspec c 100
: 101
\ 102
U 103
P 104
...
The "address" is just for purposes of our explanation here. It says
a variable called "fspec" starts at address 100, and that address
contains "c". Address 102 contains ":", and so on. Address 129 (the
end of the string) would contain a blank - because you have
"reserved" 30 addresses for your string, but only filled it with 18
characters - so the rest are blank. (Actually, they're not: they're
the _value_ 0 - which is used by SALT as a "string terminator".
You could define that same string like this:
str fspec[] = "c:\UPLD\SHAKEY.REP";
It's still a string, but by specifying an "empty" subscript, you're
telling the SALT compiler to reserve enough space for the string as
defined. SALT would create the same string as before, but would
allocate only 19 bytes for it - 18 bytes for the characters you've
defined, and 1 byte for the "string terminator" - 0.
Now, back to our regular discussion, already in progress:
Here's what you _really_ want, from an example taken from one of my
scripts:
int stat, trk1, trk2, trk3, trk4, trk5, trk6, trk7, trk8, tmark;
//
// Login strings
//
str escreq[] ="enter BBS.";
str name[] = "name:";
str namever[] =" Collins [Y,n]?";
str pass[] = "Password:";
str cont[] = "ENTER to";
str files[] = "to you?";
str more[] = "More";
str mail[] = "for mail? [Y,n]";
str sel[] = "Your Choice?";
str tstr[6]=" ";
//
main()
{
... bunch o stuff deleted
do_login()
{
int ctr = 0;
trk1 = track (escreq, 1);
trk2 = track (files, 1);
trk3 = track (name,1);
trk4 = track (namever,1);
trk5 = track (pass, 1);
trk6 = track (cont,1);
trk7 = track (sel,1);
terminal();
stat = track_hit (0); // see which (if any) track was hit
if (stat == trk7)
{
break;
}
else if (stat == trk6)
{
capture(cap_file);
cputs("^M");
}
... bunch o stuff deleted
Note that the integer variables (trk1, trk2, etc) are assigned to the
various strings that are to be tracked by the "track" command. For
example, the statement:
trk7 = track(sel,1);
essentially says "associate the variable "trk7" with the string "Your
Choice?". Then, later in the script the statement:
stat = track_hit (0);
Puts the track number that was hit in "stat", and the statement:
if (stat == trk7)
tests to see if the "hit" was caused by the variable referenced by
"trk7".
So, the steps are essentially as follows:
1) define integer variables for the tracks: (int t1, t2, t3)
2) define string variables for the strings you wish to detect:
str name[] = "st and last name?", 0;
str password[] = "assword?", 0;
3) Associate a "string" with a int variable:
t1 = track (name, 1);
t2 = track (password, 1);
4) use the "track_hit" command to detect if a track was hit, and then
isolate which one.
That's enough for now. Post if you have problems.
TTFN. Rick.
Ottawa, ON 25 May 7:09
--- Blue Wave/DOS v2.20
---------------
* Origin: BitByters BBS, Rockland ON, Can. (613)446-7773 v34, (1:163/215)
|