Announcement

Collapse
No announcement yet.

Variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mel Bishop
    replied
    Not a problem J. Been-there-done-that.

    If you would like to "clean up" your code, try substituting the
    SUB/RETURN with a FUNCTION like the following:

    Function CalcTime(t)
    t = t + 1
    function = t
    end function

    Then in the main body, or other function(s) of your program,
    simply call it with:

    ct = CalcTime(t)
    print;ct;

    or simply

    print;CalcTime(t)


    ------------------




    [This message has been edited by Mel Bishop (edited May 10, 2002).]

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Originally posted by Mel Bishop:
    First, I'm not sure but you don't need to SHARE a variable in
    a sub-routine with RETURN. If it was a SUB or FUNCTION you would
    need to share. Try deleting the 1st line.

    Second, try this:

    Print:
    gosub time ' < == You need to access the sub-routine.
    locate 10,20
    print;m;"Minutes"

    Be sure to separate m and minutes.

    One other thing caught my eye. TIME may be a reserved word. Try
    replacing TIME with CalcTime or something along that line.

    Hope this helps.
    Cheers

    Thanks!!! Using a subroutine to access it did it.

    ------------------

    Leave a comment:


  • Mel Bishop
    replied
    Originally posted by j musielewicz:

    Dim m as shared integer

    Time:
    t=t+1
    m=t
    return

    Print:
    locate 10,20
    print m"Minutes."

    First, I'm not sure but you don't need to SHARE a variable in
    a sub-routine with RETURN. If it was a SUB or FUNCTION you would
    need to share. Try deleting the 1st line.

    Second, try this:

    Print:
    gosub time ' < == You need to access the sub-routine.
    locate 10,20
    print;m;"Minutes"

    Be sure to separate m and minutes.

    One other thing caught my eye. TIME may be a reserved word. Try
    replacing TIME with CalcTime or something along that line.

    Hope this helps.
    Cheers


    ------------------


    [This message has been edited by Mel Bishop (edited May 10, 2002).]

    Leave a comment:


  • Gustavo Asplanatti
    replied
    Your code is not very clear but, you should also declare the variable t like shared.



    ------------------
    Gustavo Asplanatti
    [email protected]

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Variables

    Variables

    I am having trouble accessing a variable from one subroutine
    to another. It looks like this:

    Dim m as shared integer

    Time:
    t=t+1
    m=t
    return

    Print:
    locate 10,20
    print m"Minutes."

    However all it prints is a zero. I have also tried setting m
    to 100 and it still prints zero. What am I doing wrong?
Working...
X