首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将参数传递给.isl文件中定义的自定义消息

将参数传递给.isl文件中定义的自定义消息
EN

Stack Overflow用户
提问于 2015-11-17 10:54:35
回答 2查看 913关注 0票数 1

我的更新必须知道用户指定的目录中是否存在两个已知的文件。如果不是,我想让他知道,这条路上没有文件。到目前为止,这是我所有.isl文件中的一个.isl文件。现在我想给他看他用文件输入的完整路径。

到目前为止,这条消息看起来如下:

在选定的位置找不到File1、File2或两者.

我现在想要的是:

%1,%2或两者都找不到.

对于%1%2,我想传递完整的指定路径,但我看不出如何做到这一点。ExpandConstant没有任何参数,到目前为止,我还没有发现如何将参数传递给自定义消息。

为了澄清问题,下面是代码:

代码语言:javascript
复制
function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
  ServerData : String;
  UseDatabase : String;
  Language : String;
  ResultCode : Integer;
  ExePath : String;
  ConfigFilePath : String;
begin
  Result := True;
  if CurPageID = wpSelectDir then begin
    if DirExists(ExpandConstant('{app}')) then begin
        MsgBox(ExpandConstant('{app}'),mbInformation,MB_OK);    
        UpdatePath := ExpandConstant('{app}');
        ExePath := UpdatePath+'\File1.exe';
        ConfigFilePath := UpdatePath+'\File2.exe.config'; 
        if FileExists(UpdatePath+'\File1.exe') and FileExists(UpdatePath+'\File2.exe.config') then begin
            RegPath := UpdatePath;
            UpdatePath := RegPath + '\Update-' + ExpandConstant('{#MyAppVersion}');
            ConfigPath := RegPath + '\File2.exe.config';
            DBPage.Values[0] := ExtractServerAddr(GetServerData(ConfigPath));
            DBPage.Values[1] := ExtractServerPort(GetServerData(ConfigPath));           
        end else begin
            MsgBox(ExpandConstant('{cm:DirPageFileNotFound,ExePath,ConfigFilePath}'),mbInformation,MB_OK);
            Result := False;
        end;
    end else begin
            MsgBox(ExpandConstant('{cm:DirPageDirectoryNotFound}'),mbInformation,MB_OK);
            Result := False;
    end;
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-11-17 16:49:07

在Pascal脚本中,您应该同时使用CustomMessageFmtMessage

代码语言:javascript
复制
FmtMessage(CustomMessage('DirPageFileNotFound'), [ExePath, ConfigFilePath])

它比组装{cm:MessageName,Arguments} “常数”更干净,更容易出错。例如,如果在任何路径中都有逗号或大括号,你的语法就会中断。

{cm:...}常量用于非Code部分,如:

代码语言:javascript
复制
[Run]
Filename: "myapp.exe"; Description: "{cm:RunningApp,myapp.exe}"; 

类似问题:将参数传递给.isl文件中定义的自定义消息

票数 1
EN

Stack Overflow用户

发布于 2015-11-17 13:03:40

好吧,解决办法是尽可能容易的:

代码语言:javascript
复制
ToExpand := '{cm:DirPageFileNotFound,' + ExePath +',' + ConfigFilePath + '}'
MsgBox(ExpandConstant(ToExpand),mbInformation,MB_OK);

这两句台词成功了。

PS:我很感谢StackOverflow是我的橡皮鸭。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33755121

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档