Computer Science Canada

Local Variables That Give a Value to an Array and the Size

Author:  TheXploder [ Wed Jan 28, 2004 12:33 pm ]
Post subject:  Local Variables That Give a Value to an Array and the Size

I'm trying to make a check for words, and with each same procedure check different words and enable bigger arrays:

code:

proc words (size : int, name1, name2 : string)
    var word : array 1 .. size of string := init (name1, name2)
    for i : 1 .. size
        if word (i) = "Xploder" then
            put "Name matches!"
        else
            put "Name doesn't match!"
        end if
    end for
end words

words (2, "Xploder", "TheXploder")
words (3, "Cool", "Uncool", "TheXploder")


It doesn't seem to work quite right... hope you get where I am going with this, could you please hlep me out...

Author:  TheXploder [ Wed Jan 28, 2004 12:49 pm ]
Post subject: 

ohh, fixed it:

code:

proc words (size : int, name1, name2 : string)
    var word : array 1 .. size of string
    word (1) := name1
    word (2) := name2
    for i : 1 .. size
        if word (i) = "Xploder" then
            put "Name matches!"
        else
            put "Name doesn't match!"
        end if
    end for
end words

words (2, "Xploder", "TheXploder")

Author:  Paul [ Wed Jan 28, 2004 12:53 pm ]
Post subject: 

Yay! way to go self-help...

Author:  we64 [ Wed Jan 28, 2004 1:47 pm ]
Post subject: 

Very Happy Very Happy yeah good job


: