Old 28th December 2004, 10:23   #1
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Post WordFunc.nsh + TextFunc.nsh + FileFunc.nsh

I have thought more convenient to update one topic than three topics

Word Functions Header v2.52
Text Functions Header v1.4
File Functions Header v1.21


1. Function GetParameters moved from WordFunc.nsh to FileFunc.nsh
2. Text Functions LineFind and LineRead
    -now last line "-1" instead of "0"

These headers are included with NSIS. See: http://nsis.sourceforge.net/Docs/AppendixE.html#E
Attached Files
File Type: zip nsh.zip (29.5 KB, 2844 views)

Last edited by Instructor; 28th December 2004 at 13:02.
Instructor is offline   Reply With Quote
Old 17th January 2005, 23:53   #2
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.6
Text Functions Header v1.4
File Functions Header v1.3


1. "GetDrives" v1.1
   -Fixed: depended on drives order

2. "WordFind2X" v2.1
   -Loops sorted

3. New: "WordFind3X" v1.0
   -Find word, that contain string, between two delimiters.
   (Based on Afrow UK idea of Function "StrSortLR" 2003-06-18)

4. "WordFuncExample.nsi" updated.
Attached Files
File Type: zip nsh.zip (30.4 KB, 1115 views)
Instructor is offline   Reply With Quote
Old 1st February 2005, 07:05   #3
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.6
Text Functions Header v1.5
File Functions Header v1.3


"LineFind" v1.3
  -Added "/NUL" option: No output text file (only read InputFile).
Attached Files
File Type: zip nsh.zip (30.7 KB, 739 views)
Instructor is offline   Reply With Quote
Old 13th February 2005, 01:50   #4
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.6
Text Functions Header v1.5
File Functions Header v1.4


1. New: "GetBaseName"
   -Get file name without extension.
   (Based on comperio idea of Function "GetBaseName" 2005-01-28)

2. New: "GetFileVersion"
   -Gets the version information from executable file.

3. New: "VersionCompare" v1.0
   -Compare version numbers.
   (Based on Afrow UK Function "VersionCheckNew2" 2005-01-24)
       His original function isn't included because of wrong results:
       ${VersionCheckNew2} "2.5.9" "2.5.01" $R0     -Ver2 newer
       ${VersionCheckNew2} "2.5.09" "2.5" $R0       -equal
Attached Files
File Type: zip nsh.zip (31.8 KB, 1518 views)
Instructor is offline   Reply With Quote
Old 13th February 2005, 03:33   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Why is 2.5.09 equal to 2.5? Just a typo or does the function behave that way?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th February 2005, 08:29   #6
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
No. It isn't a typo.
Instructor is offline   Reply With Quote
Old 13th February 2005, 13:12   #7
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
@kichik:
Quote:
His original function isn't included because of wrong results:
${VersionCheckNew2} "2.5.9" "2.5.01" $R0 -Ver2 newer
${VersionCheckNew2} "2.5.09" "2.5" $R0 -equal
read it another time
Comm@nder21 is offline   Reply With Quote
Old 13th February 2005, 17:16   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
Thanks for letting me know
Fixed my function.

-Stu
Afrow UK is offline   Reply With Quote
Old 21st March 2005, 07:24   #9
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.6
Text Functions Header v1.6
File Functions Header v1.4


1. "LineFind" v1.4
   -Output file will not be updated if no changes made
   -Error flag if output file path isn't exists
   -Added: "{No}" callback this line and don't write others
   -Variables in callback function changed

2. Added script to simple install WordFunc.nsh, TextFunc.nsh, FileFunc.nsh
Attached Files
File Type: zip nsh.zip (32.8 KB, 796 views)

Last edited by Instructor; 21st March 2005 at 07:48.
Instructor is offline   Reply With Quote
Old 26th March 2005, 19:53   #10
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.7
Text Functions Header v1.7
File Functions Header v1.5


