Re: why does this crash?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 2 Oct 2004, at 21:20, Derek Parnell wrote:

> 
> 
> posted by: Derek Parnell <ddparnell at bigpond.com>
> 
> Greg Haberek wrote:
> > 
> > Maybe its late, maybe I'm just too tired... I don't know whats wrong
> > with this code. I have *no idea* why this is crashing. 
> 
> Because the first file you test does not have a slash in it. Thus 's'
> is set to zero, and 'd' is set to 4, the location of the dot.
> 
> This means that 'filename[d+1..s]' resolves to 'filename[5..0]' which
> is not a valid slice. 
> 
> > Last time I
> > checked, d+1 = 5, not -4. Anyway, here's the code. Someone please test
> > it and tell me what I may or may not be doing wrong.
> 
> The length of the slice is calculated as ...
> 
>   end - start + 1
> 
> substituting the values in your code, we get ...
> 
>    0 - 5 + 1 = -4
> 
> Hope that helps.
> 
> By the way, you code might do better with ...
> 
>     if s then
>         out[2] = reverse( filename[d+1..s] )
>         out[1] = reverse( filename[s..length(filename)] )
>     else
>         out[2] = reverse( filename[d+1 .. length(filename)]
>         out[1] = ""
>     end if
> -- 
> Derek Parnell
> Melbourne, Australia

If the next step is to save the file in the form of the url, see:
http://www.tiggrbox.info/program/createdir.html

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu