Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

code deletion

Mar 31, 2007 8:31AM PDT

I know it exists but im not sure if MSVS supports code deletion at run time. I wanted to run an if statement for 3 event instances, but delete the if statement after that. Anyone else know if MSVS has this? that would really improve the run time.

Discussion is locked

- Collapse -
Many ways to solve this one.
Apr 2, 2007 12:09AM PDT

Idea 1. When we install the application we create 3 files. Since I use humor in my software to liven it up I'll call these the 3 piggies. Now that we have piggy1.tmp piggy2.tmp and piggy3.tmp we add code in our startup such as

if exist(file(piggy1.tmp){ firsttime(); delete('piggy1.tmp'); break;}
if exist(file(piggy2.tmp){ firsttime(); delete('piggy2.tmp'); break;}
if exist(file(piggy3.tmp){ firsttime(); delete('piggy3.tmp'); break;}

And this would be rewritten to operate properly. I only offer non-operational code to get the concept here.

Idea 2. A registry entry is made and it's incremented on start up. Once it hits your number then the value is not incremented and you don't run your code segment.

Bob

- Collapse -
increased run time
Apr 3, 2007 3:45AM PDT

that doesnt seem like it would speed up the run time if there is still a check being done at the registry level. the code is still being checked for its existance and really is just adding another if statement for another check...but that delete command might work for deleteing a certain line(s) of code.

- Collapse -
How many milliseconds did this add to the startup?
Apr 3, 2007 3:54AM PDT

I timed it and it seems less than 10 milliseconds. Is this critical?

Bob

- Collapse -
Then find a faster global data structure ...
Apr 3, 2007 6:49AM PDT

then the Windows registry. Possibly another object that keeps the count. OO systems should have rather fast inter-object communication.


Kees