Inc(crement) and Dec(crement) User Subs

Place code snippets and demo code here
Post Reply
User avatar
Electroguard
Posts: 273
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 55 times
Been thanked: 129 times

Inc(crement) and Dec(crement) User Subs

Post by Electroguard »

This simple pair of user subs avoids the need to keep repeating the variable names twice each time they are incremented or decremented.
Usage is INC variable_name (instead of variable_name = variable_name + 1) and DEC variable_name

Code: [Local Link Removed for Guests]

sub inc( it )
it = it + 1
end sub

sub dec( it )
it = it - 1
end sub
I've not had any reserved words conflict with Annex32 1.43.5 but it's easy enough to slightly rename them to eg: incR and decR if preferred.
Post Reply