Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why aren't these subroutines working on user defined types?
#5
This the obvious sample of code for what you are doing:

Code: (Select All)
Type score_type
  max As Integer
  cur As Integer
End Type

Type player_type
  power As score_type
  speed As score_type
  x As Integer
  y As Integer
End Type

Dim player As player_type

player.power.max = 100
player.power.cur = 0
player.x = 100
player.y = 100

A = 10
incr A, 1
Print A

incr player.power.cur, 1
Print player.power.cur

incr player.x, 1
Print player.x
End

Sub incr (n As Integer, v)
  n = n + v
End Sub

Sub decr (n As Integer, v)
  n = n - v
End Sub

Sub multiply (n As Integer, v)
  n = n * v
End Sub

Sub divide (n As Integer, v)
  n = n / v
End Sub

Sub power (n As Integer, v)
  n = n ^ v
End Sub
Reply


Messages In This Thread
RE: Why aren't these subroutines working on user defined types? - by eoredson - 11-12-2023, 05:41 AM



Users browsing this thread: 3 Guest(s)