[TIB] Re: DOS programming


[Prev][Next][Index][Thread]

[TIB] Re: DOS programming



Thanks, this helps a lot, although I am unhappy to report that my ti92 p
was stolen at school the other day :(. I am looking for it

-----Original Message-----
From: ti-basic-bounce@lists.ticalc.org
[mailto:ti-basic-bounce@lists.ticalc.org] On Behalf Of Travis Evans
Sent: Saturday, May 10, 2003 11:51 PM
To: ti-basic@lists.ticalc.org
Subject: [TIB] Re: DOS programming

From: Jeremy Butcher
> Hi, I am writing a dos program and a few others and
> having problems with the if statements
[snip]
> If left(com,2)=cd Then:setfold(right(com,3)):goto start:EndIf

This statement has a problem. First, you might want to add the quotation
marks around the "cd" as people have suggested, but it still has a
problem.

Here's how the statement will execute. Suppose the user enters "cd math"
at
the prompt.

com = "cd math"

     If left(com,2)="cd"
The leftmost two characters of com are "cd". So far, so good.

     Then:setfold(right(com,3))

Several problems here.
     right(com,3)
In the case of com = "cd math", the rightmost three characters are
"ath",
and the program will try to switch to a folder named "ath". This isn't
what
you want.
Also, if you have a string containing the name of the folder you want to
switch to, and you supply the string to the setFold( command, you will
need
to use indirection. The setFold( command normally expects the folder
name to
be entered directly, rather than a string or string variable name.

Indirection is indicated with the # symbol. It means that a string of
string
variable follows, and that the TI-89 should take the contents of the
string
and assume it were entered directly in place of the # and string or
string
var name.

You'll need to start three characters *into* the com string and continue
to
the end. The mid( function does this.

     mid(com,4,dim(com)-3)

The first parameter is the string name, com.
The second parameter is which char to start with. We start at the fourth
character (instead of the third) to pass the "cd" *and* the space that
will
follow it. That's three characters. We want to start on the fourth
character, to pass those three. (If you actually want the user *not* to
enter a space, though, use 3 instead of 4.)
The third parameter reads until the end of the string. dim( gives how
many
characters a string contains. dim(com) will be 7 in this case. 7 - 3 =
4.
That's the four letters in the name "math." The 3 is subtracted to
ignore
the "cd" and the space at the beginning of the string, which are three
characters.

Or, you could just use mid(com,4,8) which is simpler. This reads 8
characters after the fourth one, or until the end of the string,
whichever
happens first. Since folder names won't be longer than 8 characters
long,
this will ignore anything the user types past the 8-character limit in
the
folder name. You can use this method instead if you want.

Okay, the corrected line in the program should be:
     If left(com,2)="cd" Then:setfold(#mid(com,4,dim(com)-3)):goto
start:EndIf
or:
     If left(com,2)="cd" Then:setfold(#mid(com,4,8)):goto start:EndIf

(BTW, the # character can be entered by pressing [2nd] [CHAR] 3 3.)

> but how do I find out how many vars are in 1 list? This way
> I can disp them all on the screen. Thanks

Use dim( just like I showed with the string vars above. It also works
with
lists (and matrices).
If you have a list {"main",3,5,"abc",7,9,-3} stored to the var list2,
dim(list2) will return 7.

Hope this helps!

--Travis





Follow-Ups: References: