Changing Parameter Types

Parameter types can be changed by deleting and adding a new parameter. To migrate from the old value a post-load callback must be used. The old parameter ids will be used until after the load and all post-load callbacks are completed

The following example demonstrates how you might do this:

IParamBlock* pBlock;

class TestClassPLCB
  : public  PostLoadCallback
{
  TestClass* parent;

public:

  TestClassPLCB( TestClass* p )
    : parent(p) { }

  voidproc(ILoad *iload)  {
    parent->PostLoadCallback(iload);
    delete this;
  }
};

void TestClass::PostLoadCallback( ILoad* iload )
{
  IParamBlock2PostLoadInfo* postLoadInfo = (IParamBlock2PostLoadInfo*)
    pblock->GetInterface( IPARAMBLOCK2POSTLOADINFO_ID );

  // Check for specific obsolete version
  if(postLoadInfo!=NULL && postLoadInfo->GetVersion()==OBSOLETE_VERSION)
  {
    // get the original value
    BOOL onOff = pblock->GetInt(pb_onOff_OBSOLETE, 0, 0);

    //set the original value
    pblock->SetValue( pb_onOff, 0, onOff );

    // see if it has a controller
    Control* onOffCtrl=pblock->GetController(pb_onOff_OBSOLETE,0);

    // if a controller exists add it to the new parameter
    if( onOffCtrl )
      pblock->SetController(pblock->IDtoIndex(pb_onOff),0,onOffCtrl);

    // NOTE: not necessary to set obsolete params to NULL,
    // or unlink controllers/references
  }
}