1. "ClbSet", "ClbGet" removed from WordFunc.nsh

2. "LineRead" v1.2, "LineSum", "FileJoin" v1.4, "TextCompare" v1.2
   -Added IfErrors after FileOpen

3. "GetDrives" v1.2
   -Added "ALL" along with ""

4. New: "FileReadFromEnd" v1.0
   -Read text file from end line by line.

5. New: "DriveSpace" v1.0
   -Get total, occupied or free space of the drive.

6. Added: "GetRoot"
    (Based on KiCHiK Function "GetRoot")
   -Get the root directory.

7. Added: "GetParent"
    (Based on sunjammer Function "GetParent")
   -Get parent directory.

8. Added: "GetFileName"
    (Based on KiCHiK Function "GetFileName")
   -Get last part from directory path.

9. Many minor code and documentation improvements
Attached Files
File Type: zip nsh.zip (34.4 KB, 619 views)

Last edited by Instructor; 26th March 2005 at 20:25.
Instructor is offline   Reply With Quote
Old 27th March 2005, 09:49   #11
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.7
Text Functions Header v1.7
File Functions Header v1.6


  "DriveSpace", "DirState", "GetFileVersion"
   -Missing ClearErrors at the beginning.
Attached Files
File Type: zip nsh.zip (34.3 KB, 557 views)
Instructor is offline   Reply With Quote
Old 28th March 2005, 11:56   #12
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.7
Text Functions Header v1.8
File Functions Header v1.7


In order to avoid exiting from connected functions,
changed exit value in callback function to "Stop<FunctionName>":

-"LineFind"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop -> StopLineFind
-"FileReadFromEnd"&nbsp;&nbsp;Stop -> StopFileReadFromEnd
-"TextCompare"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StopCompare -> StopTextCompare
-"GetDrives"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop -> StopGetDrives
Attached Files
File Type: zip nsh.zip (34.4 KB, 593 views)

Last edited by Instructor; 28th March 2005 at 12:25.
Instructor is offline   Reply With Quote
Old 1st April 2005, 18:45   #13
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.8
Text Functions Header v1.8
File Functions Header v1.8


1. "Locate" v1.5
&nbsp;&nbsp;&nbsp;-Added "/B=" parameter (when used banner with function)

2. "StrFilter" v1.2
&nbsp;&nbsp;&nbsp;-Missing ClearErrors at the beginning.
Attached Files
File Type: zip nsh.zip (34.8 KB, 548 views)
Instructor is offline   Reply With Quote
Old 11th April 2005, 11:31   #14
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.8
Text Functions Header v1.8
File Functions Header v1.9



Changes:

&nbsp;"Locate" v1.6
&nbsp;&nbsp;&nbsp;-Fixed: if error appeared in the callback, function don't restore stack after exit.
Attached Files
File Type: zip nsh.zip (34.8 KB, 643 views)
Instructor is offline   Reply With Quote
Old 14th April 2005, 10:01   #15
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.8
Text Functions Header v1.8
File Functions Header v2.0



Changes:

&nbsp;New: "GetOptions"
&nbsp;&nbsp;&nbsp;-Get options from command line parameters.
Attached Files
File Type: zip nsh.zip (35.5 KB, 1524 views)
Instructor is offline   Reply With Quote
Old 20th April 2005, 11:53   #16
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v2.9
Text Functions Header v2.0
File Functions Header v2.3



Changes:

1. Verbosity added (faster compilation time)

2. "Locate" v1.7
&nbsp;&nbsp;&nbsp;&nbsp;-Fixed: Banner support

3. "GetOptions"
&nbsp;&nbsp;&nbsp;&nbsp;-Now required only 2 arguments:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${GetOptions} "[Parameters]" "[Option]" $var

4. "GetTime" v1.2
&nbsp;&nbsp;&nbsp;&nbsp;-Now convert day and month in DD and MM format

5. "TextCompare" v1.4
&nbsp;&nbsp;&nbsp;&nbsp;-Rewrited all code

6. "FileReadFromEnd" v1.2
&nbsp;&nbsp;&nbsp;&nbsp;-Now if the text file cannot be opened, the error flag is set
Attached Files
File Type: zip nsh.zip (35.3 KB, 1644 views)
Instructor is offline   Reply With Quote
Old 24th May 2005, 18:05   #17
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.0
Text Functions Header v2.1
File Functions Header v2.4



Changes:

1. "VersionCompare" moved from FileFunc.nsh to WordFunc.nsh

2. New: "VersionConvert" v1.0
&nbsp;&nbsp;&nbsp;-Convert version in the numerical format which can be compared.

3. New: "ConfigRead" v1.0
&nbsp;&nbsp;&nbsp;-Read value from entry name in config file.

4. New: "ConfigWrite" v1.1
&nbsp;&nbsp;&nbsp;-Write value from entry name in config file.

5. New: "FileRecode"
&nbsp;&nbsp;&nbsp;-Recode text file from DOS to Windows format and vice-versa.

6. New: "GetFileAttributes" v1.1
&nbsp;&nbsp;&nbsp;-Get attributes of file or directory.

7. New: "BannerTrimPath"
&nbsp;&nbsp;&nbsp;-Trim string path for banner.
Attached Files
File Type: zip nsh.zip (38.9 KB, 1482 views)
Instructor is offline   Reply With Quote
Old 12th July 2005, 11:35   #18
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.0
Text Functions Header v2.1
File Functions Header v2.5



Changes:

1. "GetDrives" v1.4
&nbsp;&nbsp;&nbsp;&nbsp;-Fixed: Alloc/Free (Thanks nechai)

2. "GetOptions"
&nbsp;&nbsp;&nbsp;&nbsp;-Better option search (complite ignoration in quotes)

3. Renamed example scripts (like in CVS):
&nbsp;&nbsp;&nbsp;&nbsp;...FuncTest.nsi -> ...Func.nsi
&nbsp;&nbsp;&nbsp;&nbsp;...FuncTest.ini -> ...Func.ini
Attached Files
File Type: zip nsh.zip (39.1 KB, 610 views)
Instructor is offline   Reply With Quote
Old 20th July 2005, 23:49   #19
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.0
Text Functions Header v2.1
File Functions Header v2.6



Changes:

1. "GetTime" v1.3
&nbsp;&nbsp;&nbsp;&nbsp;-Fixed: Free structures

2. "GetExeName" and "GetExePath"
&nbsp;&nbsp;&nbsp;&nbsp;-Simplification with "GetLongPathNameA"

3. "BannerTrimPath"
&nbsp;&nbsp;&nbsp;&nbsp;-Added D mode
Attached Files
File Type: zip nsh.zip (39.1 KB, 2134 views)
Instructor is offline   Reply With Quote
Old 23rd August 2005, 12:20   #20
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.1
Text Functions Header v2.1
File Functions Header v2.7


Changes:

1. "WordReplace" v2.1
&nbsp;&nbsp;&nbsp;&nbsp;-Fixed: Incorrect rule for return errorlevel 1 in situation when string beginning with word to replace and its only one word in string and when uses option - deletes all founded words (thanks hemancuso)

2. "GetExeName" and "GetExePath"
&nbsp;&nbsp;&nbsp;&nbsp;-Fixed: Return empty string in Windows 95 (thanks kichik)
Attached Files
File Type: zip nsh.zip (39.2 KB, 571 views)
Instructor is offline   Reply With Quote
Old 21st October 2005, 18:22   #21
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.1
Text Functions Header v2.1
File Functions Header v2.8


Changes:

1. Now "GetRoot" returns not only root drive or UNC:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${GetRoot} "Program Files\NSIS" $R0 &nbsp;&nbsp;&nbsp;# $R0="Program Files" instead of ""
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${GetRoot} "\Program Files\NSIS" $R0 &nbsp;&nbsp;# $R0="\Program Files" instead of ""

