Writing a simple function - Help!
Posted: 03 June 2010, 12:36 PM
I'm trying to write a very simple function and I'm struggling. All I want to create is a function that returns a single bit when called. I'm coming from a PBASIC world so I'm using the example in the conversion document as a basis for writing some simple functions. Here's where I am:
For whatever reason I'm getting this error:
"Simple Function.bas:11: Error: assignment type conflict; left:Bit, right:Byte"
I can't get my head around this. . .ReadInput should be a bit, and the output from GetBit should be a bit. . .??? So why this error?
I know this is an extremely elementary concept for most everyone, but I'm really having problems with this. Any help would be appreciated. Thanks!
-Jeff
Code: Select all
Private Const Input_Clock as Byte = 7 ' clock pin
Private Const Input_Data as Byte = 10 ' data pin
Private Const Input_Load as Byte = 6 ' load pin
Function ReadInput(ByVal value as Bit) as Bit
Call PutPin(Input_Load, zxOutputHigh)
Call PutPin(Input_Clock, zxOutputLow)
Call PulseOut(Input_Load, 5, 0)
Dim InputByte as Byte
InputByte = ShiftIn(Input_Data, Input_Clock, 8)
ReadInput = GetBit(InputByte, value)
End Function
Sub Main()
Dim RoofOpenState as Bit
Dim RoofOpen as Bit = 1
RoofOpenState = ReadInput(RoofOpen)
End Sub
"Simple Function.bas:11: Error: assignment type conflict; left:Bit, right:Byte"
I can't get my head around this. . .ReadInput should be a bit, and the output from GetBit should be a bit. . .??? So why this error?
I know this is an extremely elementary concept for most everyone, but I'm really having problems with this. Any help would be appreciated. Thanks!
-Jeff