mIRC Home    About    Download    Register    News    Help

Print Thread
#97428 12/09/04 06:46 PM
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
im using a hash table to run and list dirs
but if the dir has a space in it
it doesnt work
it says it has: invalid parameters
this is what i use to get my dirs to run or browse them
$hget(files/folders,$replace($1-,$chr(32),$chr(1)))
they are wrote like:
C:\filefolder\
if u was wondering why i used $replace
and when it trys to run the dir it would look like:
C:\file folder\
any way
can you help to solve this problem?

thanks alot


Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
What is your problem, your replacing a space with $chr(1), not the best choice but theres nothing wrong with it.

Personally, I'd haved used $chr(160) since it is a "hard space".

Eamonn.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Using $chr(1) is better than using $chr(160) because $chr(160) can appear in a file/folder name and could therefore be part of the original filepath, whereas $chr(1) could not.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
I'm not entirely sure of your question/problem. If the hash table item names are the directories then you would have to replace spaces with something like $chr(1) since /hadd cannot add item names with spaces in, and then of course you'd have to do the same when trying to access that item by name.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
sorry i wasnt clear enough,
i mean
in the hash table it would have $chr(1)
but the actual folder will be a regular space
so for example when i type
/hadd bla bla $sdir(c:)
the folder i select for example:
c:\mirc files\
i would replace it in the hash table with $chr(1) for $chr(32)
then when i want to recall the dir i replace
the $chr(1) with $chr(32)
so it returns exactly the same as c:\mirc files
but when i try and run the returned format it doesnt work

hope you understood that and can help
thanks alot



Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
True, Windows does allow you to use, $chr(160) in a filename, no-one would use it purely because a filename is made up of the characters "typeable" on your keyboard and since, $chr(160) requires you to either copy/paste it into the filename, or use ALT+160 it is unlikely to appear, anywhere.

However, it was purely a personal preference, I wouldnt use $chr(1) in that way.

Eamonn.

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
im not trying to rename my files with different charecters
i want it to work if it has spaces in the folder name
i just transform the charecters becauses of my hash table
it works fine if the directory is C:\
and doesnt need to change charecters but when there is
a space in the dir: C:\mIRC Files\
It wont work and gives me an error
so can you please help with that,

thanks you very much
wink

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well if the directory name is the value of the item and not the item name then there is no need to replace spaces with anything, however if you still want to then just use $replace($hget(files/folders,$1-),$chr(1),$chr(32))


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
That depends on your keyboard layout and charset and goes on the assumption that all filenames are hand-typed, whereas of course there are plenty of situations where filenames are created by programs and might contain any possible characters. A control code like $chr(1) is an obvious choice of a character that will never be present in a filepath and which is easily recognizable as such to someone browsing the code.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
the problem is,
value of $1- is the folder
so if the folder was C:\mIRC Files\
$1- would have the $chr(1) not the folder
e.g
table: files/folders
item:ListScripts
Item Value: C:\mIRC Files\
so $1- would be a trigger so when i type
List Scripts
it replaces the space with 
then gets the value which is C:\mIRC Files\
and the script actually lists all the .mrc extension files in the dir
but because of this problem i cant get the dir to even run
so if you could just help me use /run to make this work
i would be really gratefull

sorry for the bad explaining before
and thanks alot for your help
i hope you could understand from that

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well from what you've described it should be working correctly, I think you must have a bug in what you're replacing when you add the item in the first place.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
ok,
seems like the alias i made for listing files
doesnt work if the dir has a space in the filename

thanks for the help
wink

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
i figured it out by putting " "
in the path to file ("C:\mIRC Files\")
wink


Link Copied to Clipboard