(wish) Replace with each replace x=x+1

Forum for discussion about the Windows IDE of Hollywood
Post Reply
Bugala
Posts: 915
Joined: Sun Feb 14, 2010 7:11 pm

(wish) Replace with each replace x=x+1

Post by Bugala »

When using "replace" option in Windows IDE, I notice that it is quite usual that I am replacing something where there is number included in the replacement and then it is supposed to rise by one each time.

as example i might have:

Code: Select all

gfx["itemname1"] = 1
after which i copy paste this same line several times:

Code: Select all

gfx["itemname1"] = 1
gfx["itemname1"] = 1
gfx["itemname1"] = 1
gfx["itemname1"] = 1
gfx["itemname1"] = 1
after which i change the real names and numbers to it:

Code: Select all

["itemname1"] = 1
gfx["itemnama"] = 2
gfx["itemnamo"] = 3
gfx["itemnameas"] = 4
gfx["itemn"] = 5
It isnt that much trouble changing those numbers afterwards manually, but I was wondering how difficult would it be to make "replace" function in such way that you could determine that one of the things to be replaced is a number that rises by 1 after each click.

SamuraiCrow
Posts: 299
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: (wish) Replace with each replace x=x+1

Post by SamuraiCrow »

Personally, I'd prefer an actual enumeration function.
I'm on registered MorphOS using FlowStudio.

Bugala
Posts: 915
Joined: Sun Feb 14, 2010 7:11 pm

Re: (wish) Replace with each replace x=x+1

Post by Bugala »

Im always worried of colliding with some reserved word in future when using enumerations.

Also, Tables can give some other benefits too in some more unusual cases. Like say i dont want to keep all the gfx in memory all the time but load them when needed, in this case I could remove some items from table and that way avoid them being referred to anymore. You can of course do the same with enumeration, but then it requires you to having table of which ones are available to use and which not, in which case you are anyway going to be making a table, so why not just make one right from beginning.

But especially when there are only very few graphics involved in program, enumerations is definetily the way to go.

SamuraiCrow
Posts: 299
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: (wish) Replace with each replace x=x+1

Post by SamuraiCrow »

I would expect all the enumerations to be prefixed with a # symbol since they are constants.
I'm on registered MorphOS using FlowStudio.

SamuraiCrow
Posts: 299
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: (wish) Replace with each replace x=x+1

Post by SamuraiCrow »

@include enum.hws from here to add an enum class. Warning it's untested at this point but has in-code documentation and an equally untested unit test method.
I'm on registered MorphOS using FlowStudio.

Post Reply