nested if statements in pascal fuck me up

  • Thread starter Thread starter Deleted User
  • Start date Start date
  • Views Views 963
  • Replies Replies 2
D

Deleted User

Guest
I've been working on a task for uni and decided to try using a nested if statement rather than a case statement. But I've now learned that each time I try a nested if statement I get either a logic error or a syntax error.

if intX > 5000 then
begin
if intX > 10000 then //do something
else //do something else
end

I've tried as many variations on this code that I can think of and they either won't compile or they execute //do something else when intX is less than 5000.

I'm probably missing something obvious here.
 
I've been working on a task for uni and decided to try using a nested if statement rather than a case statement. But I've now learned that each time I try a nested if statement I get either a logic error or a syntax error.



I've tried as many variations on this code that I can think of and they either won't compile or they execute //do something else when intX is less than 5000.

I'm probably missing something obvious here.
Adding a begin/end to the inside statement should prevent that.
 

Site & Scene News

Popular threads in this forum