I am designing counter using vhdl using planahead software, anyway I am using if statment but it gave many errors . the purpose of the counter is to count Ascending/Descending from 1 to 10 and the opposite. In case of Ascending I reset the out when it get to 9 to count again from 0. And in case Descending reset the out when it gets 0 and give 9 as new value . and I am using switch button on the board to switch between Ascending/Descending counting. Below the if statment and the errors . I dont know if I use it on the write form . Plz if anyone have an idea would be perfect.
Line:27- if(inc_dec='1') then
Line:28 if (r_reg=M-1) then
r_next<=(others=>'0')
Line:30 else r_reg+1;
Line: 31 elsif (inc_dec='0')then
Line:32 if (r_reg=M-10) then
r_next<=(others=>'9')
Line:34 else
r_reg-1;
end if;
end if;
end if;
The errors :
Line:27 [HDLCompiler 806] Syntax error near "if".
Line:28[HDLCompiler 806] Syntax error near "then".
Line:30[HDLCompiler 806] Syntax error near "else".
Line:31[HDLCompiler 806] Syntax error near "then".
Line:32[HDLCompiler 806] Syntax error near "then".
Line:34[HDLCompiler 806] Syntax error near "else".
As pointed out by Morten Zilmer, you need to terminate the if/else with an end if. Also there have been some missing semicolons. The code below should work.
if (inc_dec='1') then
if (r_reg=(M-1)) then
r_next <= (others=>'0');
else
r_reg+1;
end if;
elsif (inc_dec='0') then
if (r_reg=(M-10)) then
r_next <= to_unsigned(9, r_next'length);
else
r_reg-1;
end if;
end if;
Update: Jonathan Drolet is right. Changed
r_next <= (others=>'9');
to
r_next <= to_unsigned(9, r_next'length)
in the code
Related
Trying to detect 3 specific EMA crosses, assign them to boolean variable, plot them and set alerts when their conditions are true.
No problem detecting and plotting the 3 crosses when they occur but when I try to set alerts using 'If' statement to check boolean value = true, I get a syntax error at the if statement.
Error is :
Syntax error at input 'end of line without line continuation'
I've tried a thousand different ways to get rid of the syntax error. How am I so stumped on a simple syntax error? Lol I need a fresh set of eyes to look at this for me. Maybe its obvious?
Code:
Continuationema = ta.crossover(ema2_, ema8_)
plotshape(Continuationema, style=shape.triangleup, color=color.new(color.blue, 0), location=location.abovebar)
Bearema = ta.crossunder(ema1_, ema2_)
plotshape(Bearema, style=shape.triangledown, color=color.new(color.red, 0), location=location.abovebar)
Bullema = ta.crossover(ema2_, ema3_)
plotshape(Bullema, style=shape.triangleup, color=color.new(color.green, 0), location=location.belowbar)
// Set Alerts
If Continuationema
strategy.entry("Continuation",strategy.long,alert_message="Uptrend Detected")
alert("Uptrend Continuation Detected. EMA2 Crossing Over EMA8")
*** Syntax error at input 'end of line without line continuation'*** appears at the above 'If' statement
It is you IF statement wich is not well written, you should not use Capital ( If ) but :
if Continuationema == true
Getting the above error but the offending column is not a number. Somehow it is related to the cycle_code column which is a string. My query is hacky since I dont have full control over building it so I have to append another condition at the end ( "!= 'ABC'"). If I remove that condition the query works. I dont understand why im getting an invalid number error though?
select * from my_view WHERE ... CYCLE_CODE IN ( 'XYZ' ) AND CYCLE_CODE != 'ABC';
Hi I am getting an error
'A string is required here'
when trying the following in Crystal 2008:
If {InvPrice.SellingPrice} = 0 then "0" else
({InvPrice.SellingPrice}-ccur({?Pm-Documents/Document/Det
Can someone please give me a clue on how to resolve this?
I resolved it by removing the double quotes:
If {InvPrice.SellingPrice} = 0 then 0 else
({InvPrice.SellingPrice}-ccur({?Pm-Documents/Document/Det
Experimenting with the language I've found that select is defined in the global scope and its precedence is higher than local variables.
def example(select)
puts select
end
example 3
# Syntax error in eval:3: unexpected token: end (expecting when, else or end)
So experimenting with select step by step I get this:
select 1 end
# Syntax error in eval:3: unexpected token: end (expecting when, else or end)
and then
select when 1 end
# Syntax error in eval:1: invalid select when expression: must be an assignment or call
then
select when x = 1 end
# Syntax error in eval:1: invalid select when expression: must be an assignment or call
then
select when x
# Syntax error in eval:1: unexpected token: EOF (expecting ',', ';' or '
I'll skip ahead a few steps as you should have an idea of how I've come to my question…
select when x;
else y
end
# Error in line 1: undefined local variable or method 'x_select_action'
and lastly
x_select_action = 4
select when x;
else y
end
# Error in line 3: undefined method 'x_select_action' (If you declared 'x_select_action' in a suffix if, declare it in a regular if for this to work. If the variable was declared in a macro it's not visible outside it)
So there is this keyword in the language which precedes local variables precedence and I don't know what it's for. But apparently it looks for x_select_action when x is given as a when clause. What is this select for and how is it meant to be used?
Searching online I see select defined on Enumerable, Hash, Channel, and Array… but at first glance these don't seem to be it.
Thanks for the help!
It's similar to Go's select: https://tour.golang.org/concurrency/5
But it still needs some tweaks to be finished, that's why there are no docs about it yet.
What's wrong with this code?
let vm_run vm =
let guard = ref true in
while !guard do
if vm.cur_pc = -1 && not (Stack.empty vm.call_stack) then vm_pop_ar vm
else if vm.cur_pc = -1 then guard := false
else if vm.cur_pc < Array.length vm.cur_code then
execute vm Array.get vm.cur_code vm.cur_pc;
vm.cur_pc <- vm.cur_pc + 1
else vm_pop_ar vm
done
Error is Error: Syntax error related to the last else keyword.
I reached good confidence with OCaml but an if/else chain still gives me some troubles.. that's not the first time (last time I exploited flow to avoid using the else keyword).
I think it's something small but have no clues, according to syntax specification it should be ok
The semicolon has lower precedence than if-else, so when you need to have a block of two or more statements separated by semicolons inside an if, you need to enclose them in parentheses or a begin...end block (the two are equivalent):
else if vm.cur_pc < Array.length vm.cur_code then begin
execute vm Array.get vm.cur_code vm.cur_pc;
vm.cur_pc <- vm.cur_pc + 1
end
else vm_pop_ar vm