[comp.lang.pascal] Weird error - Help

C0361@univscvm.csd.scarolina.edu ( Thomas Jenkins) (03/09/91)

Hi,

  I'm working on a TV application.  In this application there is a customer
object that amoung other things has a name field accessed only through
four methods - Init, GetName, ChangeName, and Load.  These objects
are stored in a TCollection.  I've written several procedures to work with
the collection.  By writing a standard program to test the UNIT these
PROCEDUREs are declarded in, I've determined they work very well.
  Now the error.  When I use these procedures from my TV structure, the
FindCust procedure never finds the customer I select.  By outputing the info
inside the program, I know the values are correct.  When I check the procedure
during testing, I found a weird error inside the FindCust procedure :

 FUNCTION    FindCust ( VAR c                    : PCollection ;
                            aName                : TNameStr )
                                                 : PCustomer ;

  FUNCTION    NameMatch ( VAR p                  : PCustomer )
                                                 : BOOLEAN ;
                                                 FAR ;     {  Required - see }
                                                           {  TCollection    }

    BEGIN  {  NameMatch  }

      NameMatch := ( Pos ( aName , p^.GetName ) <> 0 ) ;

      END ;  {  NameMatch  }

   BEGIN  {  FindCust  }

     FindCust := c^.FirstThat ( @NameMatch ) ;

     END ;  {  FindCust  }



As you can see, there is very little here to go wrong.  Also as I said, the
test program was able to find any customer name I inserted.  I thought it
might be my insert until I decided to use the debugger to check the values
passed to this procedure.  Upon entering the FindCust FUNCTION, aName was
the name I passed into the FUNCTION.  When I enter the NameMatch FUNCTION,
aName was replaced by the message 'unable to access this symbol'!!  Since
aName is global in FindCust, why can't the local FUNCTION NameMatch see it?

I traced through this code in the standard application ( IE, command line
test program ) and it works fine!  Go figure.


Any suggestions as to why?

a fustrated,

tom

THOMAS E. JENKINS, JR.                +--------+  FROM SHOE  +--------+
                                      |"IS THE COMPUTER STILL GIVING  |
PROGRAMMER,                           | YOU TROUBLE?..."              |
  UNIVERSITY OF SOUTH CAROLINA        |"NO, NOT ANYMORE..."           |
  C0361 AT UNIVSCVM.BITNET            |"WHAT DID YOU DO?..."          |
  C0361 AT UNIVSCVM.CSD.SCAROLINA.EDU |" I TURNED IT OFF."            |
                                      +-------------------------------+