Author |
Topic: Converting Variable Types (Read 769 times) |
|
DJ-Dwayne
New Member
member is offline


Gender: 
Posts: 4
|
 |
Converting Variable Types
« Thread started on: Jun 19th, 2015, 07:25am » |
|
.....Is there a command to to do this?
I'm new here and to bbfw
I'm sending numbers from my Arduino over the com port ready to be read from bbfw.
I've got it basically working, but there's a problem. The ending variables in bbfw aren't numeric, so I can't do any maths with them.
I don't know if i'm sending the data incorrectly from my Arduino board or i'm reading it wrong in bbfw. ???
I hope I don't get in trouble, but i'll show the code from both the Arduino and bbfw.
The Arduino Code.... Code:int value;
void setup() {
pinMode(13, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
value = random(1, 100); //select a random number between 0 and 100:
Serial.print(value);
Serial.write(13);//end data(CR);
}
The BBC Basic Code.... Code:
MODE7
VDU 23,1,0;0;0;0; : REM Disable cursor
VDU4
arduino%=OPENUP("COM18: baud=9600 parity=N data=8 stop=1")
PRINT "Com 18 Opened as Channel ";arduino%
140 INPUT#arduino%,number$ :REM Get Data being sent
VDU30
PRINT TAB(6,1)" ";
VDU30
PRINT TAB(0,1)"DATA=";number$
GOTO 140
NOTE.....please excuse the naughty "goto" command :-*
Now....I can only use the "number$" type variable to get the numbers I want. e.g.
number$="55" (Correct but unusable for Maths)
but if i took away the $ sign, I get something in the order of...
number = 9.25474568E-24 (WTF?????)
Maybee i'm not understanding strings v's bytes or something over serial.
I'm stumped just trying to explain the problem....PLEASE HELP.
|
« Last Edit: Jun 19th, 2015, 07:30am by DJ-Dwayne » |
Logged
|
|
|
|
DJ-Dwayne
New Member
member is offline


Gender: 
Posts: 4
|
 |
Re: Converting Variable Types
« Reply #1 on: Jun 19th, 2015, 07:55am » |
|
Grrr... found the answer.
VAL
staring me right in the face. Is there a better way or not?
|
|
Logged
|
|
|
|
dfeugey
Guest
|
 |
Re: Converting Variable Types
« Reply #2 on: Jun 19th, 2015, 09:36am » |
|
I don't think so.
|
|
Logged
|
|
|
|
DJ-Dwayne
New Member
member is offline


Gender: 
Posts: 4
|
 |
Re: Converting Variable Types
« Reply #3 on: Jun 19th, 2015, 10:12am » |
|
on Jun 19th, 2015, 09:36am, dfeugey wrote:
????? Please explain. I just went.... Code: I can now do maths with it. Or is there a better way? Please tell ???
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Converting Variable Types
« Reply #4 on: Jun 19th, 2015, 2:47pm » |
|
on Jun 19th, 2015, 10:12am, DJ-Dwayne wrote:Or is there a better way? |
|
VAL is the correct way.
Richard.
|
|
Logged
|
|
|
|
dfeugey
Guest
|
 |
Re: Converting Variable Types
« Reply #5 on: Jun 20th, 2015, 08:44am » |
|
Quote: Easy  Is there a better way? > I don't think so. That's the only and right way to do it.
|
« Last Edit: Jun 20th, 2015, 08:45am by dfeugey » |
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Converting Variable Types
« Reply #6 on: Jun 20th, 2015, 11:43am » |
|
Just to add that VAL is affected by the *lowercase setting:
Code: *lowercase on
PRINT VAL("1e3")
*lowercase off
PRINT VAL("1e3") Richard.
|
|
Logged
|
|
|
|
|