Archive: String Function Header: "WordFunc.nsh"


String Function Header: "WordFunc.nsh"
Nullsoft Install System is the best. But when I had been writing
one script I could not do some string operations. I started to try
various functions, but unfortunately they were narrowly - directed and
some of them hanged during testing it I think inadmissible.

For this reason I wanted to write universal function on which other
functions can be based and wrote "WordFind".

Recently I have finished creation of a header file which includes
the following functions (with many examples):

1. WordFind (un.WordFind)
2. WordReplace (un.WordReplace)
3. WordAdd (un.WordAdd)
4. WordFind2X (un.WordFind2X)
5. StrFilter (un.StrFilter)
6. CopyToClipboard (un.CopyToClipboard)
7. CopyFromClipboard (un.CopyFromClipboard)

I shall be grateful if you will estimate the done job. :)


Nice ;)

I should use the clipboard functions! :)


CopyToClipboard & CopyFromClipboard are written by Afrow UK.


I think you should use a macro system with the functions...

E.g.

!macro StrStr TheString SearchFor
Push ${TheString}
Push ${SearchFor}
Call StrStr
!macroend


In their script, one would use:
!insertmacro StrStr "hello" "el"
Pop $R0 ;$R0 == "ello"


-Stu

That is offered is was the first version of a file: recurrence of identical functions, but with different names without un. and with un. But I do not like the big files especially if it is possible to make less. If I have correctly understood (English not the native language).


deguix made a StrFunc NSIS header file (it will be in your include folder) which you could always update with the new functions (or ask him to update it even).

-Stu


I know about Deguix StrFunc NSIS header file.

1) His macros have no uninstall. :(
2) From all functions in his header file at all my respect I can allocate only your clipboards, NSISToIO and IOToNSIS.


@AfrowUK

I was thinking to awnser before you about updating StrFunc.nsh.

@Instructor

1) They have uninstall.
2) Doesn't matter what you use the most. Sometimes neither I use it. It's only a selection of functions. I was thinking on your header file to make some changes to StrFunc.

I'll say more at night, 'cause right now I don't have time to awnser.


I apologize, if is valid StrFunc has uninstall macros (I have only the version included in NSIS 2.0).

For new version of WordFunc.zip


It's giving a foreign language 404 html error...

Now this is the time...:

You did a great job on doing all that. I really should stop my vacation on the StrFunc development now.

I see that you have some ideas on the header file itself:

- !define _UN1 when using uninstaller functions.

One thing to improve here is that you could make a smaller header file using this below as an example:

!macro un.CommandCall Parameters
!define _UN1
!insertmacro CommandCall ${Parameters}
!undef _UN1
!macroend

!macro CommandCall Parameters

# A normal command call

!macroend
- It doesn't have a command to separate commands for install and uninstall functions. Makes more lines of code (inside header file), but makes easier for the user.

And I did test your functions, they are in great shape, but we need to make sure that it doesn't have any bugs. Using that program of yours it will be much easier.

Now a list of planned things for StrFunc.nsh 1.07:

- I'll examinate your first 5 functions in your header file for bugs, if they have, I'll call you here. If not, they'll be included.
- Did you see my first suggestion here? StrFunc has a problem like it. I should fix it.
- An example program like yours (kichik told me before to do a different example program than just a simple test).

Because I already promissed the InstallOptionsEx new version soon, I'll start working on StrFunc only after that plugin launchment.

Ok, that's all for now. See you soon.

I don't understand your code.

"!define _UN1" (_UN1 is already defined)

Do you mean:


!macro un.CommandCall Parameters
!undef _UN1
!define _UN1 `un.`
!insertmacro CommandCall ${Parameters}
!undef _UN1
!define _UN1
!macroend

!macro CommandCall Parameters
Push ...
Push ...
Call {_UN1}Command
Pop ...
Pop ...
!macroend

If yes, then the size on the contrary will increase.

Can you explain if not difficultly:
"- It doesn't have a command to separate commands for install and uninstall functions."


No, it should be:

macro un.CommandCall Parameters
!define _UN1 `un.`
!insertmacro CommandCall ${Parameters}
!undef _UN1
!macroend

This is simple, because _UN1 will start off undefined, be defined for the CommandCall, and then be undefined again (for another CommandCall)

-Stu


Can you explain if not difficultly:
"- It doesn't have a command to separate commands for install and uninstall functions."
In other words, it has commands like ${WordFind} and ${un.WordFind}.

StrFunc has commands like ${StrStr}, ${UnStrFunc} (to separate inst from uninst) and ${StrStr} again.

(I call ${WordFind} a command, not a function or macro.)

! include WordFunc.nsh

### _UN1 should be defined all over again up to###
!insertmacro WordFunction

Section
$ {WordFunction}...
SectionEnd

Unfortunately I do not see it more simple decision. Whether can you write an example with one function.


I didn't want you to change that, I was just saying that that is different, and I liked it. (sorry if I didn't say it before)

I'll launch InstallOptionsEx beta 6 now, so I can work on StrFunc.nsh starting right now. Is that first file your latest file version? Can I begin the development now?


The previous message has been addressed for Afrow UK.

I discuss with you and with Afrow UK in a that occasion that you have suggested to simplify a header file, but yet has not found out how this simplification can be expressed.

I spread last version constantly here Download


I spread last version constantly here
For me you hosted a file on a host that doesn't reach the United States, so I can't download it. Please, attach the file here.

...


Thanks. It's like what happened when I was on Brazil trying to download HM NIS Edit. I couldn't get it from there. I just knew and used that program only here in United States.


Good remark.
With what program you download a file?


I use Internet Explorer. It's just because USA is so far from Russia that he couldn't get the download. I could though as I am a little closer.

-Stu


I know it, but for example Opera (at me 7.23) also refuses to download a file.


Oh... you mean you can't download it if you follow the link? Well I tried it and it came up with a page with loads of strange characters (I guess it's Russian), but there was a big link on there with the download URL (but in funny characters). I clicked on that and it downloaded.

-Stu


On the next time, try to at least to have a page in English. I can't understand anything. The real thing is that it reaches here but I didn't know were to click.


Now about the functions, I included the Word* functions (I won't launch it right now), but I just wanted to tell you to make a smaller version of StrFilter without the Upper case and Lower case options. Because I already have one function totally for this subject.

And another thing, you could add an ability to filter the characters the user wants. But you don't need to do this right now.


I'd like to have some of your functions in the better shape as possible for the people (as I said before). You don't imagine how tested the functions that are included with StrFunc.nsh within NSIS are. As NSIS is in a stable version, we test everything we can...

I know, you've done a good job, but we need it to be a "perfect" job. As I had to do before. So that's why I'm asking more favors from you now:

- General:

- Don't try to compress every option and, for example, words to add under one parameter, try to expand it into several parameters so makes the input more organized (for the user).

- Try to make an error handler like NSIS do, it never outputs like a parameter, but it uses the command "SetErrors". Only in much complicated matters is used another return value for errors (like InstallOptions).

- Try to make it accept the String without separators. That means "String" should have the minimum of 1 word (not 2 as now it is).

- Make output parameters as the first, then the input ones.

- As all the functions are ${WordFind} dependant, you could make them with more options, like the ${WordFind} itself.

- Learn to use default values for the parameters, like in ${WordAdd} the "Delimiter" parameter could have a value when it is empty.

Don't be mad at me just by that, when I started nor even English I did understand well, now after about two years using NSIS (I'm member here since Dec, 2002, but I used NSIS since Aug, 2002) I have two projects that I'm working right now, and other several functions, but most of them I kept abandoned.

(Sometimes you can see me as a perfectionist, that's because I'm an user and a developer at the same time.)


... make a smaller version of StrFilter without the Upper case and Lower case options. Because I already have one function totally for this subject.
I think there is no necessity to change idea of function and the more to reduce an opportunity.

And another thing, you could add an ability to filter the characters the user wants.
The concrete example is necessary for me (What string is given? What it is necessary to make?).

I'd like to have some of your functions in the better shape as possible for the people...
Do you mean comments?

- Don't try to compress every option and, for example, words to add under one parameter, try to expand it into several parameters so makes the input more organized (for the user).
How many people are so much and opinions. I see it as have made (simple, organized, compact).

- Try to make an error handler like NSIS do, it never outputs like a parameter, but it uses the command "SetErrors". Only in much complicated matters is used another return value for errors (like InstallOptions).
It is simple to do. The offer: SetErrors for errorlevel 1-4.

- Try to make it accept the String without separators.
What sense? What tasks can be solved thus?

That means "String" should have the minimum of 1 word (not 2 as now it is).
There is minimum = 1 word + delimiter ([Word][delimiter], but not [word])

- Make output parameters as the first, then the input ones.
If it is critical that I can change it. Though it is more habitual for me by analogy to use of functions:

Push "..."
Push "..."
Call Function
Pop $var1
Pop $var2


- As all the functions are ${WordFind} dependant, you could make them with more options, like the ${WordFind} itself.
The concrete example is necessary for me (What string is given? What it is necessary to make?).

- Learn to use default values for the parameters, like in ${WordAdd} the "Delimiter" parameter could have a value when it is empty.
All values required I don't want to change it (There are no those parameters which it is possible to name by default).

I in any case do not become angry. I am glad, that there are people which express the opinion. :)

- Try to make an error handler like NSIS do, it never outputs like a parameter, but it uses the command "SetErrors". Only in much complicated matters is used another return value for errors (like InstallOptions).
Sorry has not closely read.

I have thought that you have suggested to add besides errorlevel parameter also command SetErrors.

I want to tell, that errorlevel serves for the greater concrete definition of mistakes (you are itself understand it) which it is possible and it is necessary to use (Examle.nsi).

I think there is no necessity to change idea of function and the more to reduce an opportunity.
OK, no problems at all.

The concrete example is necessary for me (What string is given? What it is necessary to make?).
Hmmm... I was saying about the function StrFilter. That's because it now has an option to choose between letters, numbers and other types, but it doesn't accept the characters you want.

This would be great for path names (like "C:\Program Files") to filter characters like "*" which you cannot put.

How many people are so much and opinions. I see it as have made (simple, organized, compact).
OK, no problems.

What sense? What tasks can be solved thus?
Hmmm... Ignore my message, I sometimes post so fast that actualy I put non-sense things to the post.

There is minimum = 1 word + delimiter ([Word][delimiter], but not [word])
Could you include at least this change, please?

If it is critical that I can change it. Though it is more habitual for me by analogy to use of functions:
Oh man, where I did hit my head that day...

- As all the functions are ${WordFind} dependant, you could make them with more options, like the ${WordFind} itself.
The concrete example is necessary for me (What string is given? What it is necessary to make?).
Sorry if I didn't say, but I was saying about the functions.

All values required I don't want to change it (There are no those parameters which it is possible to name by default).
OK, I can do it.

I want to tell, that errorlevel serves for the greater concrete definition of mistakes (you are itself understand it) which it is possible and it is necessary to use (Examle.nsi).
Yep.

I asked all that because some of them are better to be changed in the function itself if you can do it. If you can't, no problems.

...it doesn't accept the characters you want.

This would be great for path names (like "C:\Program Files") to filter characters like "*" which you cannot put.
I need more information (fill the data).

String: "C:\Program Files"

Filter: "?"

Result: "?"

...I was saying about the functions.
1) What opportunities in functions does not suffice?
2) Globally: what operations with string, it is impossible to do, but it would be desirable?

Could you include at least this change...
Unfortunately I can't, as this change already exists. :)
You even can enter no words, but a delimiter should be found necessarily (accepted: string from one delimiters).


If you are going to test functions, you can enter any parameters and strings - functions will not hang and will show result (at least so reflected).

Pay attention on (WordFind):
--------------------------------------------------------------------
Strings:
"[word+1][delimiter][word+2][delimiter][word+3]..."
"[delimiter][word+1][delimiter][word+2][delimiter]..."
"[delimiter][delimiter][word+1][delimiter][delimiter][delimiter]..."
"...[word-3][delimiter][word-2][delimiter][word-1]"
"...[delimiter][word-2][delimiter][word-1][delimiter]"
"...[delimiter][delimiter][word-1][delimiter][delimiter][delimiter]"
--------------------------------------------------------------------


By the way has a little changed WordFind:

Word Functions Header v1.9


Thanks Deguix. I obstinate, but attentive.

1) Has reduced quantity of output variables in Word functions (with 2 up to 1).
"WordAdd" now accept one word.
New "WordReplace" option {}.
New function "WordInsert".
New example-program "RenameIt".
Add an example for WordFind "To accept one word in string if delimiter not found".

2) Has processed StrFilter:
-Inclusion of the certain symbols (without the filter)
-Removal of the certain symbols
-Multilanguage support (at present English and Russian)

If somebody can help with other languages I shall be grateful
English: A-Z (ACSII code: 65-90)
a-z (ACSII code: 97-122)
Russian: FirstSymbolInUpperCase-LastSymbolInUpperCase (ACSII code: 192-223)
FirstSymbolInLowerCase-LastSymbolInLowerCase (ACSII code: 224-255)
...


Word Functions Header v2.0


1) Completely rewritten code for "WordFind2X" (new algorithm).
2) "WordInsert" now accept empty string.
3) Processed "WordReplace" option {}.
4) "RenameIt":
-Add UNDO option.
-Has taken away the option of the choice of the language (is now used filter for two languages).


Word Functions Header v2.1


1) "WordReplace":
-Serious bug fixed: when use all replace + when option "replace it" meets in option "replace with".
-Code optimization
2) "WordAdd":
-Removed errorlevel 4b and added errorlevel 1 then delimiter is empty
3) "WordInsert":
-added errorlevel 1 then delimiter is empty
4) "RenameIt":
-Better list edit and command line support


Word Functions Header v2.2 (I hope final)


Changes:

1) Errorlevel output: by default no output (more comfortable for user)
2) WordFind2X: New optimized code (WordFind independent)
3) New function "GetParameters"
4) Removed errorlevel 4 from all functions
5) Removed errorlevel 2 from "WordAdd"
6) Removed example-program "RenameIt"

Word Functions Header v2.3


Yes! I got the 1000th view on this topic :D


WordFind2X:
New option { and }

Word Functions Header v2.31


Changes:

1. Processed "WordFind" option {} -> "WordAdd" replace improved.
2. Processed "WordFind" option {{ and }}.
3. "WordFind2X" new options like "WordFind":
    -{* and *}
    -/word
    -Rename { and } with {{ and }}

Word Functions Header v2.4


Changes:

1. "WordFind" v1.9
    -new optimazed code
2. "WordFind2X" v2.0
    -code optimization
3. "WordReplace" v2.0
    -now "WordFind" independent

Word Functions Header v2.5 (Final)


Archive: String Function Header: "WordFunc.nsh"


"WordFind" v2.0
  -Some small improvement

Word Functions Header v2.51