why does this crash?

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

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. 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.

include misc.e
with trace

global function split_file( sequence filename )
integer d, s
sequence out

    out = {"","",""}	-- {path, filename, extension}

    filename = reverse( filename )

    d = find( '.', filename )	-- find the first dot
    s = find( '\\', filename )	-- find the first slash

    out[3] = reverse( filename[1..d] )
    out[2] = reverse( filename[d+1..s] )
	
    if s then
        out[1] = reverse( filename[s..length(filename)] )
    end if
	
    return out
end function	

sequence file1, file2, file3

    --trace(1)
    file1 = split_file("file with no path.exe")
    file2 = split_file("C:\\some path name\\a file with no extension")
    file3 = split_file("C:\\full path info\\path number 2\\correct
filename.ext")
    --trace(0)
	
    pretty_print(1, file1, {2}) puts(1, "\n")
    pretty_print(1, file2, {2}) puts(1, "\n")
    pretty_print(1, file3, {2}) puts(1, "\n")
    ? getc(0)


And here's my ex.err file:

C:\EUPHORIA\projects\test.exw:17 in function split_file() 
slice length is less than 0 (-4) 
    filename = {101'e',120'x',101'e',46'.',104'h',116't',97'a',112'p',32' ',
111'o',110'n',32' ',104'h',116't',105'i',119'w',32' ',101'e',108'l',105'i',
102'f'}
    d = 4
    s = 0
    out = {
            {},
            {},
            {46'.',101'e',120'x',101'e'}
          }

... called from C:\EUPHORIA\projects\test.exw:29 


HELP!
~Greg

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

Search



Quick Links

User menu

Not signed in.

Misc Menu