[Coco] OS9 HEX to DECIMAL conversion.

coco at jechar.ca coco at jechar.ca
Mon May 21 11:34:12 EDT 2018


So based on what you said I tryed

PROCEDURE add
PRAM as:STRING
PRAM bs:STRING
a=VAL(as)
b=VAL(bs)
print a+b
END

Still dosn't work what is the PRECISE syntax for PARAM
and when I call the routine will

basic09 add 5 8

be okay or do I need to call as

basic09 add "5" "8"


On 2018-05-20 20:33, Wayne Campbell wrote:
> As the first response to your email says the key word is PARAM, not
> PARAMETER. Also, if you're using nitros9 and shell+, the parameters 
> will be
> passed as strings. You will have to use string parameters to receive 
> the
> numbers and then convert those strings to actual numbers. Also again,
> DIMing parameters or variables requires the use of type identifiers. 
> These
> are Atomic types, unless you have defined a complex type. Atomic types 
> are:
> 
> REAL
> INTEGER
> BOOLEAN
> BYTE
> STRING
> USER DEFINED (COMPLEX TYPE)
> 
> STRING without a length modifier defaults to 32 characters. Use
> STRING[size] to set a length from 1 to 32767 (max length).
> 
> 
> On Sun, May 20, 2018, 2:51 PM <coco at jechar.ca> wrote:
> 
>> Thanks for the Info.
>> 
>> For my problem with HEX calculations I have found a solution
>> Involving breaking the number into 2 sets of three Hex digits and 
>> using
>> FLOAT and FIX to convert to REAL for the Math and then back to Integer
>> to PRINT USING H3.
>> 
>> I an ready to go on to the next step where I want to pass
>> parameters from the command line to my program, so not having written
>> basic09 code in 15 years I looked for a sample program from  the 
>> manual.
>> 
>> The program I found I have listed below.
>> 
>> PROCEDURE add
>> PARAMETER a,b
>> PRINT a+b
>> END
>> 
>> This is exactly as I wrote it as I used list add>/p
>> to send it to a file on my PC and then cut and pasted it into
>> this email.
>> 
>> But something is wrong as I get these errors.
>> 
>> add
>> PARAMETER a,b
>>            ^
>> ERROR #027
>> ERROR #051
>> Ready
>> B:
>> 
>> 
>> Help Please!
>> 
>> On 2018-05-19 20:39, L. Curtis Boyle wrote:
>> > Discord is an app (available for multiple platforms, or through a web
>> > browser), which you can get here:
>> > https://discordapp.com
>> >
>> > Then, find the server “TRS-80 CoCo TALK”.
>> >
>> > L. Curtis Boyle
>> > curtisboyle at sasktel.net
>> >
>> >> On May 19, 2018, at 3:30 PM, coco at jechar.ca wrote:
>> >>
>> >> Thanks for the Info it is giving me some ideas about what I may have
>> >> to do to deal with these calculations.
>> >>
>> >> What URL is "Discord" at ?
>> >>
>> >> On 2018-05-16 14:41, L. Curtis Boyle wrote:
>> >> Your error is due to pushing beyond the signed 16 bit limits of the
>> >> hex routines in BASIC09. It does work fine within 16 bit signed
>> >> values
>> >> (I put some screenshots of test source code, and a sample run, in
>> >> the
>> >> BASIC09 section on Discord).
>> >> On May 16, 2018, at 12:19 PM, James Jones <jejones3141 at gmail.com>
>> >> wrote:
>> >> Tried it out. VAL("$61A80") gives an error 67, "illegal argument".
>> >> VAL("A80") prints as 2688., so VAL() returns a REAL, which I guess
>> >> it has
>> >> to for consistency with other BASICs. Hex PRINT USING output claims
>> >> to be
>> >> fine with printing a REAL, but perhaps the VAL() code for hex
>> >> doesn't
>> >> handle values that won't fit in an INTEGER. (What's 61A80? 400000 in
>> >> hex.)
>> 
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>> 


More information about the Coco mailing list