Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 GUI feild select problems
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ambiguities




PostPosted: Wed Mar 11, 2009 4:50 pm   Post subject: GUI feild select problems

I'm trying to have fields added into a GUI box with recursion from a tree but it only enters the first variable. can you see what i did wrong?

i think it might be the way i'm trying to read it


code:
procedure showtreefull (crp : ^student)

    var x : int := GUI.CreateTextBoxChoice (20, 20, 200, 100, 0, 0, ChoseLine)

    if crp -> ltp not= nil then
        showtreefull (crp -> ltp)
    end if

    GUI.AddLine (x, (crp -> lname + ", " + crp -> fname))

    if crp -> gtp not= nil then
        showtreefull (crp -> gtp)
    end if
end showtreefull
[/code]
Sponsor
Sponsor
Sponsor
sponsor
corriep




PostPosted: Wed Mar 11, 2009 5:06 pm   Post subject: RE:GUI feild select problems

You have to create to text box before you call the recursive procedure. Right now you are creating a new text box on every recurse.
Ambiguities




PostPosted: Wed Mar 11, 2009 5:12 pm   Post subject: Re: GUI feild select problems

i reviewed the code removed the creation of the gui box and it wont display any other tree segments... my brain is so tired lol

code:
procedure addtotree (var locptr, crp : ^student)

    if root = nil then
        root := crp
    end if
    if crp -> lname > locptr -> lname then
        if locptr -> gtp not= nil then
            addtotree (locptr -> gtp, crp)
        else
            locptr -> gtp := crp
        end if
    elsif crp -> lname < locptr -> lname then
        if locptr -> ltp not= nil then
            addtotree (locptr -> ltp, crp)
        else
            locptr -> ltp := crp
        end if
    end if
end addtotree


it doesn't error but yet again it doesn't seem to properly work any ideas?
corriep




PostPosted: Wed Mar 11, 2009 5:25 pm   Post subject: Re: GUI feild select problems

Turing:
procedure showtreefull (crp : ^student)
    % This line is being called on every recurse, creating many boxes all in the same spot
    % var x : int := GUI.CreateTextBoxChoice (20, 20, 200, 100, 0, 0, ChoseLine)

    if crp -> ltp not= nil then
        showtreefull (crp -> ltp)
    end if

    GUI.AddLine (x, (crp -> lname + ", " + crp -> fname))

    if crp -> gtp not= nil then
        showtreefull (crp -> gtp)
    end if
end showtreefull

% If we move it here, the textbox is created once and the lines added
% in the showtreefull procedure will be added to it
var x : int := GUI.CreateTextBoxChoice (20, 20, 200, 100, 0, 0, ChoseLine)
showtreefull (foo)


Btw, remember syntax tags Wink
Quote:
[syntax="Turing]
code here
[/syntax]
Tony




PostPosted: Wed Mar 11, 2009 5:27 pm   Post subject: RE:GUI feild select problems

The reference to textbox should probably be passed to the function, instead of being decleared globally; though either way the point is to have exactly 1 instance of the GUI element.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Ambiguities




PostPosted: Wed Mar 11, 2009 8:24 pm   Post subject: Re: GUI feild select problems

Thanks Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: