From 343414493d627397dd9c6671ccdc991b8eb03356 Mon Sep 17 00:00:00 2001 From: LanHeron Date: Wed, 3 Sep 2025 11:36:58 +0800 Subject: [PATCH] vault backup: 2025-09-03 11:36:58 --- .../相关操作/4.0-other/999.Delphi脚本记录.md | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md index 8175a5fb..bbcb8aef 100644 --- a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md +++ b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md @@ -873,4 +873,25 @@ end. ## 从文档名称中获取文件编码 -设置从文件名称中获取文件编码,需要设置在 \ No newline at end of file +设置从文件名称中获取文件编码,需要设置在 **事件脚本** → **页面显示时** 当中,以 `&` 符号作为分隔符 + +```delphi +uses MyClass,Variables,BaseUtil,CommonFunc,DataConst,CFFrm,CFSimplePropFrm,Forms,StdCtrls,Variants,SysUtils,Classes,Controls,Dialogs, + CHostIntf,ProductClas,DocClas,LoginClas,VirtualTrees,CEntClas,PathClas; +var + AmpPos: Integer; + ResultText: string; +begin + // 查找 & 符号的位置 + AmpPos := Pos('&', fedtDocName.Text); + + if AmpPos > 0 then + begin + // 提取 & 符号之前的内容 + ResultText := Copy(fedtDocName.Text, 1, AmpPos - 1); + + // 将变量值插入SQL语句,而不是变量名 + chiExecuteSqlNoResultRec('update cfdoc set code = ''' + ResultText + ''' where docid = ' + IntToStr(CurBizObj.objid)); + end; +end. +``` \ No newline at end of file