[comp.sys.apple2] BASIC problem

apollo@pro-hindugods.cts.com (Amrit Chauhan) (06/25/91)

I am having problems with the VAL command in BASIC.  Can someone help me
out here?  I have a RamFAST SCSI Card in slot 7 mapping partions to slots
7, 2, and 6.  I don't know if that can cause this problem, but just in
case.  Here is a portion of the program:

10 REM - VAL problems
20 INPUT TI$: REM - This variable contains 9600, 2400, 1200, or 300
30 VAL (TI$)
40 END

This is not the program.  The program itself is rather large, but this is
an example of the VAL command that does not work.  If I was to run this
program with the value of TI$ = 9600, 2400, 1200, or 300, it does:

]run
D


That's it.  The system hangs there just like that and the only way to stop
it from hanging is to hit cntrl-RESET.  I have tried a variety of syntaxes
for VAL like VAL ("9600"), and VAL ("TI") or VAL (TI) and nothing has
worked.  It just does the same thing.  The TI$ variable pulls the baud rate
of a user out of a file.  That comes out as ASCII text and I need the
numerical value associated with it, not the ASCII text.  So, anyone that can
figure out what's wrong, please help me.  Thanks in advance.

Amrit

===The Hindu Love Gods BBS - - - - Bloomfield Hills, MI - - - -313/644-0481===
ProLine:  apollo@pro-hindugods                | Amrit S. Chauhan
Internet: apollo@pro-hindugods.cts.com        | Voice: 313/644-2971
UUCP:     crash!pro-hindugods!apollo          | Intel 9600ex Modem in use.
ARPA:     crash!pro-hindugods!apollo@nosc.mil | PPE member: thanks jwolverton
-------------------------------------------------------------------------------
The only ProLine site in the 313 area.  Come on, someone buy a ProLine here.
:)  :-)  C:#  %-|   =|:-)=  :<)=  `-)  :-C  :-O  :-D  B-)  8-:)  :->  :-c  :*)
===============================================================================

David.Empson@actrix.gen.nz (David Empson) (06/25/91)

Applesoft's VAL is a function, not a command.  As such, you have to
use it in an expression.  Applesoft will lock up if you try to use
some functions by themselves on the line.

What do you actually want to do with the value of the string?  Two
examples would be:

(a) store the value of the string into a variable, as in:

    I = VAL(A$)

(b) print the value of the string, as in:
 
    PRINT VAL(A$)

The latter is slightly pointless, since you could just print the string.





-- 

David.Empson@bbs.actrix.gen.nz

marekp@pnet91.cts.com (Marek Pawlowski) (06/25/91)

You must assign a variable to get the value of the returned result from VAL.

X = VAL(TI$)

That will do it.

/* Marek Pawlowski, President, Intelligent Twist Software, 250 Harding  */
/* Blvd., PO BOX 32017, Richmond Hill, Ontario, L4C 9M7, CANADA.        */
/* marekp@gnu.ai.mit.edu, marekp@cerf.net, marekp@pnet91.cts.com,       */
/* marekp@generic.uucp, Voice: (416) 884-4501 4-8pm Toronto time        */
/* "F U cn rd dis U mst Uz Unix" - ericmcg@pnet91.cts.com               */

drudman@hpcc01.HP.COM (Drew Rudman) (06/26/91)

The VAL command converts a string to a numeric value.  You can assign this
conversion or use it in some fashion.  Legal uses of the VAL function include:

	A = VAL(IT$):REM This will assign A with the numeric value of IT$

	PRINT VAL(IT$):REM this will print the numerical value of IT$

If IT$ has a non-numerical first character, the numerical VALue of it will
be zero.  Hence VAL("AB23") = 0 and VAL("1203")=1203.  I believe the function
will convert to numerics until the first non-numerical character is encountered
in the conversion string.  ie VAL("123ABC") = 123.

Using VAL in the way you have shown is improper.  You should get a ?SYNTAX
ERROR when you program encounters the line - I have no idea why it is hanging.

[ Call...              9600bps/60meg ][ Drew Rudman                          ]
[            The Charge              ][                                      ]
[   Apple ][              IBM        ][ Internet: drudman@hpiosa.corp.hp.com ]
[          (415) 321-4713            ][ The Charge BBS: Axe Slinger (#1)     ]

page@pro-party.cts.com (Niall Durham) (06/27/91)

Hey, you need a numeric variable in front of that command.

        xxxx  input in$
        xxxx  nv=val(in$)
        xxxx  print nv

There you go, hope it helps.

-page

----
ProLine:  page@pro-party
Internet: page@pro-party.cts.com
UUCP:     crash!pro-party!page
ARPA:     crash!pro-party!page@nosc.mil
----
ProLine:  page@pro-party
Internet: page@pro-party.cts.com
UUCP:     crash!pro-party!page
ARPA:     crash!pro-party!page@nosc.mil

mikero@lablues.UUCP (Mike roberge) (06/27/91)

apollo@pro-hindugods.cts.com (Amrit Chauhan) writes:

> I am having problems with the VAL command in BASIC.  Can someone help me
> out here?  I have a RamFAST SCSI Card in slot 7 mapping partions to slots
> 7, 2, and 6.  I don't know if that can cause this problem, but just in
> case.  Here is a portion of the program:
> 
> 10 REM - VAL problems
> 20 INPUT TI$: REM - This variable contains 9600, 2400, 1200, or 300
> 30 VAL (TI$)
> 40 END
> 
> This is not the program.  The program itself is rather large, but this is
> an example of the VAL command that does not work.  If I was to run this
> program with the value of TI$ = 9600, 2400, 1200, or 300, it does:
> 
> ]run
> D
> 
If I'm not mistaken, you have to give the Val of a string to another 
variable. Ex.,       BAUD=VAL(TI$)

I believe that's how it would work, and now BAUD or whatever variable you 
decide to use will contain the correct value.  Anybody can correct me if I'm 
wrong (and I'm sure you will).  But try that.

Mike Roberge