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

Forum for discussion about the Windows IDE of Hollywood

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

Postby Bugala » Sun Jul 16, 2017 8:57 am

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.
Bugala
 
Posts: 645
Joined: Sun Feb 14, 2010 8:11 pm

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

Postby SamuraiCrow » Mon Jul 17, 2017 6:00 pm

Personally, I'd prefer an actual enumeration function.
SamuraiCrow
 
Posts: 105
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

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

Postby Bugala » Mon Jul 17, 2017 10:36 pm

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.
Bugala
 
Posts: 645
Joined: Sun Feb 14, 2010 8:11 pm

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

Postby SamuraiCrow » Tue Jul 18, 2017 7:46 am

I would expect all the enumerations to be prefixed with a # symbol since they are constants.
SamuraiCrow
 
Posts: 105
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

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

Postby SamuraiCrow » Tue Jul 18, 2017 4:03 pm

@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.
SamuraiCrow
 
Posts: 105
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA


Return to Windows IDE

Who is online

Users browsing this forum: No registered users and 1 guest