Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

And or not etc in Oshonsoft

Status
Not open for further replies.

camerart

Well-Known Member
Hi,
I am working through programs trying to get a project working in Oshonsoft. Some of the lines I am copying in C have digital and logic ANDs ORs and NOTs
e,g, if ((a & b) AND (NOT(a & c)))

Can someone give me an idea of how it may look in Oshonsoft please? Can Oshonsoft do this, or do each group need to be worked out first without brackets?

I'll try to some different ways and see if I can get anything to simulate.

Thanks, Camerart.
 
Oshonsoft accepts only one logic operation in a statement.
Look the Basic compiler reference manual.
 
Oshonsoft accepts only one logic operation in a statement.
Look the Basic compiler reference manual.
Hi J,
After finding similar when trying 'ORs' earlier, I thought this may be the case.

Of course, I checked the manual before enquiring and only one logic statement is shown in the example, but I was hoping:)

Does this mean that the manual shows the full range of possibilities for all operations?
C.
 
e,g, if ((a & b) AND (NOT(a & c)))
hi C,

Dim x as Byte
Dim y as byte

One option is.
x= a AND b
y= a AND c
y = NOT y

IF x AND y =Condition then

E.

Clip from manual.

Logical Operators.
For Bit data type variables seven logical operations are available.
It is possible to make only one logical operation in one single statement.
Logical operations are also available for Byte and Word variables.

For example:

DIM A AS BIT
DIM B AS BIT
DIM X AS BIT
X = NOT A
X = A AND B
X = A OR B
X = A XOR B
X = A NAND B
X = A NOR B
X = A NXOR B

DIM A AS WORD
DIM B AS WORD
A = A OR B
PORTB = PORTC AND %11110000
 
Morning Eric,
I looked a those examples in the manual, but there are no answers to compare with.

So far I found (from external searches) how '&' works, I'm looking up 'AND' now.

I presume that each bracket must be done separately (in order) in a nest of IF ENDIFs?
C.

hi C,

Dim x as Byte
Dim y as byte

One option is.
x= a AND b
y= a AND c
y = NOT y

IF x and y =Condition then

E.

Clip from manual.

Logical Operators.
For Bit data type variables seven logical operations are available.
It is possible to make only one logical operation in one single statement.
Logical operations are also available for Byte and Word variables.

For example:

DIM A AS BIT
DIM B AS BIT
DIM X AS BIT
X = NOT A
X = A AND B
X = A OR B
X = A XOR B
X = A NAND B
X = A NOR B
X = A NXOR B

DIM A AS WORD
DIM B AS WORD
A = A OR B
PORTB = PORTC AND %11110000
 
morning C.
The '&' symbol is just an alternate way of writing 'AND'.
OSH uses 'AND' and will not accept '&'

Likewise
the '|' symbol is used as 'OR' in some compilers, use only 'OR' in OSH

Post the just the section of the pre-converted code, showing the expected conditions, not the whole program.
From that I should be able to see what is the action of the Statements.

E
 
morning C.
The '&' symbol is just an alternate way of writing 'AND'.
OSH uses 'AND' and will not accept '&'

Likewise
the '|' symbol is used as 'OR' in some compilers, use only 'OR' in OSH

Post the just the section of the pre-converted code, showing the expected conditions, not the whole program.
From that I should be able to see what is the action of the Statements.

E
Hi Eric, Ok. C.
 
Hi,
This reminds me of the use of English example: What are the most times AND can be used consecutively in one sentence?

A sign-writer is painting a pub sign 'Pig and whistle' but he has placed the words too close together. The landlord came out and said "Put a bigger space between Pig and and and and and whistle".
C.
 
Last edited:
Oshonsoft can use only bitwise operators of C.
eg. & -> And, | -> Or, ~ -> Not, etc.
but no != , ||, && operators
 
Oshonsoft can use only bitwise operators of C.
eg. & -> And, | -> Or, ~ -> Not, etc.
but no != , ||, && operators
Hi J,
It's early days for me with operators. am I correct that ~ is the same as !

I have ! in the program I'm trying to translate to Oshonsoft BASIC.
C.
 
Hi J,
It's early days for me with operators. am I correct that ~ is the same as !

I have ! in the program I'm trying to translate to Oshonsoft BASIC.
C.
If it is the program you posted in another thread,
the ! was != ( not equal) and could be replaced by <> in Oshonsoft.
 
Hi I,
I presume that the [Not!] in your answer is your explanation, and not the first example.
C.
Yep! you figured correctly..

Not! No! Never! Not a chance! of doing this in Oshonsoft!!!!!!
 
Actually! There is a good chance...

e,g, if ((a & b) AND (NOT(a & c)))

Here is my way

dim res1 as byte
dim res2 as byte

res2 = a and b
res 1 = a and c
res1 = not res1

if res2 and res1 then......
 
Yep! you figured correctly..

Not! No! Never! Not a chance! of doing this in Oshonsoft!!!!!!
Hi I,
Yep! you figured correctly.. ----- Good!

Not! No! Never! Not a chance! of doing this in Oshonsoft!!!!!! -----:eek: I've spent weeks so far.
C.
 
Actually! There is a good chance...



Here is my way

dim res1 as byte
dim res2 as byte

res2 = a and b
res 1 = a and c
res1 = not res1

if res2 and res1 then......
Hi I,
There is a good chance... ----- :joyful: I've put the razor back in the drawer.

Your way! I'll give it a go, thanks.
c.
 
Hi,
I have lines like;
blah (apple OR banana OR orange OR peach)
and similarly:
blah (apple AND banana AND orange AND peach)

When using the suggestions does it matter if they are 'done' in different orders? In other words, if I first (apple OR banana) then (orange OR peach) then (res1 OR res2) or 'say' OR each fruit as I go along? Similarly for AND.
C.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top