Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
strings initialized?
Yesterday I experienced a kind of coding poltergeist with the following simple function:

function strings(times as ubyte, text as string ) as string

    dim i as ubyte
    dim result as string
    for i = 1 to times
        let result = result + text
    next i
    return result

end function

The program did strange things when printing the string returned by strings(): it printed other strings of the program that had nothing to do, and then froze. The reason was I had supposed the DIMed strings were initialized to an empty string but they are not; it took time to find out. When I added a simple line, everything worked as expected:

    dim result as string
    let result = ""

I've searched in the forum, but found no reference about this. The DIM wiki page doesn't mention string initialitazion. I just want to confirm this issue before updating the wiki. Are strings not initialized to empty strings because of a technical issue or simply because it's not implemented yet? Is this definitive or will it change in the future?

Messages In This Thread

Forum Jump:

Users browsing this thread: 1 Guest(s)