- NSIS Discussion
- Check a string for the letters 'quake2'
Archive: Check a string for the letters 'quake2'
Afrow UK
9th March 2003 13:24 UTC
Check a string for the letters 'quake2'
Is it possible to check whether 'quake2' is in $EXEDIR, or in any variable?
Right now I have this:
ReadINIStr $1 "$TEMP\map-compiler_settings.ini" "Field 7" "State"
StrCmp "$1" "C:\quake2" DirOk
StrCmp "$1" "C:\quake2\" DirOk
StrCmp "$1" "D:\quake2" DirOk
StrCmp "$1" "D:\quake2\" DirOk
StrCmp "$1" "E:\quake2" DirOk
StrCmp "$1" "E:\quake2\" DirOk
StrCmp "$1" "C:\games\quake2" DirOk
StrCmp "$1" "C:\games\quake2\" DirOk
StrCmp "$1" "D:\games\quake2" DirOk
StrCmp "$1" "D:\games\quake2\" DirOk
StrCmp "$1" "E:\games\quake2" DirOk
StrCmp "$1" "E:\games\quake2\" DirOk
StrCmp "$1" "$PROGRAMFILES\quake2" DirOk
MessageBox MB_OK|MB_ICONEXCLAMATION \
"Your current Quake2 directory doesn't contain the letters 'quake2'.$\n \
This will greatly affect Map-Compiling.$\n$\n \
Please change your Quake2 directory structure so that \
it is something like: C:\quake2 or D:\games\quake2.$\n\
If you don't use Quake2, but instead use the Q2Demo or some other \
Quake2 modification, then you will still need to make a new Quake2 \
directory.$\n$\nRead the readme ID: Directory Structures for more \
information."
DirOk:
But it isn't very sufficiant, since the user may have his quake2 directory in e.g. C:\mygames\quake2
Thanks for any help
-Stuart
Joost Verburg
9th March 2003 13:27 UTC
There is a function in the NSIS Archive at http://nsis.sf.net
Sunjammer
9th March 2003 13:44 UTC
More specifically there is a set of useful string related functions in the archive here. The particular function that I think Joost is referring to is StrStr which was actually taken from Appendix B of the NSIS documentation!
Afrow UK
9th March 2003 14:24 UTC
Works great thanks
Lol the submit reply buttons gone somewhere ---->
-Stuart
Afrow UK
9th March 2003 15:42 UTC
I have another part to my program that I can't do...
The user enters a path line...
C:\program files\dday
I need to rename 'dday' to 'quake2' thats easy.
After installation, I need it to rename it back to dday...
C:\program files\quake2 -> C:\program files\dday
Note that the user may enter anything as the path. I used C:\program files\dday as an example.
How can this be done?
-Stuart
kichik
9th March 2003 17:13 UTC
Write whatever you have changed to the registry, an INI file or just a regular file and read that file/registry key when you finish installation. If it's in the same installer you can also save that in a variable.
Afrow UK
9th March 2003 19:31 UTC
I shall explain in more detail.
The user enters the target directory for their quake2 game, which in one case may be...
C:\games\q2demo
To compile maps, the q2demo directory must be 'quake2' not 'q2demo'
I need it to rename the 'q2demo' directory to 'quake2'
When it has finished, I need to rename C:\games\quake2 back to C:\games\q2demo, so that the user knows his q2demo still exists.
The user may not enter C:\games\q2demo
He may enter C:\games\dday, C:\program files\q2demo, C:\program files\dday or even C:\007q2
The reason I don't know how to do this is because
1. First of all $1 is the quake2 directory that the user has entered
2. It gets renamed... e.g C:\games\q2demo -> C:\games\quake2
3. After that I get stuck. I can't rename it back because it's not C:\games\q2demo anymore, but its now C:\games\quake2
I can't do a Rename command, because I don't know what the renamed directory structure is. It could be apsolutly anything.
Is that enough detail to show you my problem?
-Stuart
kichik
9th March 2003 19:46 UTC
No. What's wrong with saving $1 somewhere?
Afrow UK
9th March 2003 20:55 UTC
Yes, thats what have done.
$1 = eg. C:\games\q2demo
Rename $1 quake2
C:\games\q2demo is now C:\games\quake2
After install...
Then what!!
I need to get the q2demo bit of it (last piece after the \) and then I can rename
kichik
9th March 2003 20:56 UTC
Use GetParent from the useful functions appendix to get that off.
Afrow UK
9th March 2003 21:09 UTC
Thanx dude!!!
:)
-Stu