BBC BASIC for Windows
« CVI »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:13pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: CVI  (Read 1546 times)
dynamic35
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 34
xx CVI
« Thread started on: Jan 6th, 2010, 5:45pm »

1st of all, thanks for the fine B2C Basic for Windows system I purchased for a Christmas gift (to myself. Only one supprise here.
The command CVI is missing. Or is it? It is needed in my first application reading on-line a well known home Weather Station in order to result a WeatherTalker (via serial COMM) -using a method given in among the BBC BASIC sound examples (SPEAK.BCC)
Is there a CVI (Qbasic) kind of command somewhere in this language?
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: CVI
« Reply #1 on: Jan 6th, 2010, 9:39pm »

Quote:
The command CVI is missing. Or is it?

A good way to find equivalents to QBASIC functions is to run QB2BBC (the QBASIC to BBC BASIC translator) and see what happens. In the case of CVI this is what you get:

Code:
A = CVI(B$)
translates to
A = FN_cvi(B$) 

So in this case there is an equivalent function in QBLIB. Looking there we find this (rather cryptic) code:

Code:
DEF FN_cvi(A$) = ((!!^A$) << 16) >> 16 

The QBASIC to BBC BASIC translator can be found here:

http://groups.yahoo.com/group/bb4w/files/Tools/QB2BBC.exe

and QBLIB, if you need it separately, is here:

http://groups.yahoo.com/group/bb4w/files/Libraries/QBLIB.BBC

Richard.
User IP Logged

dynamic35
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 34
xx Re: CVI
« Reply #2 on: Jan 6th, 2010, 10:02pm »

Thanks Richard. meanwhile I planned something like this but not yet tested it with a weather station
Yr sentence is anyhow very much shorter!
DEF FN_cvi(a$)
Hbyte$=LEFT$(a$,1)
Lbyte$=RIGHT$(a$,1)
Msbyte% = ASC(Lbyte$)
Lsbyte% = ASC(Hbyte$)
IF Msbyte% >127 THEN
Msbyte% = (Msbyte% EOR 255)
Iresu% = Msbyte%*256+(Lsbyte% EOR 255)
Iresu% = (Iresu%*(-1))-1
ELSE
Iresu% = Msbyte%*256 + Lsbyte%
ENDIF

=Iresu%
User IP Logged

dynamic35
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 34
xx Re: CVI
« Reply #3 on: Jan 7th, 2010, 10:36pm »

Just a note ,after testing succesfully both of those, I found that in the CVIs above , the argument (A$) there must be sum of CHR$s. So if I read via my weather station's serial port #sepo% two numbers i1% and i2% like this
i1%=BGET#sepo%
i2%=BGET#sepo%

then the CVI argument will be A$= CHR$(i1%)+ CHR$(i2%)
Then FN_cvi(A$) results (in my case f.e) -- say the outside temperature nicely in the proper range -60. ....+60 C.

If we just make simply mathematics with formulas like
CVI= lowbyte + 256* Highbyte then we will -as an example get - very wrong values now and then below -17.7 C (fahrenheit 0) say number like +3500 C instead of -20 C
The challence for anybody (not just to NASAs space sw programmers (with F-mathematics?) is a must to avoid the Fahrenheit 0-problem seen here too, namely that the zero temperature in F-mathematic is allways 0 F (-17.7C) and in C mathematics 0C occurs at +32F.
In weather stations /sw.s --tested in normal winter coldness ----15..+++5 C , someone may never have a possibility to meet those kind of zero division problems -even with his/hers Fahrenheit weather mathematics, if products are tested in real life/ outdoors in normal weather conditions (not at least near NASA's Huntsville facilities were we had a nice time while visiting an ICAE seminar in 1999)
So lets test our weather station applications in a cold storage or here at 62+N

User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls