Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

COMPARATIVE OPERATORS_ARDUINO UNO

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Wed Jun 10, 2020 11:00 pm    Post subject: COMPARATIVE OPERATORS_ARDUINO UNO Reply with quote

Hi!!!

I am trying to perform operations inside the Arduino Uno for example:
Comparisons between 2 data A and B and result C by means of serial monitor 1 or 0, true or false.
all works fine as (<, <=, =,>,> =) works fine.
instead this (<>) I get an error why?
I have read with help at bascom to learn and practice.

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32

$baud = 19200

Dim A As Byte
Dim B As Byte
Dim C As Byte

A = 100
B = 100
C = A <> B



Do

 Print C
 Waitms 1000

Loop
End
 


It's wrong?

    Error : 93 Line : 37 Variable not dimensioned [A <> B] , in File : C:\Users\Bienvenido\Desktop\Proyecto_ Bascom_Arduino_ 2020\TIMER\Prueba.bas


Question Question Question Question Question
I am looking forward to your response.
Back to top
View user's profile
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 489
Location: Cleveland, OH

usa.gif
PostPosted: Thu Jun 11, 2020 2:41 am    Post subject: Reply with quote

Quote:
C = A <> B


That puts two operators on the same line, which will confuse the compiler.

One approach would be:

Code:

If A <> B then
  C = 1
Else
  C = 0
End If

 


JC
Back to top
View user's profile Visit poster's website
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Thu Jun 11, 2020 5:37 am    Post subject: Reply with quote

Hi JC !!

Brilliant!! I was going to do this but I already understood and thank you very much JC !!!!!
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 182
Location: Japan

japan.gif
PostPosted: Thu Jun 11, 2020 8:23 am    Post subject: Reply with quote

C = A = B
C = A > B
These arithmetic expressions put True[1] or False[0] of the calculation result in the variable C.

C = A <> B
The above is probably a BASCOM oversight or bug.

However, as JC says, it is possible to directly judge True or False by the IF statement, so the situation where this operator is used is limited.
Back to top
View user's profile Visit poster's website
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Thu Jun 11, 2020 6:22 pm    Post subject: Reply with quote

C = A <> B
The above is probably a BASCOM oversight or bug

You have to work but I don't know how strange I get Bascom error

Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 182
Location: Japan

japan.gif
PostPosted: Fri Jun 12, 2020 12:49 am    Post subject: Reply with quote

To resolve this issue, please contact MCS Support and ask Mark to update!
Back to top
View user's profile Visit poster's website
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 474

PostPosted: Fri Jun 12, 2020 1:15 am    Post subject: Reply with quote

Code:

Dim A As Byte , B As Byte , C As Byte

A = B = C
A = Not A.0
 


e
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Fri Jun 12, 2020 5:29 am    Post subject: Reply with quote

O-Family wrote:
To resolve this issue, please contact MCS Support and ask Mark to update!


Yes and thank you very much !!!
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Fri Jun 12, 2020 6:24 am    Post subject: Reply with quote

enniom wrote:
Code:

Dim A As Byte , B As Byte , C As Byte

A = B = C
A = Not A.0
 


e


Very easy!!! I'm already learning!!!

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32

$baud = 9600

Config Pinb.5 = Output
Led_5 Alias Portb.5
Config Pind.2 = Output
Led_2 Alias Portd.2
Config Pind.3 = Output
Led_3 Alias Portd.3

Dim A As Byte : Dim B As Byte : Dim C As Byte

A = B = C

A.0 = Led_5
A.0 = 1

A = Not A.0


Do
   If A = 1 Then
    Print "Led_5_ON,Led_2_ON,Led_3_ON"
    Waitms 1000
    Set Led_5
    Set Led_2
    Set Led_3
    Else
    A = 0
    Print "Led_5_OFF,Led_2_OFF,Led_3_OFF"
    Waitms 1000
    Reset Led_5
    Reset Led_2
    Reset Led_3
   End If
Loop
End
 
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 226
Location: D.F.

mexico.gif
PostPosted: Thu Jul 16, 2020 7:00 pm    Post subject: Re: COMPARATIVE OPERATORS_ARDUINO UNO Reply with quote

Printpix52 wrote:
Hi!!!

I am trying to perform operations inside the Arduino Uno for example:
Comparisons between 2 data A and B and result C by means of serial monitor 1 or 0, true or false.
all works fine as (<, <=, =,>,> =) works fine.
instead this (<>) I get an error why?
I have read with help at bascom to learn and practice.

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32

$baud = 19200

Dim A As Byte
Dim B As Byte
Dim C As Byte

A = 100
B = 100
C = A <> B



Do

 Print C
 Waitms 1000

Loop
End
 


It's wrong?

    Error : 93 Line : 37 Variable not dimensioned [A <> B] , in File : C:\Users\Bienvenido\Desktop\Proyecto_ Bascom_Arduino_ 2020\TIMER\Prueba.bas


Question Question Question Question Question
I am looking forward to your response.



With my new update to 2.0.8.3 it works fine !!! Very Happy
Back to top
View user's profile
olhexy

Bascom Member



Joined: 03 Apr 2011
Posts: 180
Location: Tilburg, Netherlands

netherlands.gif
PostPosted: Sat Jul 18, 2020 7:51 am    Post subject: Reply with quote

enniom wrote:
Code:

Dim A As Byte , B As Byte , C As Byte

A = B = C
A = Not A.0
 


e

A= Not A.0 ( A is not A dot zero)
What is de exact meaning of that dot (".") ????

EDIT:
I think I found it.
It is hard to find in the Help, but I got a hint at Set, Reset.
This is how I understand it:
A.0 means bit nr 0 of A.
A can be a byte or word.
The bit nr can be 0, 1, ..., 6, 7 in a byte, or 0, 1, ..., 14, 15 in a word.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum