Forum Discussion

gambo's avatar
gambo
New Contributor
14 years ago

Object Name Changes with Each Run of the Application

This has got to be a common problem.  I'm running TC 7.10.xxx  on a VB application utilizing MDI forms. 


The problem form is a modal form that is registered in the NameMapping table as "frmFind_V3_2".


Every time I instantiate the form the _2 is incremented.  I know this by using the Object Inspector and looking at the form properties. 


If I execute the following code: 


    set frmFind = Aliases.Meditrac.frmFind_V3_2

   

    if frmFind.Exists Then

      Log.Message("frmFind EXISTS --> " & frmFind.fullname)

      Log.Message("frmFind EXISTS --> " & frmFind.name)

      Else

      Log.Message("frmFind DOES NOT EXIST")

    End if


The Log shows:


Type Message Time Link

The menu item 'Accounting|Brokers' was clicked. 16:56:34 

Toolbar button 3 was clicked. 16:56:34 

frmFind EXISTS --> Sys.Process("Meditrac").VBObject("frmFind_V3_25") 16:56:35 

frmFind EXISTS --> VBObject("frmFind_V3_25") 16:56:35 

 


As you can see the [Name] and [FullName] properties of the object indicate _25 unfortunately the object inspector show the index at a number greater than 25.  In this case frmFind_V3_27.


If I execute a command like:  frmFind.Close 


TC times out and indicates the form is not visible. 


If I hard code in the following: 


Meditrac.frmFind_V3_28.Close 


where the _28 represents the next index (meaning the object inspector showed the form at _27).  The command executes as expected and closes the form. 


I've been working on this way too many hours and could use a new direction. 


Thanks,

Rudy

2 Replies

  • Hi Rudy,



    You need to use wildcards in this case. Modify the problematic object's recognition parameters in the Name Mapping editor - find the property whose value changes and replace its variable part with a wildcard (* or ?). For example, "frmFind_V3_*".
  • gambo's avatar
    gambo
    New Contributor
    Jared,

    That got me closer but it only worked once. 



    I needed to add a NameMapping refresh.




    NameMapping.Sys.Meditrac.frmFind_V3_2.RefreshMappingInfo



    It now works every time. 



    Thanks