Author |
Message |
amir20001
|
Posted: Fri May 16, 2008 8:26 pm Post subject: security system program |
|
|
i have started on this but i don't fully understand how the parallelget function works
here is what i have so far any help would be appreciated
code: |
var val1, val2, val3, val4, val5 : boolean
loop
delay (1000)
const val : int := parallelget % Read in the set of pin values
cls
put "Pin 10 is: ", (val div 64) mod 2
get val1
put "Pin 11 is: ", (val div 128) mod 2
get val2
put "Pin 12 is: ", (val div 32) mod 2
get val3
put "Pin 13 is: ", (val div 16) mod 2
get val4
put "Pin 15 is: ", (val div 8) mod 2
get val5
end loop
if val1 := 1 then
parallelput (4)
if val2 := 1 then
parallelput (8)
if val3 := 1 then
parallelput (16)
if val4 := 1 then
parallelput (32)
if val5 := 1 then
parallelput (64)
if val5 := 1 then
parallelput (128)
else
parallelput (0)
end if
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
syntax_error
![](http://compsci.ca/v3/uploads/user_avatars/196798963948cf16794b6e5.jpg)
|
Posted: Fri May 16, 2008 11:41 pm Post subject: Re: security system program |
|
|
amir20001 wrote:
code: |
if val1 := 1 then
parallelput (4)
if val2 := 1 then
parallelput (8)
if val3 := 1 then
parallelput (16)
if val4 := 1 then
parallelput (32)
if val5 := 1 then
parallelput (64)
if val5 := 1 then
parallelput (128)
else
parallelput (0)
end if
|
I am not sure about your parallelget issue but
not 100% sure but I think you should have end if after each if statement |
|
|
|
|
![](images/spacer.gif) |
gitoxa
![](http://compsci.ca/v3/uploads/user_avatars/125344263047f801d546bcb.jpg)
|
Posted: Fri May 16, 2008 11:57 pm Post subject: RE:security system program |
|
|
if val1 = 1 then
as opposed to
if val1 := 1 then |
|
|
|
|
![](images/spacer.gif) |
Nick
![](http://compsci.ca/v3/uploads/user_avatars/19644337547e837b41d67a.png)
|
Posted: Sat May 17, 2008 12:01 am Post subject: RE:security system program |
|
|
err... why are you declaring variables in an if statement, does that even run?
EDIT: also the program will never leave the loop reaching the bottom statements |
|
|
|
|
![](images/spacer.gif) |
Sean
![](http://compsci.ca/v3/uploads/user_avatars/47413941748406f441f83e.png)
|
Posted: Sat May 17, 2008 9:10 am Post subject: Re: security system program |
|
|
Also, change your if statements. You don't need to use new if statments all the time, you can continue an if statment by adding elsif to it. Like so:
|
|
|
|
|
![](images/spacer.gif) |
Nick
![](http://compsci.ca/v3/uploads/user_avatars/19644337547e837b41d67a.png)
|
Posted: Sat May 17, 2008 10:01 am Post subject: RE:security system program |
|
|
also use arrays, that if statement can be a single for loop + if |
|
|
|
|
![](images/spacer.gif) |
amir20001
|
Posted: Sat May 17, 2008 11:21 am Post subject: Re: RE:security system program |
|
|
nick @ Sat May 17, 2008 12:01 am wrote: err... why are you declaring variables in an if statement, does that even run?
EDIT: also the program will never leave the loop reaching the bottom statements
i didn't know u couldn't do that, and it dose not run thx for ur help |
|
|
|
|
![](images/spacer.gif) |
amir20001
|
Posted: Sat May 17, 2008 11:27 am Post subject: Re: security system program |
|
|
thx a lot every one i got it working ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|