"Unexpected Syntax Error" using mod

Discussion in 'Programming' started by Vallyrie, Jun 16, 2018.

Tags:
  1. Vallyrie

    Vallyrie Member

    Joined:
    Jun 14, 2018
    Posts:
    8
    Hi everybody,

    I'm trying to create an on-screen stopwatch, and I have an error coming up when I try to use "mod." Here's the line of code with the error:

    s = s mod (rs*60);

    All it tells me is that there's an unexpected syntax error. Does anyone know what's wrong?

    Thanks in advance!
     
  2. Carl Nylander

    Carl Nylander Member

    Joined:
    Jul 21, 2016
    Posts:
    212
    I guess you get it when rs is 0?
     
  3. Vallyrie

    Vallyrie Member

    Joined:
    Jun 14, 2018
    Posts:
    8

    rs is equal to the room speed
     
  4. Paskaler

    Paskaler Member

    Joined:
    Jul 4, 2016
    Posts:
    315
    The syntax checker may be highlighting the wrong line(it happens).
    Please post all of the surrounding code as well.
     
  5. Vallyrie

    Vallyrie Member

    Joined:
    Jun 14, 2018
    Posts:
    8
    Here's the create event:

    rs = room_speed;

    s = 0; //seconds
    m = 0; //minutes
    h = 0; //hours

    Here's the draw event:

    s += 1;

    s = s mod (rs*60);

    if (s == 0) {

    m+= 1;

    }

    if(m > 59){

    h+=1;

    }

    //draw
    draw_set_font(font0);
    draw_set_color(c_black);

    if (m < 10){

    draw_text(50, 50, string("0") + string(h) + string(":0") + string(m) + string(":") + string(s/rs));

    } else{

    draw_text(50, 50, string("0") + string(h) + string(":") + string(m) + string(":") + string(s/rs));

    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice