Re: converting program variables to arrays



Shirley Cohen wrote:
Hi Java Experts,

I'm trying to take an existing application and add some custom labels
to the program variables. Specifically, I want to change every scalar
variable to an array type such that I can store the value of the
variable at index 0 of the array and store some label at index 1 of
the array. Rather than manually change every variable one line at a
time, can anyone suggest a more efficient way of doing this?

I agree with Roedy's replacement edit. Of course, to do that you need to use an editor capable of handling regular expressions (vi, microemacs or emacs would all do, or [in extremis] write a program in perl, awk or even Java).

However, you'd get better advice if you tell us why you need to do this and what you hope to achieve by doing it rather than simply saying how one possible solution might work.

I agree with another Manish: declaring a class rather than using an array would probably be a much better solution. For starters it gets round the obvious problem that a simple array won't hold an int as [0] and a string label as [1].


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
.



Relevant Pages

  • Re: Adding events to Run time created controls
    ... I added this to some test code and it worked ... label to see which matchs with the mouse position. ... >>which one of the labels in the array was clicked upon. ... > Sender or put the appropriate array index in the Tag of each label. ...
    (alt.comp.lang.borland-delphi)
  • Re: Help sorting an array
    ... thank you very much for the replies. ... In the mean time I have managed to hack together a small function to do ... calendar) into an array, and using that array to create widgets in a ... The month names serve as the title of a label and out of the ...
    (comp.lang.ruby)
  • Re: discover array offsets within initializer?
    ... and have subsequent mentions of that label name ... be automatically replaced by the offset within the array ... have a set of enums corresponding to array indices. ... an X-macro version rather than multiple inclusion. ...
    (comp.lang.c)
  • Re: Help sorting an array
    ... thank you very much for the replies. ... In the mean time I have managed to hack together a small function to do ... calendar) into an array, and using that array to create widgets in a ... The month names serve as the title of a label and out of the ...
    (comp.lang.ruby)