2. Some typos corrected (thanks Jamyn)
Attached Files
File Type: zip nsh.zip (39.2 KB, 663 views)
Instructor is offline   Reply With Quote
Old 23rd December 2005, 07:47   #22
MikeSchinkel
Guest
 
Posts: n/a
What about UTC (Coordinated Universal Time?)

I need to use UTC (Coordinated Universal Time) instead of Local Time which can be gotten from kernel32::GetSystemTime. Any chance of updating the "official" version of Text Functions Header to incorporate that functionality?

My other option is to hack GetTime() and include it directly in my code. Yuck.
  Reply With Quote
Old 24th December 2005, 13:16   #23
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.1
Text Functions Header v2.1
File Functions Header v2.9


Changes:

"GetTime" v1.4
-Added support for system time (UTC)
-Added example how to convert time to 12-hour format AM/PM
Attached Files
File Type: zip nsh.zip (39.4 KB, 633 views)
Instructor is offline   Reply With Quote
Old 3rd February 2006, 13:01   #24
TonyDS
Senior Member
 
Join Date: Jul 2003
Posts: 151
Has the getdrives function been tested on windows 98,

If so does it work?
TonyDS is offline   Reply With Quote
Old 3rd February 2006, 13:30   #25
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Quote:
Has the getdrives function been tested on windows 98
Yes
Quote:
If so does it work?
Yes
Instructor is offline   Reply With Quote
Old 3rd February 2006, 13:37   #26
TonyDS
Senior Member
 
Join Date: Jul 2003
Posts: 151
Thanks
TonyDS is offline   Reply With Quote
Old 5th February 2006, 17:37   #27
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.2
Text Functions Header v2.2
File Functions Header v3.0


Changes:

1. "WordReplace" v2.2
&nbsp;&nbsp;&nbsp;-Added options "{", "}", "{*", "}*"

2. "GetOptions"
&nbsp;&nbsp;&nbsp;-Now sets error flag if option does not found

3. "ConfigRead"
&nbsp;&nbsp;&nbsp;-Now sets error flag if entry does not found

4. New case sensitive functions (NSIS 2.14 required):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"WordFindS", "WordFind2XS", "WordFind3XS", "WordReplaceS",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"WordAddS", "WordInsertS", "StrFilterS", "TextCompareS",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ConfigReadS", "ConfigWriteS", "GetOptionsS"

5. Added program for simple headers install
Attached Files
File Type: zip nsh.zip (44.4 KB, 557 views)
Instructor is offline   Reply With Quote
Old 6th February 2006, 08:19   #28
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Word Functions Header v3.2
Text Functions Header v2.3
File Functions Header v3.1


Changes:

-Added /NOUNLOAD flag for the system plugin. Functions that uses system plugin calls several times, now 25-75% faster ("GetSize", "DriveSpace", "GetDrives", "GetTime", "ConfigWrite", "FileRecode").
Attached Files
File Type: zip nsh.zip (44.4 KB, 1035 views)
Instructor is offline   Reply With Quote
Old 6th February 2006, 18:48   #29
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
kichik, plz update the CVS
Comm@nder21 is offline   Reply With Quote
Old 9th March 2006, 00:46   #30
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Hey Instructor,
I have to say that your functions are very cool. I find that I use them almost every chance I get!

Here's an enhancement suggestion for the Locate function:
Currently, there is an option /M=[mask] to add options of what to search for. A cool option might be something like /!M=[mask] to specify what to EXCLUDE.

For example /!M=*.EXE would mean to exclude all dat files from the search.

Using both together, one might use
/M=*.DAT /!M=doofus.dat

which would translate to:
"Include all *.DAT files except the file named 'doofus.dat'"

