RotaryRead(<variable>, <variable>, ...)
RotaryRead(<variable>, <variable>, ...)
A more compact and more functional Read...Data in one statement.
Example:
Repeat
Debug RotaryRead(348, 24, 25, 1024)
Forever
Outputs:
348
24
25
1024
348
...
Example:
Repeat
Debug RotaryRead(348, 24, 25, 1024)
Forever
Outputs:
348
24
25
1024
348
...
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: RotaryRead(<variable>, <variable>, ...)
In my case (I code retro games) It would certainly make my code more more compact and more readable.
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: RotaryRead(<variable>, <variable>, ...)
but it is nothing you could not easily put into a selfcoded function...
and I wonder what should it be good for, really.
Oldskool Games are my passion and profession, and I don't see the real use at first glance.
and I wonder what should it be good for, really.
Oldskool Games are my passion and profession, and I don't see the real use at first glance.
oh... and have a nice day.
Re: RotaryRead(<variable>, <variable>, ...)
Tried to code it in a macro and in a function but it didn't work out. (I'm not a pro coder though). You could use it for example to do animations or to do little sequences or movements in games with less code.
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: RotaryRead(<variable>, <variable>, ...)
for such things you would use an Array...
Code: Select all
#LastFrame = 3
Define n.l
Dim Phase.l(#LastFrame)
Restore PhaseTable
For n=0 To #LastFrame
Read.l Phase(n)
Next
Define counter.l = 0
Define GlobalCounter.l = 0
Repeat
Debug Phase(counter)
counter +1
If counter > #LastFrame
counter = 0
EndIf
GlobalCounter +1
Until GlobalCounter > 23
End
DataSection
PhaseTable:
Data.l 348, 24, 25, 1024
EndDataSection
oh... and have a nice day.
Re: RotaryRead(<variable>, <variable>, ...)
Thanks for the example. It makes my point (more compact, more readable code) very clear I think. 

- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: RotaryRead(<variable>, <variable>, ...)
well, honestly I think it rather makes clear that you don't need such.
an Array with a counter is such a common thing, it's really really redable and very flexible.
your "RotaryRead" maybe halfways readable, but it's not really flexible.
e.g. when you create your sprites for the animation with #PB_Any, you would need an Array to store the IDs anyways.
... what is easier then, using the array with a counter or passing every single element to your function?
what if the number of frames change?
a function with hardcodes arguments could never cope with that.
for an Array, you would just use a variable for "LastFrame", and be able to alter it any way you like.
honestly, your function is really exotic, I never seen anything like that.
don't count on your function to be implemented.
an Array with a counter is such a common thing, it's really really redable and very flexible.
your "RotaryRead" maybe halfways readable, but it's not really flexible.
e.g. when you create your sprites for the animation with #PB_Any, you would need an Array to store the IDs anyways.
... what is easier then, using the array with a counter or passing every single element to your function?
what if the number of frames change?
a function with hardcodes arguments could never cope with that.
for an Array, you would just use a variable for "LastFrame", and be able to alter it any way you like.
honestly, your function is really exotic, I never seen anything like that.
don't count on your function to be implemented.
oh... and have a nice day.
- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: RotaryRead(<variable>, <variable>, ...)
Hm,
even it is more readable, it won't be used by many programmers, I believe...
I have also some wishes about adding functions to PB (mostly integer math functions) to reduce the diversity of codes for the same thing etc. But everything not being implemented can easily be done by you own code, as Kaeru Gaman already wrote – and you can encapsulate these things into procedures as well, so the calling code would be easy enough to read
even it is more readable, it won't be used by many programmers, I believe...
I have also some wishes about adding functions to PB (mostly integer math functions) to reduce the diversity of codes for the same thing etc. But everything not being implemented can easily be done by you own code, as Kaeru Gaman already wrote – and you can encapsulate these things into procedures as well, so the calling code would be easy enough to read

Code: Select all
#BufferSize=4
Global Dim Buffer(#BufferSize)
Global BufferPointer=-1
i=0
While i<#BufferSize
Read Buffer(i)
i+1
Wend
DataSection
Data.l 348, 24, 25, 1024
EndDataSection
Procedure.l RotaryRead()
BufferPointer+1
ProcedureReturn Buffer(BufferPointer%#BufferSize)
EndProcedure
For i=0 To 9
Debug RotaryRead()
Next i