Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!udel!haven!adm!news From: C0361@univscvm.csd.scarolina.edu ( Thomas Jenkins) Newsgroups: comp.lang.pascal Subject: Weird error - Help Message-ID: <26221@adm.brl.mil> Date: 8 Mar 91 16:28:37 GMT Sender: news@adm.brl.mil Lines: 61 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." | +-------------------------------+