'boolstack structure used for conditionals
Private Type boolstack
val(20) As Boolean
pos As Integer
End Type
Private Const stacklim As Integer = 20
Dim currgene As Long 'for *.thisgene
Dim Condst As boolstack 'for the conditions stack
'/*********I had to gess this
Private Type stackishere
pos As Double
val(255) As Double
End Type
Private Type therobotsarehere
st As stackishere
End Type
Dim rob(20) As therobotsarehere
'\**************
Private Sub DNASgn(robotnumber As Integer) 'returns sign of number on stack
Dim a As Integer
a = readst(robotnumber)
writest robotnumber, Sgn(a)
End Sub
Private Function readst(n As Integer) As Integer
readst = 0
If rob(n).st.pos > 0 Then
readst = rob(n).st.val(rob(n).st.pos)
rob(n).st.pos = rob(n).st.pos - 1
End If
End Function
' stack push
Private Sub writest(n As Integer, val)
If Abs(val) > 32000 Then val = Sgn(val) * 32000
If rob(n).st.pos < stacklim Then
rob(n).st.pos = rob(n).st.pos + 1
rob(n).st.val(rob(n).st.pos) = val
End If
End Sub
Private Sub Form_Load()
writest 0, 700
DNASgn 0
MsgBox rob(0).st.val(rob(n).st.pos) ' returns 1
'
writest 0, 0
DNASgn 0
MsgBox rob(0).st.val(rob(n).st.pos) ' returns 0
'
writest 0, -700
DNASgn 0
MsgBox rob(0).st.val(rob(n).st.pos) ' returns -1
End Sub
'Even In your own code It returns 0 for 0, rofl , now what?