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

Username:   Password: 
 RegisterRegister   
 'Show Variables'
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jekate




PostPosted: Mon Sep 25, 2006 8:22 pm   Post subject: 'Show Variables'

How do I get the 'Show Variables' button, able to be checked in 4.0.5? It would help so much right now because I can't figure out why my program isn't working and know what the variables values are would help out a bunch.
Sponsor
Sponsor
Sponsor
sponsor
Jekate




PostPosted: Mon Sep 25, 2006 8:49 pm   Post subject: (No subject)

Ok, I got the program working, but I'd still like to know how to get 'Show Variables' to work.

Anyways, here is the program. I know, I probably used too much and there are probably ways that I could simplify it. But, I don't really know how. Any suggestions?

code:
var x1, x2, xc1, xc2, y1, y2, yc1, yc2, colchange, colchange2, colchange3 : int
var col, col2, col3 : real


colchange := 0
colchange2 := 2
colchange3 := 2
x1 := 0
x2 := maxx
xc1 := 0
xc2 := 2
y1 := 0
y2 := maxy
yc1 := 1
yc2 := 1
col := 0
col2 := 0
col3 := 0


loop
    if colchange2 = 2 and colchange3 = 2 then
        if colchange = 0 then
            col := col + 0.01
        elsif colchange = 1 then
            col := col - 0.01
        elsif colchange = 2 then
            col := col
        end if
        if col >= 1 and col < 2 then
            colchange := 1
        elsif col <= 0 then
            colchange := 2
            colchange2 := 0
        end if
    end if
    if colchange = 2 and colchange3 = 2 then
        if colchange2 = 0 then
            col2 := col2 + 0.01
        elsif colchange2 = 1 then
            col2 := col2 - 0.01
        elsif colchange2 = 2 then
            col2 := col2
        end if
        if col2 >= 1 and col2 < 2 then
            colchange2 := 1
        elsif col2 <= 0 then
            colchange2 := 2
            colchange3 := 0
        end if
    end if
    if colchange = 2 and colchange2 = 2 then
        if colchange3 = 0 then
            col3 := col3 + 0.01
        elsif colchange3 = 1 then
            col3 := col3 - 0.01
        elsif colchange3 = 2 then
            col3 := col3
        end if
        if col3 >= 1 and col3 < 2 then
            colchange3 := 1
        elsif col3 <= 0 then
            colchange3 := 2
            colchange := 0
        end if
    end if



    if x1 = 0 and y1 = 0 then
        xc1 := 0
        yc1 := 1
    elsif x1 = maxx and y1 = 0 then
        xc1 := 1
        yc1 := 0
    elsif x1 = maxx and y1 = maxy then
        xc1 := 2
        yc1 := 1
    elsif x1 = 0 and y1 = maxy then
        xc1 := 1
        yc1 := 2
    end if

    if x2 = 0 and y2 = 0 then
        xc2 := 0
        yc2 := 1
    elsif x2 = maxx and y2 = 0 then
        xc2 := 1
        yc2 := 0
    elsif x2 = maxx and y2 = maxy then
        xc2 := 2
        yc2 := 1
    elsif x2 = 0 and y2 = maxy then
        xc2 := 1
        yc2 := 2
    end if

    if xc1 = 0 then
        x1 := x1 + 1
    elsif xc1 = 1 then
        x1 := x1
    elsif xc1 = 2 then
        x1 := x1 - 1
    end if
    if xc2 = 0 then
        x2 := x2 + 1
    elsif xc2 = 1 then
        x2 := x2
    elsif xc2 = 2 then
        x2 := x2 - 1
    end if

    if yc1 = 0 then
        y1 := y1 + 1
    elsif yc1 = 1 then
        y1 := y1
    elsif yc1 = 2 then
        y1 := y1 - 1
    end if
    if yc2 = 0 then
        y2 := y2 + 1
    elsif yc2 = 1 then
        y2 := y2
    elsif yc2 = 2 then
        y2 := y2 - 1
    end if

    RGB.SetColour (1, col, col2, col3)
    drawline (x1, y1, x2, y2, 1)
    delay (20)
end loop
Silent Avenger




PostPosted: Mon Sep 25, 2006 8:58 pm   Post subject: (No subject)

Well I usually don't do much turing programming and what I do is really noobish but couldn't you output the variables to the run form? or have it output to something like a message box?
Jekate




PostPosted: Mon Sep 25, 2006 9:14 pm   Post subject: (No subject)

Well, I remember from 3.x you could check a box that called up another window that had all the variables and their values. It was really useful, but I can't seem to get it so it is checkable in 4.0.5. I could output the variables in the run screen, but if the screen was black at any times I needed it the text wouldn't be readable.
Silent Avenger




PostPosted: Mon Sep 25, 2006 9:29 pm   Post subject: (No subject)

Well couldn't you temporarly change the background to white so you can see what the variables are or is the background controled by one of the variables you need to check?
Clayton




PostPosted: Tue Sep 26, 2006 7:14 am   Post subject: (No subject)

i dont think that checking a 'Show Variables' box is a viable opion in 4.0.5, so the best you can do is make your own, use a little intuitiveness and read up on windows and you could be on your way to solving your problem Razz
Cervantes




PostPosted: Tue Sep 26, 2006 8:49 am   Post subject: (No subject)

Using windows would be the way to go. However, I'll point this out:
Jekate wrote:
I could output the variables in the run screen, but if the screen was black at any times I needed it the text wouldn't be readable.

You can just change the colour of the outputted text.
code:

colourback (black)
cls
colour (white)
put "Hello world"

That will output Hello world in white text on a black background.
Jekate




PostPosted: Tue Sep 26, 2006 4:09 pm   Post subject: (No subject)

Well, it looks like this:

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Now I can't seem to get it to be checkable, so I may have to create my own window.
Sponsor
Sponsor
Sponsor
sponsor
Jekate




PostPosted: Sat Sep 30, 2006 8:43 am   Post subject: (No subject)

Well I finished it, and here it is:

code:
var x1, x2, xc1, xc2, y1, y2, yc1, yc2, colchange, colchange2, colchange3 : int
var col, col2, col3 : real
View.Set ("graphics:max;max")

colchange := 0
colchange2 := 2
colchange3 := 2
x1 := 0
x2 := maxx
xc1 := 0
xc2 := 2
y1 := 0
y2 := maxy
yc1 := 1
yc2 := 1
col := 0
col2 := 0
col3 := 0

loop
    if colchange2 = 2 and colchange3 = 2 then
        if colchange = 0 then
            col := col + 0.01
        elsif colchange = 1 then
            col := col - 0.01
        elsif colchange = 2 then
            col := col
        end if
        if col >= 1 and col < 2 then
            colchange := 1
        elsif col <= 0 then
            colchange := 2
            colchange2 := 0
        end if
    end if
    if colchange = 2 and colchange3 = 2 then
        if colchange2 = 0 then
            col2 := col2 + 0.01
        elsif colchange2 = 1 then
            col2 := col2 - 0.01
        elsif colchange2 = 2 then
            col2 := col2
        end if
        if col2 >= 1 and col2 < 2 then
            colchange2 := 1
        elsif col2 <= 0 then
            colchange2 := 2
            colchange3 := 0
        end if
    end if
    if colchange = 2 and colchange2 = 2 then
        if colchange3 = 0 then
            col3 := col3 + 0.01
        elsif colchange3 = 1 then
            col3 := col3 - 0.01
        elsif colchange3 = 2 then
            col3 := col3
        end if
        if col3 >= 1 and col3 < 2 then
            colchange3 := 1
        elsif col3 <= 0 then
            colchange3 := 2
            colchange := 0
        end if
    end if

    if x1 = 0 and y1 = 0 then
        xc1 := 0
        yc1 := 1
    elsif x1 = maxx and y1 = 0 then
        xc1 := 1
        yc1 := 0
    elsif x1 = maxx and y1 = maxy then
        xc1 := 2
        yc1 := 1
    elsif x1 = 0 and y1 = maxy then
        xc1 := 1
        yc1 := 2
    end if

    if x2 = 0 and y2 = 0 then
        xc2 := 0
        yc2 := 1
    elsif x2 = maxx and y2 = 0 then
        xc2 := 1
        yc2 := 0
    elsif x2 = maxx and y2 = maxy then
        xc2 := 2
        yc2 := 1
    elsif x2 = 0 and y2 = maxy then
        xc2 := 1
        yc2 := 2
    end if

    if xc1 = 0 then
        x1 := x1 + 1
    elsif xc1 = 1 then
        x1 := x1
    elsif xc1 = 2 then
        x1 := x1 - 1
    end if
    if xc2 = 0 then
        x2 := x2 + 1
    elsif xc2 = 1 then
        x2 := x2
    elsif xc2 = 2 then
        x2 := x2 - 1
    end if

    if yc1 = 0 then
        y1 := y1 + 1
    elsif yc1 = 1 then
        y1 := y1
    elsif yc1 = 2 then
        y1 := y1 - 1
    end if
    if yc2 = 0 then
        y2 := y2 + 1
    elsif yc2 = 1 then
        y2 := y2
    elsif yc2 = 2 then
        y2 := y2 - 1
    end if

    RGB.SetColour (1, col, col2, col3)
    drawline (x1, y1, x2, y2, 1)
    delay (2)
end loop
wtd




PostPosted: Sun Oct 01, 2006 12:51 pm   Post subject: (No subject)

Ultimately the most helpful thing for you is going to be breaking your program down into a series of smaller sub-programs (functions/procedures) which accomplish smaller, more focused goals, and communicate with one another via parameters/arguments.

That you are not instructed in the use of such tools at an earlier stage is unfortunate, but you should correct this yourself by researching functions and procedures, and how they can help you write more structured programs.

Tony's tutorial on the subject:

http://www.compsci.ca/v2/viewtopic.php?t=407
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  [ 10 Posts ]
Jump to:   


Style:  
Search: