Библиотека полезных скриптов

Замена строк в значениях параметров во всех dmf-файлах в указанной папке

$SearchText=@Dialog.Ask Введите текст для поиска
$STL=@Calc Length(“$SearchText”)
@if $STL=0 then @Break Введите непустой текст
$ReplaceText=@Dialog.Ask Введите текст для замены
$Path=@Dialog.Ask Путь к папке Default=С:\Digitals
@Text[0].FolderListTree *.dmf $Path
$MapCount=@Text[0].Count
@if $MapCount=0 then @Break Файл(ы) не найдены
$FileNumber=0
%LoopEachFile
$FileNumber=$FileNumber+1
$MapFileName=@Text[0].Line[$FileNumber]
@FileOpen $MapFileName
$OC=@Map.Count
$PC=@Map.Parameters.Count
$CC1=0
$I=0
%LoopObject
$I=$I+1
$J=0
$L=@Map.Object[$I].Layer
$LD=@Map.Layers.Get $L
@Dialog.Message $LD
%LoopParameter
$J=$J+1
$S=@Map.Object[$I].Parameter[$J]
$CC2=0
%Repeat
$IP=@Calc pos(“$SearchText”,“$S”)
@if $IP=0 then @Goto %Continue1
$S=@Calc delete(“$S”,$IP,$STL)
$S=@DequoteText $S
$S=@Calc insert(“$S”,“$ReplaceText”,$IP)
$S=@DequoteText $S
$CC2=$CC2+1
@if $CC2>100 then @Goto %Continue1
@Goto %Repeat
%Continue1
@if $CC2=0 then @Goto %Continue2
$CC1=$CC1+1
@Map.Object[$I].Parameter[$J] $S
%Continue2
@if $J<$PC then @Goto %LoopParameter
@if $I<$OC then @Goto %LoopObject
@if $CC1>0 then @Map.SaveToFile $MapFileName
@if $CC1>0 then @Text[1].Add $MapFileName изменен
@if $CC1=0 then @Text[1].Add $MapFileName не изменен
@CloseMap
@if $FileNumber<$MapCount then @Goto %LoopEachFile
@Text[1].Save $Path\Changes.log
@Dialog.Message см. лог-файл $Path\Changes.log