(* 何如使用 ⇘ CAA_FILE.library示例 - 根路径或者路径功能块 *)
PROGRAM ROOT_PRG
VAR
xRootInit: BOOL := FALSE;
uiRootState: UINT := 0;
sStandarddir: CAA.FILENAME:='C:/PLC_DIR';
sDirName: CAA.FILENAME;
filsrt: FILE.SetRoot;
filgrt: FILE.GetRoot;
END_VAR
IF NOT xRootInit THEN
filsrt(xExecute:=FALSE);
filgrt(xExecute:=FALSE);
xRootInit:=TRUE;
uiRootState:=0;
ELSE
CASE uiRootState OF
0: (* read root directory *)
filgrt( xExecute:=TRUE);
IF filgrt.xDone THEN
sDirName:=filgrt.sFileName;
uiRootState:=1;
END_IF
IF filgrt.xError THEN
(* error handling*)
;
END_IF
1:(* compare root directory *)
IF sDirName <> sStandarddir THEN
uiRootState:=2; (* set the new root *)
ELSE
uiRootState:=3; (* standard root directory already is set *)
END_IF
2:(* set new root directory *)
filsrt.sFileName:=sStandarddir;
filsrt( xExecute:=TRUE);
IF filsrt.xDone THEN
uiRootState:=3;
END_IF
IF filsrt.xError THEN
(* error handling*)
;
END_IF
3: (* end of example*)
;
END_CASE
END_IF