Odd Feature Request: base-1 mod operation

Started by jaymzjulian, January 04, 2020, 02:23:45 PM

Previous topic - Next topic

jaymzjulian

This is a weird request, but I actually trip over this a lot.  What I was thinking about is an operator that is mod, but instead of being based at 0, it's based at 1.  This is beacuse, of course, gsbasic arrays start at 1 - so to cycle one, you either have to:

a) have your internal pointer based at 0, and have every access be +1, and remember that, or
b) have code that looks like:

if menu_cursor > Ubound(menu_data)
  menu_cursor = 1
endif

rather than the usual

menu_cursor = (menu_cursor + 1) mod Ubound(menu_data)


I've no idea what one would call such an operator, mind you....

Vectrex32

I'd just write a BASIC function to do it.

- Bob