So I copied PRG into my project added lib and retain variable, And I get an error that RTS_IEC_RESULT is unknown type, but is declared like:
PROGRAMAppRetainVAR
  fbDelete      :FILE.Delete;(* Function block to delete the file *)
  (* The retain file <application-name>.ret is placed in the directory of the bootproject *)
  sFileName     :STRING:='App1.ret';
  pApp      :POINTERTOAPPLICATION;
  Result        :RTS_IEC_RESULT;(* Result code *)
  xInit      :BOOL;END_VAR
Code:
(*Theretainvariablesarestoresinafileandgetretrievedafterwards.*)IFNOTxInitTHEN    (*Firstdeletetheretainfile.    Thisisnecessary,becausethefunctionAppStoreRetainsInFileappendsthedataattheendofthefile.*)  fbDelete(xExecute:=TRUE,sFileName:=sFileName);  IFfbDelete.xDoneOR(fbDelete.xErrorANDfbDelete.eError=FILE.ERROR.NOT_EXIST)THEN    (*Attention:IttakesatleastonecycleuntilxDoneisTRUE*)    fbDelete(xExecute:=FALSE);    xInit:=TRUE;    (*Now,it's the time to save the retains. *)    pApp:=AppGetCurrent(pResult:=ADR(Result));    IFpApp<>0THEN      (*Storethevariablesinafile*)      Result:=AppStoreRetainsInFile(pApp,sFileName);    END_IF  END_IFEND_IF(*RestoretheRetainVariablesfromthefile.  Forstoringandrestoring,thesamepointertoapplication(pApp)mustbeused.*)Result:=AppRestoreRetainsFromFile(pApp,sFileName);
I have no Idea how to declare it other way??? Any Ideas?
regards,
Alex
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm trying to implement retrieving Retain variables from File, using lib cmpApp. I found a sample in Codesys Store:
http://store.codesys.com/application-manager.html
So I copied PRG into my project added lib and retain variable, And I get an error that RTS_IEC_RESULT is unknown type, but is declared like:
Code:
I have no Idea how to declare it other way??? Any Ideas?
regards,
Alex
With newer library versions it is required (and also better for older versions) to use the namespace to define which RTS_IEC_RESULT you want to use.
In this case you need to define the variable as:
Result : CmpApp.RTS_IEC_RESULT;
Thank you TimvH didn't know that, Build OK, now testing.
regards,
Alex