[REBOL] filepath and slash problem
From: sabufrancis::rediffmail::com at: 15-Jul-2007 20:41
Hi Rebol gurus
I would appreciate the answer to the following mystery. I wracked my
brains for the last 5 hours .... and narrowed my problem down to this...
I am trying to do what is otherwise a really simple thing.... which is
to convert some slashes and dots in file paths into "-" (After spending
5 hours, I think I can get a work around for it, by extracting the
components of the path, but having wasted so much time; I really want to
know why this caused a problem:
*Scenario 1*
tempSeparator: "-"
comlist: [1 'TestEdu/Test.txt 2 'TestEdu/Hello.text]
forskip comlist 2 [
fnm: second comlist
print [ "type: " type? fnm "First: " fnm/1 " Sec: " fnm/2]
mfnm: copy to-string fnm
print ["After conversion: " fnm]
;;;step aaa
mfnm: replace/all mfnm "/" tempSeparator
mfnm: replace/all mfnm "." tempSeparator
print mfnm
]
*The results of above are:*
>>type: path First: TestEdu Sec: Test.txt
After conversion: TestEdu/Test.txt
TestEduTest-txt
type: path First: TestEdu Sec: Hello.text
After conversion: TestEdu/Hello.text
TestEduHello-text
/Notice that it gobbled up the slash/
on the other hand, if I directly give step aaa manually using a string
then it works fine
tempSeparator: "-"
mfnm: "TestEdu/Test.txt"
mfnm: replace/all mfnm "/" tempSeparator
mfnm: replace/all mfnm "." tempSeparator
print mfnm
*The results of above is: *
>>TestEdu-Test-txt
What gives?
Regards
Sabu Francis