Re: How do I use a parameter/variable/string literal as an identifier?

From: Michael Szuchy (szuchymj_at_jmu.edu)
Date: 04/28/04


Date: 28 Apr 2004 12:34:00 -0700

The exact problem that I am having is this: I am working with sort of
a grid of text boxes. Not an actual grid, just a bunch of text boxes
arranged in a grid. I want to be able to detect if the user has
pressed a key in one of the boxes. In the onkeypress event I set the
corresponding member of a boolean array (there is one array for each
column) to true. I had a seperate onchange event for each column,
because I didn't know of a way to call up the name of a certain
boolean array, depending on what column I was in. I.E. there are 8
boolean arrays, named bool_a, bool_b, etc. There are 10 rows of text
boxes. When a key was pressed in row 2, column b, for instance,
column_b_keypress would be called, and bool_b[2] (I used one based
arrays) would be set to true. The problem came when I tried to combine
all the keypress events for each column into one. How would I call the
proper array? As before I wished for something like
(findvariable('bool_' + columnletter))[rownumber], and came up empty
handed.

After making my previous post I realized that a multi-dimensional
array would be perfectly suited for this task. I'm guessing there are
plenty of other alternative ways to solve this problem as well...and
furthermore that there is nothing that could be done with a
hypothetical findvariable function that couldn't also be done without
one. But sometimes I just wish I had this as an option, even at severe
cost to performance. It would help prototyping move a lot faster, at
least until I am able to think up a better solution to the problem or
learn more about delphi.

I would appreciate any further details on the wimp's method using
tstringlist.

Thanks.
 

>
> >> "Michael Szuchy" <szuchymj@jmu.edu> wrote in message
> >> news:2625ef3d.0403302139.5511c46a@posting.google.com...
> >>
> >> > Thanks for your help. I had come across the FindComponent method
> >> > earlier, but was still wondering if there was a more general purpose
> >> > method that could be used for all identifiers, rather than components
> >> > only. But now that I think about it, FindComponent will probably do
> >> > the job just fine in all but a few cases, even if it isn't exactly
> >> > what I wanted.
> >>
> >> FindComponent _shouldn't_ be exactly what you wanted. Usually when
> >> you have to retrieve variables by name, you've chosen a wrong solution
> >> to your problem somewhere. What is it you're trying to do? There is
> >> probably a better solution that we might just be willing to let you
> >> have - at no extra charge.
>
> > Again I have run across this problem in a different situation. The
> > specifics aren't important...just that I keep wishing that I could
> > have sort of a findcomponent method, but for all variables/identifiers
> > rather than only components. I know there are probably alternate
> > solutions to my problems, but I would rather learn a new language
> > where it is possible to do this. Does one exist? Is it theoretically
> > possible even? I thought I read about this being doable in C++, but
> > I'm not sure.
>
> It could be done in theory, if there is debugging info, and no/few
> optimizations. I did it for FPC as proof of concept once, for limited
> things and only one level deep (mainly to try to find out if DLLs under
> DOS could be implemented in such a way)
>
> It doesn't matter if it is C++ or Object Pascal, the languages are similar,
> it's what the compiler provides that makes it different.
>
> It think it would be difficult for Delphi, since you can't get Delphi to
> be dumb enough to stop optimizing all together. Moreover you don't really
> want to know how much work this is (for any language/compiler), and the
> performance hit would slow it down to be slower than VB probably when used
> a lot.
>
> Despite that it can be done in theory, I stand by earlier posters that
> the fact you want to do this hints at either unfamilarity with compiled
> languages or some design mistake.
>
> You are mistaking what you want to do with a solution. Getting identifiers
> runtime by name is a solution, not the problem. So the specifics _are_
> important.



Relevant Pages

  • Re: making a monthly calendar...
    ... > return boxes ... the each_slice part (you do want one big array right?). ... month as the offset. ... google calendar uses a 7 x 7 grid. ...
    (comp.lang.ruby)
  • Re: MDI child with an "always on top" dialog
    ... If Not privBut Is Nothing Then ... tell you that each button exposes a part of a big array. ... I need to display the array's pieces thruough a grid of text boxes on ...
    (microsoft.public.vb.controls)
  • Re: error 3048 - Cannot open any more databases
    ... recommendations and I declared my array as static and also loaded the array ... Yes the bound column of my combo boxes are not the display column. ... the same subform, just inserted 48 times. ...
    (microsoft.public.access.formscoding)
  • Re: error 3048 - Cannot open any more databases
    ... I am having a hard time creating a multidimensional array. ... Yes the bound column of my combo boxes are not the display column. ... the same subform, just inserted 48 times. ...
    (microsoft.public.access.formscoding)
  • Re: How to fire an event
    ... The other page does the checking of the boxes in a javascript, ... Well it could be a bug in the grid, ... you want to raise the UpdateRowBatch event. ... You might want to check out some Infragistics forums and documentation ...
    (microsoft.public.dotnet.languages.csharp)