简体   繁体   English

PosEx在设计时软件包中不起作用

[英]PosEx not works in Design-Time Package

I have created a design-time package for my delphi7 IDE. 我已经为delphi7 IDE创建了一个设计时程序包。 I want a component on a form offer me some menu items in the context menu during design-time. 我希望表单上的组件在设计时为我提供上下文菜单中的一些菜单项。 When i debug the package, i can see that my code gets executed, but when it comes to a line using the built-in function PosEx, the behaviour confuses me. 当我调试程序包时,我可以看到我的代码被执行了,但是当使用内置函数PosEx进行一行处理时,该行为使我​​感到困惑。 In the debugger, i can see that the text to search in contains the part to search for, but the function returns 0 anyway! 在调试器中,我可以看到要搜索的文本包含要搜索的部分,但是无论如何该函数返回0! And, if i execute this directly (instead of debugging the IDE using it in a project) it all works fine. 而且,如果我直接执行此操作(而不是在项目中使用它来调试IDE),则一切正常。

This is my code: 这是我的代码:

function RemoveLeftOverPlaceHolders( var PIO_sTemplate: string);
var nStartPos: integer;
const JPCG_FOREACH_START = '{%foreach ';
begin
  nStartPos := 0;

  repeat
    nStartPos := PosEx( JPCG_FOREACH_START, PIO_sTemplate, nStartPos ); // <-- nStartPos is always 0 !
    if nStartPos > 0 then begin
      ...
    end;
  until nStartPos = 0;
end;

Is it possible that the string types are changed during execution in the IDE? 在IDE中执行过程中是否可能更改了字符串类型? (any ansistring-unicode problem?) (任何ansistring-unicode问题?)

Edit: I'm using GExperts and DelphiSpeedUp 编辑:我正在使用GExperts和DelphiSpeedUp

Stupid... the answer stands right in the code... nStartPos is initialized with 0, whichs leads to a failing PosEx. 愚蠢的...答案正好在代码中... nStartPos初始化为0,这导致PosEx失败。 Strange that it worked when executing the code out of a design pack... 奇怪的是,当从设计包中执行代码时,它起作用了……

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM