Computer Science Canada

help, pls sos

Author:  hey_joe42 [ Sun Mar 23, 2003 9:38 pm ]
Post subject:  help, pls sos

there is some type of problem with my scroll bar in my gui
lets say you already had it view the items, k then you go to view something else, and when u do, you click on the scroll bar to scroll down, instead of scrolling down on the requested items, it reverts to the first items it displayed in other words its not resetting
code:
body procedure guilishious (produ : string, manu : string)
    View.Set ("graphics:650;400")             % Enlarge the window to the maximum size
    % The Text Field IDs
    var textBox : int
    % The label for the title
    var title : int
    % The name of the file to be viewed
    const fileNameToBeViewed : string := "inventory.bin"
    % Attempt to open the file.  Put an error message if open fails
    var f : int
    open : f, fileNameToBeViewed, read
    if f = 0 then
        put "Unable to open '" + fileNameToBeViewed + "' : ", Error.LastMsg
        return
    end if
    % We opened the file successfully.  Now create the widgets.
    GUI.SetBackgroundColour (grey)
    % Create the title label
    title := GUI.CreateLabelFull (20, 280, fileNameToBeViewed, 250, 0,
        GUI.CENTER, 0)
    % Create the text box
    textBox := GUI.CreateTextBoxFull (10, 10, 630, 365, GUI.INDENT, 0)
    % Read the file and place it in the text box.
    var line : string
    line := "Title  Manufact Price  #in stock  warning #  #to order  product # Category  Sale"
    GUI.AddLine (textBox, line)
    loop
        exit when eof (f)
        read : f, prod
        if produ = manu then
            line := prod.product + "   |   " + prod.manufacturer + "   |   $" + realstr (prod.price, 6) + "   |  " + intstr (prod.number) + "  |  " + intstr (prod.reorder) + " | " +
                intstr (prod.numinstock) + " | " + prod.prodnumber + " | " + prod.cater + " | " + prod.sale
            GUI.AddLine (textBox, line)
        end if
    end loop
    close : f             % Close the file
    % Process Events
    var mx, my, mbtn : int
    var font1 : int
    font1 := Font.New ("Arial:10")
    drawfillbox (20, 380, 59, 395, 35)
    Font.Draw ("BACK", 22, 382, font1, 0)
    loop
        if buttonmoved ("down") then
            buttonwait ("down", mx, my, mbtn, mbtn)
            if mbtn = 1 then
                if mx > 20 and mx < 59 and my > 380 and my < 395 then
                    cls
                     displayinfo
                end if
            end if
        end if
        exit when GUI.ProcessEvent
    end loop
end guilishious
%GUI display for all the files in the record
body proc _display
    View.Set ("graphics:650;400")             % Enlarge the window to the maximum size
    % The Text Field IDs
    var textBox : int
    % The label for the title
    var title : int
    % The name of the file to be viewed
    const fileNameToBeViewed : string := "inventory.bin"
    % Attempt to open the file.  Put an error message if open fails
    var f : int
    open : f, fileNameToBeViewed, read
    if f = 0 then
        put "Unable to open '" + fileNameToBeViewed + "' : ", Error.LastMsg
        return
    end if
    % We opened the file successfully.  Now create the widgets.
    GUI.SetBackgroundColour (grey)
    % Create the title label
    title := GUI.CreateLabelFull (20, 280, fileNameToBeViewed, 250, 0,
        GUI.CENTER, 0)
    % Create the text box
    textBox := GUI.CreateTextBoxFull (10, 10, 630, 365, GUI.INDENT, 0)
    % Read the file and place it in the text box.
    var line : string
    line := "Title  Manufact Price  #in stock  warning #  #to order  product # Category  Sale"
    GUI.AddLine (textBox, line)
    loop
        exit when eof (f)
        read : f, prod
        line := prod.product + "   |   " + prod.manufacturer + "   |   $" + realstr (prod.price, 6) + "   |  " + intstr (prod.number) + "  |  " + intstr (prod.reorder) + " | " +
            intstr (prod.numinstock) + " | " + prod.prodnumber + " | " + prod.cater + " | " + prod.sale
        GUI.AddLine (textBox, line)
    end loop
    % Process Events
    var mx, my, mbtn : int
    var font1 : int
    font1 := Font.New ("Arial:10")
    drawfillbox (20, 380, 59, 395, 35)
    Font.Draw ("BACK", 22, 382, font1, 0)
    loop
        if buttonmoved ("down") then
            buttonwait ("down", mx, my, mbtn, mbtn)
            if mbtn = 1 then
                if mx > 20 and mx < 59 and my > 380 and my < 395 then
                    cls
                    close : f             % Close the file
                    exit
                end if
            end if
        end if
        exit when GUI.ProcessEvent
    end loop

end _display

Here also is the program

Author:  Tony [ Mon Mar 24, 2003 5:27 pm ]
Post subject: 

so you need to rest the textbox?

why not set its value to NULL before writing a new set of data to it?

Though I'm not sure how GUI works in turing... Confused

Author:  hey_joe42 [ Mon Mar 24, 2003 5:32 pm ]
Post subject:  new discovery

i have figured out a little more about my program, seethe scroll bar is located in the GUI.CreateTextField
so therefore, well i tried using GUI.Dispose, cuz i want it be like your using it the first time everytime, but it seems to reload memory from its first loading, when you click on the scroll bars
comeon someone here is a gui expert how do i have it so it clears all data in the gui scrollbars stuff

Author:  Asok [ Mon Mar 24, 2003 5:41 pm ]
Post subject: 

sorry, I too don't use GUI much, I preffer to create my interfaces from scratch, plus grey is ugly Wink

Author:  Tony [ Mon Mar 24, 2003 5:44 pm ]
Post subject: 

seriosly... if you want control, just go lookup how they programmed their textboxes (open up GUI module and look up textbox procedure).

understand how it functions then program your own Very Happy

not only will it look better... it will have more functionality too

Author:  hey_joe42 [ Mon Mar 24, 2003 6:51 pm ]
Post subject: 

lol yeah i agree, but im trying to get some bonus marks for incorpating GUI
we should have a segment so we can get ideas on how to Create your own interfaces, similiar to gui, cuz that would be a good section

anyways i solved my problem just put GUI.Dispose(textBox) in there before i exited to the main menu
knew it was something simple

Author:  azndragon [ Mon Mar 24, 2003 10:02 pm ]
Post subject: 

I gave up on the GUI cause it's not that great in Turing. Just wondering, how would you view the GUI module? And how would you go about to make your own module, or better yet, can someone write a tutorial on modules? Very Happy

Author:  Blade [ Mon Mar 24, 2003 10:09 pm ]
Post subject: 

lol, i looked at the gui.... copied some code, and tried to make sense of it... but it just wasnt working... and as azndragon said, its not that great... so i gave up on it also... if you have turing 4.x theres a module list with GUI in it that explains a great deal of it and what each does... take a look in there


: