Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:02 03 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Problem with 0

Author Message
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 82
Posted: 10:02am 21 Dec 2014
Copy link to clipboard 
Print this post

Hi

I need to selectively remove the 0's from the output of this array, the format is: If the 0 is the first character (0,9,11) it needs to be read so the output is 0,9,11 if the 0 is the second or third character (3,8,0) it needs to be ignored so the output is 3,8

I have tried (with my limited knowlege of BASIC) everything I can think of

Any ideas ?

setpin 21, dout
pin(21) = 0
dim Out$

'''''''''''''''''''''Primary Alphabet
dim STRING A(256) LENGTH 8 'DominoEX16 Primary Alphabet
DATA " 1,15, 9"," 1,15,10"," 1,15,11"," 1,15,12"," 1,15,13"," 1,15,14"," 1,15,15"," 2, 8, 8"
DATA " 2,12, 0"," 2, 8, 9"," 2, 8,10"," 2, 8,11"," 2, 8,12"," 2,13, 0"," 2, 8,13"," 2, 8,14"
DATA " 2, 8,15"," 2, 9, 8"," 2, 9, 9"," 2, 9,10"," 2, 9,11"," 2, 9,12"," 2, 9,13"," 2, 9,14"
DATA " 2, 9,15"," 2,10, 8"," 2,10, 9"," 2,10,10"," 2,10,11"," 2,10,12"," 2,10,13"," 2,10,14"
DATA " 0, 0, 0"," 7,11, 0"," 0, 8,14"," 0,10,11"," 0, 9,10"," 0, 9, 9"," 0, 8,15"," 7,10, 0"
DATA " 0, 8,12"," 0, 8,11"," 0, 9,13"," 0, 8, 8"," 2,11, 0"," 7,14, 0"," 7,13, 0"," 0, 8, 9"
DATA " 3,15, 0"," 4,10, 0"," 4,15, 0"," 5, 9, 0"," 6, 8, 0"," 5,12, 0"," 5,14, 0"," 6,12, 0"
DATA " 6,11, 0"," 6,14, 0"," 0, 8,10"," 0, 8,13"," 0,10, 8"," 7,15, 0"," 0, 9,15"," 7,12, 0"
DATA " 0, 9, 8"," 3, 9, 0"," 4,14, 0"," 3,12, 0"," 3,14, 0"," 3, 8, 0"," 4,12, 0"," 5, 8, 0"
DATA " 5,10, 0"," 3,10, 0"," 7, 8, 0"," 6,10, 0"," 4,11, 0"," 4, 8, 0"," 4,13, 0"," 3,11, 0"
DATA " 4, 9, 0"," 6,15, 0"," 3,13, 0"," 2,15, 0"," 2,14, 0"," 5,11, 0"," 6,13, 0"," 5,13, 0"
DATA " 5,15, 0"," 6, 9, 0"," 7, 9, 0"," 0,10,14"," 0,10, 9"," 0,10,15"," 0,10,10"," 0, 9,12"
DATA " 0, 9,11"," 4, 0, 0"," 1,11, 0"," 0,12, 0"," 0,11, 0"," 1, 0, 0"," 0,15, 0"," 1, 9, 0"
DATA " 0,10, 0"," 5, 0, 0"," 2,10, 0"," 1,14, 0"," 0, 9, 0"," 0,14, 0"," 6, 0, 0"," 3, 0, 0"
DATA " 1, 8, 0"," 2, 8, 0"," 7, 0, 0"," 0, 8, 0"," 2, 0, 0"," 0,13, 0"," 1,13, 0"," 1,12, 0"
DATA " 1,15, 0"," 1,10, 0"," 2, 9, 0"," 0,10,12"," 0, 9,14"," 0,10,12"," 0,11, 8"," 2,10,15"
DATA " 2,11, 8"," 2,11, 9"," 2,11,10"," 2,11,11"," 2,11,12"," 2,11,13"," 2,11,14"," 2,11,15"
DATA " 2,12, 8"," 2,12, 9"," 2,12,10"," 2,12,11"," 2,12,12"," 2,12,13"," 2,12,14"," 2,12,15"
DATA " 2,13, 8"," 2,13, 9"," 2,13,10"," 2,13,11"," 2,13,12"," 2,13,13"," 2,13,14"," 2,13,15"
DATA " 2,14, 8"," 2,14, 9"," 2,14,10"," 2,14,11"," 2,14,12"," 2,14,13"," 2,14,14"," 2,14,15"
DATA " 0,11, 9"," 0,11,10"," 0,11,11"," 0,11,12"," 0,11,13"," 0,11,14"," 0,11,15"," 0,12, 8"
DATA " 0,12, 9"," 0,12,10"," 0,12,11"," 0,12,12"," 0,12,13"," 0,12,14"," 0,12,15"," 0,13, 8"
DATA " 0,13, 9"," 0,13,10"," 0,13,11"," 0,13,12"," 0,13,13"," 0,13,14"," 0,13,15"," 0,14, 8"
DATA " 0,14, 9"," 0,14,10"," 0,14,11"," 0,14,12"," 0,14,13"," 0,14,14"," 0,14,15"," 0,15, 8"
DATA " 0,15, 9"," 0,15,10"," 0,15,11"," 0,15,12"," 0,15,13"," 0,15,14"," 0,15,15"," 1, 8, 8"
DATA " 1, 8, 9"," 1, 8,10"," 1, 8,11"," 1, 8,12"," 1, 8,13"," 1, 8,14"," 1, 8,15"," 1, 9, 8"
DATA " 1, 9, 9"," 1, 9,10"," 1, 9,11"," 1, 9,12"," 1, 9,13"," 1, 9,14"," 1, 9,15"," 1,10, 8"
DATA " 1,10, 9"," 1,10,10"," 1,10,11"," 1,10,12"," 1,10,13"," 1,10,14"," 1,10,15"," 1,11, 8"
DATA " 1,11, 9"," 1,11,10"," 1,11,11"," 1,11,12"," 1,11,13"," 1,11,14"," 1,11,15"," 1,12, 8"
DATA " 1,12, 9"," 1,12,10"," 1,12,11"," 1,12,12"," 1,12,13"," 1,12,14"," 1,12,15"," 1,13, 8"
DATA " 1,13, 9"," 1,13,10"," 1,13,11"," 1,13,12"," 1,13,13"," 1,13,14"," 1,13,15"," 1,14, 8"
DATA " 1,14, 9"," 1,14,10"," 1,14,11"," 1,14,12"," 1,14,13"," 1,14,14"," 1,14,15"," 1,15, 8"
for B = 0 to 255
read A(B)
next B

getsym

sub getsym
do
Out$ = "EDUPIC DOMINOEX TEST" 'Turn Out$ into ASCII (txtchr)
for t = 1 to len(Out$)
txtchr=Asc(Mid$(Out$, t, 1))
'Use txtchr value to read the arrays
syma = val(LEFT$(mid$(A(txtchr), 1), 2))
symb = val(left$(mid$(A(txtchr), 4), 2))
symc = val(right$(mid$(A(txtchr), 1), 2))
next t
loop

Thanks

Jed
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 10:59am 21 Dec 2014
Copy link to clipboard 
Print this post

There are many ways to achieve what you are after.

With the code you have posted here, I would keep the zero's.
When you call the sub that outputs the tones, only call it if the value is greater than zero for the second and third sym.

do
Out$ = "EDUPIC DOMINOEX TEST" 'Turn Out$ into ASCII (txtchr)
for t = 1 to len(Out$)
txtchr=Asc(Mid$(Out$, t, 1))
'Use txtchr value to read the arrays
syma = val(LEFT$(mid$(A(txtchr), 1), 2))
symb = val(left$(mid$(A(txtchr), 4), 2))
symc = val(right$(mid$(A(txtchr), 1), 2))
maketone syma ' always send this one
if symb > 0 then maketome symb ' only send if not zero
if symc > 0 then maketome symc ' only send if not zero

next t
loop

sub maketone symbol
' do whatever to generate tones
end sub


Not the most efficient code but good enough to get to the next step - making noise.

Jim
VK7JH
MMedit
 
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 82
Posted: 09:44pm 21 Dec 2014
Copy link to clipboard 
Print this post

Thanks TassyJim

If I needed to output the array values directly that would work

I should have mentioned that there is a step in between reading the array and creating the tones I have to do this calculation

Output = (Previous output +2 +value read from array) MOD 18

So the idea was to filter out the zero's
Read the values of syma, symb, symc into an array (don,t know how yet) call it sym

Then out = (out +2 +sym) MOD 18

Am I approaching the whole thing in the wrong way ?




 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025