Re: IsValid(Object)

From: David Frauzel (net.weathersongATnemo)
Date: 01/07/04


Date: 7 Jan 2004 14:45:09 -0700

kbarthelmess@compuserve.com (Kurt Barthelmess (TeamB)) wrote in
news:3ffc839e.16042718@newsgroups.borland.com:

> You have a serious problem.
It's a scripting language that I'm building, to interact with this
"database", so I guess in a sense I've encountered a situation where the
script needs to raise an exception without the application itself raising
an exception - building exception handling into the script language is
another way to resolve it, I suppose, but it's no more a serious problem
than exists in actual programming languages where the same kind of thing
can happen: then it's not really a problem with the programming language,
but a problem with the program. :D

> Only that won't be reliable. The memory previously occupied by
> FGffContext (before it got Free'd) is still physically present and
> Free'ing something does not erase or zero it out. Its content is
> undefined and it might actually contain something that looks like (but
> is not) the sibling, another sibling, or ....
Ah, good point. I've had the nagging feeling that try..except isn't
really the way to handle unknown conditions, anyhow.

> Is it the case that if FGffContext had a sibling (before it got
> zapped) that the sibling is guaranteed to still exist after all your
> tweaking? If so, you could grab and save that field before you start
> tweaking. After tweaking, test the saved reference instead of going
> back to FGffContext.
Nope, I can't assume anything. During the loop, any number of arbitrary
scripting commands could have executed. For all I know, the entire
database might have been wiped.

> Otherwise you'll have to restart your looping from the top of the tree
> after every tweaking operation. Or redesign the logic in some way to
> ensure that you don't delete stuff out from under yourself. Perhaps
> you could start at the end of the chain and work backwards to the
> beginning?
Determining if I've deleted stuff out from under myself is the one that
has the matrix problem, so I'm saving it for a last resort. I have to
work in a strict order because it's a series of scripting commands. (The
scripting syntax is also XML-like, so commands can be nested inside of
commands: so it executes left to right, top to bottom.)

As an interim solution, I realized I could just save the "path" to the
field in another variable, and then use a database lookup to see if the
field named still exists; though this only works in my case specifically
because of the db-like nature of the app, and because I had already built
those functions (one to get the stringified path of a field, and one to
look up a field given this kind of string).

Looping := AGff.Find(Path).IsValid;
if not Looping then Exit;
// Now we can assume FGffContext is still valid
FGffContext := FGffContext.GetNextSibling;
Looping := Assigned(FGffContext);

Unfortunately, this solution technically suffers from the same problem,
because I don't know if AGff (the TGffFile) is still valid! I have
support for file handles in the scripting language, and there are
commands to open and close files, of course.

So, I have to cascade the solution, and determine whether AGff is still
valid by temporarily saving the name of its handle, and then checking if
it's still on the global list of open handles... :p

Well, I feel better about that than try..except, anyhow.



Relevant Pages

  • Re: Difficulties in deriving a truly universal GUI Scripting Language
    ... It depends on what the purpose of the scripting language is. ... This would be left as a problem for the script programmer. ... the caret ...
    (microsoft.public.vc.mfc)
  • Re: Difficulties in deriving a truly universal GUI Scripting Language
    ... that the ordinary scripting languages have never had to handle, ... "Universal GUI Scripting Language" suggests that there will be ways to ... This would be left as a problem for the script programmer. ... the caret ...
    (microsoft.public.vc.mfc)
  • Re: Difficulties in deriving a truly universal GUI Scripting Language
    ... problems that any scripting language would also face. ... "Universal GUI Scripting Language" suggests that there will be ways to ... This would be left as a problem for the script programmer. ... the caret ...
    (microsoft.public.vc.mfc)
  • Re: Difficulties in deriving a truly universal GUI Scripting Language
    ... "Universal GUI Scripting Language" suggests that there will be ways to ... This would be left as a problem for the script programmer. ... interpretation, but yes, it *is* possible, although unlikely, the caret ...
    (microsoft.public.vc.mfc)
  • Re: Automated shutdown
    ... Basically SyzCmdz does what the big ticket automation products from the ... The SyzCmdz utility is designed to provide the "authorized" user with the ... CICS, DB/2, or Unix System Services commands from within a batch job ... SyzCmdz is not simply a "dumb" scripting facility for issuing commands, ...
    (bit.listserv.ibm-main)