That's all I have for now. Keep up the great work!
Comperio is offline   Reply With Quote
Old 9th March 2006, 02:17   #31
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Many filters implemented in Locate plugin
Instructor is offline   Reply With Quote
Old 9th March 2006, 02:53   #32
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Thanks for the link, Instructor. Looks exactly what I was looking for!

So tell me, why is this not included with NSIS itself like you've your other functions? (Just curious)
Comperio is offline   Reply With Quote
Old 9th March 2006, 04:34   #33
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Quote:
So tell me, why is this not included with NSIS itself like you've your other functions? (Just curious)
I think this is not my question
Instructor is offline   Reply With Quote
Old 9th March 2006, 14:26   #34
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
OK, I found an odd problem:
I'm using the Locate function from NSIS ver 2.15.

I'm using it to search for all files/directies. I found that if I push two items to the stack, then locate will stop. But, if I just push one item to the stack, it works as expected.

I also noticed that when i push the text "blah" to the stack the 2nd time (instead of "continue"), I get a Windows error.

Here's a short sample showing the error:
code:

name "test"
outfile "test.exe"
!define ROOT "C:\TEMP"
!include FileFunc.nsh
!insertmacro Locate

Page instfiles

Section
${Locate} "${ROOT}" "/L=FD /M=*.* /G=1 /B=0" "AddToList"
SectionEnd

Function AddToList
MessageBox MB_OK "$$R7=$R7"
Push "$R7"
Push "continue" ### if I remove this line, it works fine
FunctionEnd



Is this an NSIS error or a problem with ${locate}?
Comperio is offline   Reply With Quote
Old 9th March 2006, 15:27   #35
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
You can not use NSIS stack in the callback function, because it is used by function. Only one push requered in the callback.

P.S.
You can call another function from the callback, on condition that this function don't change the stack after completion.

Last edited by Instructor; 9th March 2006 at 15:50.
Instructor is offline   Reply With Quote
Old 9th March 2006, 18:42   #36
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
hmmm... I see. I'll have to keep that in mind.

I didn't see this this info in the NSIS manuals. Are you the one that manages those, or do I need to post a separate request on the NSIS sourceforge site?
Comperio is offline   Reply With Quote
Old 9th March 2006, 22:24   #37
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
*sigh*
I may have opened a big can of worms with this. In my example script above, I changed the sample script above to write the file names to a text file instead of pushing to the stack using the command FileWrite $myHandle "$R7$\r$\n". (my hope was to bypass the stack completely and then retrieve the values one at a time later.) Unfortunately, I find that it didn't work, either.

However, using a WriteIniStr command WriteIniStr "$myFileName" "General" "$R7" "" did work, so I guess I have a workaround.

But, I'd still like to understand why the FileWrite did not work. My only guess is that some NSIS functions (like FileWrite) must also use the NSIS stack. Is this correct? (If so, would perhaps using regular variables work better?)
Comperio is offline   Reply With Quote
Old 10th March 2006, 03:00   #38
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
See example in manual "Write results to a text file"

Quote:
My only guess is that some NSIS functions (like FileWrite) must also use the NSIS stack. Is this correct?
FileOpen-FileWrite-FileClose don't use NSIS stack.

Last edited by Instructor; 10th March 2006 at 03:20.
Instructor is offline   Reply With Quote
Old 10th March 2006, 13:37   #39
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Thanks, Instructor. As always, your suggestion worked perfectly!
(I guess I can just chalk this up as a bad day.)
Comperio is offline   Reply With Quote
Old 22nd March 2006, 12:25   #40
Ary Manzana
Guest
 
Posts: n/a
Hi. I test this:

${VersionCompare} "2.3" "2.29" $0

And it tells me that $0 is 2. That means that 2.29 is a higher version than 2.3, which is wrong. Same goes with:

${VersionCompare} "2.29" "2.3" $0

it tells me that $0 is 1.

I'll try to fix it, but I'm a newbie in NSIS...
  Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump