Debian Codegraph @

Include/StrFunc.txt

raw
1 String Functions Header File Readme
2 -----------------------------------
3
4 String Functions Header File contains a set of good string manipulation
5 functions in a much simpler way to include and call in NSIS scripts.
6
7 How to use
8 ----------
9
10 Basic Syntax
11 ------------
12
13 Parameters are specified in this format:
14 required (required) (option1 | option2) [optional or add. options]
15 [option1 | option2]
16
17 The stars in command titles (*****) are the function usefulness in my
18 opinion. The more starts, the more useful it is. 5 stars (*****) is the
19 most useful.
20
21 Any time when is mentioned "Default is" means that you can use the value
22 mentioned or keep it blank, the result is the same.
23
24 If you want a certain value (e.g. a text) to be language-specific, set a
25 language string (using LangString) and define $(STRINGNAME) as value.
26
27 If you want to add ` to a string, you should always escape it using $\`
28 because the header file macro functions use ` to separate parameters.
29
30 1. Include Header file
31 ----------------------
32
33 !include "StrFunc.nsh"
34
35 StrFunc.nsh is inside the Include directory, so you don't have to
36 specify a path.
37
38 You have to put this command before any command used in this header file.
39
40 2. Defines
41 ----------
42
43 This header file contains defines that automate the life of some who
44 fear a lot of changes sometimes imposed in this header file, or who have
45 applications that put it to work at maximum capacity. Before you try
46 these, take a look at the information below:
47
48 - Every item on a define value is separated by a "|", and every subitem
49 (items in an item) is separated by " ".
50
51 - Use ${StrTok} $var "${DefineName}" "|" "$counter" "0" to get every
52 item inside the define. For subitems, use ${StrTok} $var2 "$var" " "
53 "$counter2" "0" after getting the value for a desired item.
54
55 - ${StrFunc_List} is automatically made by the header file. The rest
56 is manually added to the header.
57
58 2.1 Defines List:
59 -----------------
60
61 StrFunc_List - Lists all function names currently available on StrFunc
62 header file.
63
64 *_List - Lists all parameter names currently available for "*"
65 function. (* = function name - i.e. StrTok_List).
66
67 *_TypeList - Lists the types of all parameters on "*" function.
68 (* = function name - i.e. StrTok_List). Possible types
69 for each parameter:
70
71 - Output - Needs a variable to output a function result.
72
73 - Text - Needs text or number to be input.
74
75 - Mixed - Needs text, number or option to be input.
76 Each subitem following the "Mixed" word is an
77 option. The first option is ever the default
78 one. Two following spaces " " means that
79 that subitem is empty.
80
81 - Option - Needs an option to be input. Each subitem
82 following the "Option" word is an option.
83 The first option is ever the default one. Two
84 following spaces " " means that that subitem
85 is empty.
86
87 3. Commands
88 -----------
89
90 Some commands have special specifications to work. Consult command's
91 documentation on "3.3 Commands" section.
92
93 3.1 How To Use Commands In Install Sections and Functions
94 ---------------------------------------------------------
95
96 Every command used in install sections and functions have to be declared
97 before (and outside of) any sections and functions, and without
98 parameters.
99
100 Example:
101 --------
102
103 ${UsingStrFunc} StrStr
104
105 3.2 How To Use Commands In Uninstall Sections and Functions
106 -----------------------------------------------------------
107
108 Commands for uninstall sections and functions have "Un" before
109 the name.
110
111 Example:
112 --------
113
114 ${UsingStrFunc} UnStrStr
115
116 A complete example with both Install and Uninstall Commands:
117 ------------------------------------------------------------
118
119
120 !include "StrFunc.nsh"
121
122 ${UsingStrFunc} StrStr # Supportable for Install Sections and Functions
123
124 ${UsingStrFunc} UnStrStr # Supportable for Uninstall Sections and Functions
125
126 Section
127
128 ${StrStr} $0 "OK! Now what?" "wh"
129
130 SectionEnd
131
132 Section Uninstall
133
134 ${UnStrStr} $0 "OK! Now what?" "wh"
135
136 SectionEnd
137
138 3.3 Commands
139 ------------
140
141 =========================================================================
142 ** ${StrCase}
143 -------------------------------------------------------------------------
144 ResultVar String Type(|L|U|T|S|<>)
145 =========================================================================
146 Converts "String" to "Type" Case. Uses LogicLib.
147
148 Parameters:
149
150 ResultVar
151 Destination where result is returned.
152
153 String
154 String to convert to "Type" case.
155
156 Type
157 Type of string case to convert to:
158
159 - "" = Original Case (same as "String")
160 - L = Lower Case (this is just an example. a very simple one.)
161 - U = Upper Case (THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE.)
162 - T = Title Case (This Is Just An Example. A Very Simple One.)
163 - S = Sentence Case (This is just an example. A very simple one.)
164 - <> = Switch Case (This is just an example. A very simple one.)
165
166 Default value is "" (Original Case).
167
168 Result Value -> ResultVar:
169
170 "String" in "Type" case.
171
172 Example:
173
174 ${StrCase} $0 '"Você" is "You" in English.' "U"
175 [__(_)__()___()__()__(____)_]
176
177 $0 = '"VOCÊ" IS "YOU" IN ENGLISH.'
178
179 =========================================================================
180 * ${StrClb}
181 -------------------------------------------------------------------------
182 ResultVar String Action(|>|<|<>)
183 =========================================================================
184 Makes an action with the clipboard depending on value of parameter
185 "Action". Uses LogicLib.
186
187 Parameters:
188
189 String
190 If "Action" = ">" or "<>" - String to put on the clipboard.
191
192 Action
193 Can be one of the following values:
194
195 - "" = Cleans the clipboard.
196 - ">" = Set string to clipboard.
197 - "<" = Get string from clipboard.
198 - "<>" = Swap string with clipboard's.
199
200 Result Value -> ResultVar:
201
202 If "Action" = "<" or "<>" - String found on the clipboard.
203
204 =========================================================================
205 *** ${StrIOToNSIS}
206 -------------------------------------------------------------------------
207 ResultVar String
208 =========================================================================
209 Convert "String" from Install Options plugin to be supported by NSIS.
210 Escape, back-slash, carriage return, line feed and tab characters are
211 converted.
212
213 Parameters:
214
215 ResultVar
216 Destination where result is returned.
217
218 String
219 String to convert to be supportable for NSIS.
220
221 Result Value -> ResultVar:
222
223 "String" supportable for NSIS.
224
225 Example:
226
227 ${StrIOToNSIS} $0 "\r\n\t\\This is just an example\\"
228 [()()()()_______________________()]
229
230 $0 = "$\r$\n$\t\This is just an example\"
231
232 =========================================================================
233 * ${StrLoc}
234 -------------------------------------------------------------------------
235 ResultVar String StrToSearchFor CounterDirection(>|<)
236 =========================================================================
237 Searches for "StrToSearchFor" in "String" and returns its location,
238 according to "CounterDirection".
239
240 Parameters:
241
242 ResultVar
243 Destination where result is returned.
244
245 String
246 String where to search "StrToSearchFor".
247
248 StrToSearchFor
249 String to search in "String".
250
251 CounterDirection(>|<)
252 Direction where the counter increases to. Default is ">".
253 (> = increases from left to right, < = increases from right to left)
254
255 Result Value -> ResultVar:
256
257 Where "StrToSearchFor" is, according to "OffsetDirection".
258
259 Example:
260
261 ${StrLoc} $0 "This is just an example" "just" "<"
262 (__)<<<<<<<<<<<
263
264 $0 = "11"
265
266 =========================================================================
267 *** ${StrNSISToIO}
268 -------------------------------------------------------------------------
269 ResultVar String
270 =========================================================================
271 Converts "String" from NSIS to be supported by Install Options plugin.
272 Escape, back-slash, carriage return, line feed and tab characters are
273 converted.
274
275 Parameters:
276
277 ResultVar
278 Destination where result is returned.
279
280 String
281 String to convert to be supportable for Install Options plugin.
282
283 Result Value -> ResultVar:
284
285 "String" supportable for Install Options plugin.
286
287 Example:
288
289 ${StrNSISToIO} $0 "$\r$\n$\t\This is just an example\"
290 [(_)(_)(_)^_______________________^]
291
292 $0 = "\r\n\t\\This is just an example\\"
293
294 =========================================================================
295 ***** ${StrRep}
296 -------------------------------------------------------------------------
297 ResultVar String StrToReplace ReplacementString
298 =========================================================================
299 Searches for all "StrToReplace" in "String" replacing those with
300 "ReplacementString".
301
302 Parameters:
303
304 ResultVar
305 Destination where result is returned.
306
307 String
308 String where to search "StrToReplace".
309
310 StrToReplaceFor
311 String to search in "String".
312
313 StringToBeReplacedWith
314 String to replace "StringToReplace" when it is found in "String".
315
316 Result Value -> ResultVar:
317
318 "String" with all occurrences of "StringToReplace" replaced with
319 "ReplacementString".
320
321 Example:
322
323 ${StrRep} $0 "This is just an example" "an" "one"
324 [____________()_______]
325
326 $0 = "This is just one example"
327
328 =========================================================================
329 *** ${StrSort}
330 -------------------------------------------------------------------------
331 ResultVar String CenterStr LeftStr RightStr IncludeLeftStr(1|0)
332 IncludeCenterStr(1|0) IncludeRightStr(1|0)
333 =========================================================================
334 Searches for "CenterStr" in "String", and returns only the value
335 between "LeftStr" and "RightStr", including or not the "CenterStr" using
336 "IncludeCenterStr" and/or the "LeftStr" using "IncludeLeftStr" and
337 "RightStr" using "IncludeRightStr".
338
339 Parameters:
340
341 ResultVar
342 Destination where result is returned.
343
344 String
345 String where to search "CenterStr".
346
347 CenterStr
348 String to search in "String".
349
350 LeftStr
351 The first occurrence of "LeftStr" on the left of "CenterStr".
352 If it is an empty value, or was not found, will return
353 everything on the left of "CenterStr".
354
355 RightStr
356 The first occurrence of "RightStr" on the right of "CenterStr".
357 If it is an empty value, or was not found, will return
358 everything on the right of "CenterStr".
359
360 IncludeLeftStr(1|0)
361 Include or not the "LeftStr" in the result value. Default is 1
362 (True). (1 = True, 0 = False)
363
364 IncludeCenterStr(1|0)
365 Include or not the "CenterStr" in the result value. Default is 1
366 (True). (1 = True, 0 = False)
367
368 IncludeRightStr(1|0)
369 Include or not the "RightStr" in the result value. Default is 1
370 (True). (1 = True, 0 = False)
371
372 Result Value -> ResultVar:
373
374 String between "LeftStr" and "RightStr" of a found "CenterStr"
375 including or not the "LeftStr" and "RightStr" if
376 "IncludeLeftRightStr" is 1 and/or the "CenterStr" if
377 "IncludeCenterStr" is 1.
378
379 Example:
380
381 ${StrSort} $0 "This is just an example" " just" "" "ple" "0" "0" "0"
382 [_______(___)_______]( )
383 C R
384
385 $0 = "This is an exam"
386
387 =========================================================================
388 ***** ${StrStr}
389 -------------------------------------------------------------------------
390 ResultVar String StrToSearchFor
391 =========================================================================
392 Searches for "StrToSearchFor" in "String".
393
394 Parameters:
395
396 ResultVar
397 Destination where result is returned.
398
399 String
400 String where to search "StrToSearchFor".
401
402 StrToSearchFor
403 String to search in "String".
404
405 Result Value -> ResultVar:
406
407 "StrToSearchFor" + the string after where "StrToSearchFor" was found in
408 "String".
409
410 Example:
411
412 ${StrStr} $0 "This is just an example" "just"
413 >>>>>>>>>{_)____________]
414
415 $0 = "just an example"
416
417 =========================================================================
418 ***** ${StrStrAdv}
419 -------------------------------------------------------------------------
420 ResultVar String StrToSearchFor SearchDirection(>|<)
421 ResultStrDirection(>|<) DisplayStrToSearch(1|0) Loops CaseSensitive(0|1)
422 =========================================================================
423 Searches for "StrToSearchFor" in "String" in the direction specified by
424 "SearchDirection" and looping "Loops" times.
425
426 Parameters:
427
428 ResultVar
429 Destination where result is returned.
430
431 String
432 String where to search "StrToSearchFor".
433
434 StrToSearchFor
435 String to search in "String".
436
437 SearchDirection (>|<)
438 Where do you want to direct the search. Default is ">" (to right).
439 (< = To left, > = To right)
440
441 ResultStrDirection (>|<)
442 Where the result string will be based on in relation of
443 "StrToSearchFor"
444 position. Default is ">" (to right). (< = To left, > = To right)
445
446 DisplayStrToSearch (1|0)
447 Display "StrToSearchFor" in the result. Default is "1" (True).
448 (1 = True, 0 = False)
449
450 Loops
451 Number of times the code will search "StrToSearchFor" in "String" not
452 including the original execution. Default is "0" (1 code execution).
453
454 CaseSensitive(0|1)
455 If "1" the search will be case-sensitive (differentiates between cases).
456 If "0" it is case-insensitive (does not differentiate between cases).
457 Default is "0" (Case-Insensitive).
458
459
460 Result Value -> ResultVar:
461
462 "StrToSearchFor" if "DisplayStrToSearch" is 1 + the result string after
463 or before "StrToSearchFor", depending on "ResultStrDirection".
464
465 Result with Errors:
466
467 When "StrToSearchFor" was not found, will return an empty string.
468
469 When you put nothing in "StrToSearchFor", will return "String" and set
470 error flag.
471
472 When you put nothing in "String", will return an empty string and set
473 error flag.
474
475 Example:
476
477 ${StrStrAdv} $0 "This IS really just an example" "IS " ">" ">" "0" "0" "1"
478 >>>>>( )[____________________]
479
480
481 $0 = "really just an example"
482
483 =========================================================================
484 **** ${StrTok}
485 -------------------------------------------------------------------------
486 ResultVar String Separators ResultPart[L] SkipEmptyParts(1|0)
487 =========================================================================
488 Returns the part "ResultPart" between two "Separators" inside
489 "String".
490
491 Parameters:
492
493 ResultVar
494 Destination where result is returned.
495
496 String
497 String where to search for "Separators".
498
499 Separators
500 Characters to find on "String".
501
502 ResultPart[L]
503 The part want to be found on "StrToTokenize" between two "Separators".
504 Can be any number, starting at 0, and "L" that is the last part.
505 Default is L (Last part).
506
507 SkipEmptyParts(1|0)
508 Skips empty string parts between two "Separators". Default is 1 (True).
509 (1 = True, 0 = False)
510
511 Result Value -> ResultVar:
512
513 "String" part number "Part" between two "Separators".
514
515 Examples:
516
517 1) ${StrTok} $0 "This is, or is not, just an example" " ," "4" "1"
518 ( ) () () () [_] ( ) () ( )
519 0 1 2 3 4 5 6 7
520 $0 = "not"
521
522 2) ${StrTok} $0 "This is, or is not, just an example" " ," "4" "0"
523 ( ) () ^() [] ( ) ^( ) () ( )
524 0 1 23 4 5 67 8 9
525 $0 = "is"
526
527 =========================================================================
528 * ${StrTrimNewLines}
529 -------------------------------------------------------------------------
530 ResultVar String
531 =========================================================================
532 Deletes unnecessary new lines at end of "String".
533
534 Parameters:
535
536 ResultVar
537 Destination where result is returned.
538
539 String
540 String where to search unnecessary new lines at end of "String".
541
542 Result Value -> ResultVar:
543
544 "String" with unnecessary end new lines removed.
545
546 Example:
547
548 ${StrTrimNewLines} $0 "$\r$\nThis is just an example$\r$\n$\r$\n"
549 [_____________________________(_)(_)(_)(_)]
550
551 $0 = "$\r$\nThis is just an example"
552
553 Functions included and not included
554 --------------------------------------------------
555
556 11 functions have been included
557 They are not available on Archive
558 They are on LogicLib format
559
560 15 functions have not been included
561 12 were not included because of better functions
562 6 were not included because of AdvStrTok (called here as StrTok)
563 First String Part Function
564 Save on Variables Function
565 Sort Strings (1, 2 and 3) Functions
566 StrTok Function
567 2 were not included because of StrCase
568 StrLower Function
569 StrUpper Function
570 2 were not included because of StrClb
571 StrClbSet Function
572 StrClbGet Function
573 1 was not included because of NSISToIO and IOToNSIS
574 Convert / to // in Paths Function
575 1 was not included because of original String Replace Function (called
576 here as StrRep)
577 Another String Replace Function
578 2 were not included because they aren't useful anymore
579 Slash <-> Backslash Converter Function
580 Trim Function
581 1 was not included because of bugs
582 Number to String Converter Function
583
584 Version History
585 ---------------
586
587 1.09 - 10/22/2004
588
589 - Fixed stack problems involving: StrCase, StrRep, StrSort, StrTok.
590 - Fixed StrClb: When "Action" = "<>", handle was wrongly output as text.
591 - Fixed StrSort, StrStrAdv documentation examples.
592 - Fixed StrIOToNSIS, StrLoc, StrNSISToIO, StrRep, StrStr: sometimes
593 didn't find "StrToSearch" at all.
594
595 1.08 - 10/12/2004
596
597 - Converted all the functions to LogicLib.
598 - StrSort: Totally remade and it can break old scripts. See
599 documentation for details.
600 - StrTok: "ResultPart" has to start from 0 and it can break old scripts.
601 See documentation for details.
602 - Added defines: StrFunc_List, *_List and *_TypeList.
603 - Fixed StrStrAdv: Variables $R0-$R3 couldn't be used in scripts before calling.
604 - StrRep: Cut down some variables.
605 - Arranged correctly the order of StrSort on the documentation.
606
607 1.07 - 09/21/2004
608
609 - Removed ${UnStrFunc} command. Now you can just include uninstall
610 functions commands like ${UnStrStr} to be supported by uninstall functions
611 and sections.
612 - Added case-sensitive comparison option for StrStrAdv.
613 - StrCase now uses System.dll which makes case conversions effective with
614 all latin letters (i.e. ê).
615 - Added switch case and original case for StrCase.
616 - StrClbSet and StrClbGet removed, added StrClb.
617 - Made compact the most usual operations inside the header file. File size
618 reduced.
619
620 1.06 - 03/26/2004
621
622 - StrNumToStr removed due to complex number handling on some languages.
623 - Fixed the bug where the old string was attached to string returned by
624 StrCase when $R5 variable was used.
625
626 1.05 - 03/17/2004
627
628 - Fixed a bug with StrCase, Title Case wasn't working as should be.
629 - Fixed a bug with StrStrAdv, previous fix created another bug, string not
630 returned correctly when using backwards search with "DisplayStrToSearch" as
631 "0".
632
633 1.04 - 03/07/2004
634
635 - Added new StrCase, removed StrLower and StrUpper.
636 - Organized by name commands inside header and readme files.
637
638 1.03 - 02/12/2004
639
640 - Added commands support for uninstall sections and functions.
641 - Fixed variables switch in "StrLoc" and "StrTok" after using these.
642
643 1.02 - 02/07/2004
644
645 - Fixed StrLoc.
646 - Fixed Documentation about StrLoc. "Direction" is really "OffsetDirection".
647 - Added my new AdvStrSort, and removed the old one.
648
649 1.01 - 02/05/2004
650
651 - Fixed Documentation about StrSort and StrTok.
652 - Fixed StrTok default value for the string part. Now it's "L".
653 - Fixed StrStrAdv fixed wrong search when had a combination of same
654 substrings one after another in a string.
655 - Fixed StrLoc: when a string isn't found, don't return any value at all.
656
657 1.00 - 02/01/2004
658
659 - Added documentation.
660 - Renamed header file to "StrFunc.nsh".
661 - Added 1 function, StrLoc.
662 - Modified StrStrAdv, removed some lines.
663 - Fixed StrTok, 2 simple numbers made it loop every time.
664 - Fixed some small issues on the header file.
665
666 0.02 - 01/24/2004
667
668 - Completed StrFunc.nsh file. Need some tests and the readme.
669
670 0.01 - 01/22/2004
671
672 - First version to test ideas...
673
674 Credits
675 -------
676
677 Made by Diego Pedroso (aka deguix).
678
679 Functions Credits
680 -----------------
681
682 - All functions are made by Diego Pedroso on LogicLib format. They
683 are based on functions by Amir Szekely, Dave Laundon, Hendri
684 Adriaens, Nik Medved, Joost Verburg, Stuart Welch, Ximon Eighteen,
685 "bigmac666" and "bluenet". "bluenet"'s version of StrIOToNSIS and
686 StrNSISToIO on LogicLib format were included.
687
688 License
689 -------
690
691 This header file is provided 'as-is', without any express or implied
692 warranty. In no event will the author be held liable for any damages
693 arising from the use of this header file.
694
695 Permission is granted to anyone to use this header file for any purpose,
696 including commercial applications, and to alter it and redistribute
697 it freely, subject to the following restrictions:
698
699 1. The origin of this header file must not be misrepresented;
700 you must not claim that you wrote the original header file.
701 If you use this header file in a product, an acknowledgment in the
702 product documentation would be appreciated but is not required.
703 2. Altered versions must be plainly marked as such,
704 and must not be misrepresented as being the original header file.
705 3. This notice may not be removed or altered from any distribution.