Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Making (stringA - stringB) ...


2 replies to this topic

gronchi

gronchi
  • Members
  • 71 posts

Posted 06 December 2002 - 15:28

Hi to all,
I have to process a file where each row is a path:
<drive><path1>[path2]<filename>
Each row will become:
[path2]<filename>
where:
<> mandatory field (known length)
[] optional  field (UNknown length)

that is I have to make a string's subtraction
I didn't find something ready to use in InstallShield function so I write this code:

Code Sample

IN  STRING completePath = <drive><path1>[path2]<filename>
IN  STRING fixedPath    = <drive><path1>
OUT STRING shortPath    = [path2]<filename>

ncompletePathLength = StrLength(completePath);
nfixedPath = StrLength(fixedPath);
nDiff = (ncompletePathLength - nfixedPath);
StrSub (shortPath, completePath, nfixedPath, nDiff);


is there something better optimized?
(I know among you there are code guru...)

Thanks.
Ciao, Giuseppe

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 06 December 2002 - 16:24

You don't need to bother caclulating the difference or save off the results, so here's an optomized verison:

Code Sample

IN  STRING completePath = <drive><path1>[path2]<filename>
IN  STRING fixedPath    = <drive><path1>
OUT STRING shortPath    = [path2]<filename>

StrSub ( shortPath, completePath, StrLength(fixedPath), StrLength(completePath) );


However, I wasn't aware that IS had the concept of IN/OUT for variable declarations.  Interesting.
user posted image

gronchi

gronchi
  • Members
  • 71 posts

Posted 10 December 2002 - 17:24

Quote (TacoBell00 @ Dec. 06 2002,15:24)
However, I wasn't aware that IS had the concept of IN/OUT for variable declarations.  Interesting.

Yes I know, it's only a way to better visualize the variables I had to process.

Anyway thanks for the optimization!!!