Results 1 to 4 of 4

Thread: Variables

  1. #1
    Join Date
    Mar 2008
    Location
    In a cave
    Posts
    345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Variables

    This is what I have:
    SCAR Code:
    function Walk(Road: boolean; Col, SRad, ERad, Rad: integer): boolean;
    begin
      Result := True;
      if not FindColor(x, y, Col, MMX1, MMY1, MMX2, MMY2) then
      begin
        Result := False;
        if Road then Col := FindRoadColor;
        else Col := FindFallyRoadColor;
      end;
      RadialRoadWalk(Col, SRad, ERad, Rad, 3, 3);
    end;

    procedure Walking;
    var
    RCol, FallyRCol: integer;
    begin
      FallyRCol := FindFallyRoadColor;
      ---some walking stuff here between---
      Walk(False, FallyRCol, 200, 230, 65);
      ---some more to come---
    end;

    Now the question: Will function Walk change the variable FallyRCol in proc Walking if the color has changed or do I have to change it in proc Walking too if I want it to be updated there?
    A Chinese wiseman once said: "Shu ciu!", it was considered very smart, but now people know it means: "Something stinks here!"
    FalBuggySmelter v.1.31
    [Updated on the 1st of March 2010]
    RimmBugger BETA V1.8

  2. #2
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    No it wont, make a global variable and assign stuff from walk to it. That way it can be used through the script.

    Right now its static and only usable in that procedure.
    I do visit every 2-6 months

  3. #3
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    If you want to do what you want to do, then put 'var Col: Integer' and it will update the variable put in rather than a local copy.
    So, the declaration would look like:
    function Walk(Road: boolean; var Col: Integer; SRad, ERad, Rad: integer): boolean;
    but, it is normally displayed with any var arguments first, so the common way of declaring would be
    function Walk(var Col: Integer; Road: boolean; SRad, ERad, Rad: integer): boolean;
    Also, it's important you split Col from the other integer variables otherwise it will treat them all like that, which means you have to supply variables to it rather than just a numeric argument.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  4. #4
    Join Date
    Mar 2008
    Location
    In a cave
    Posts
    345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @Zasz: I don't want it to be a global...

    @mixster: Thanks. Exactly what I needed
    A Chinese wiseman once said: "Shu ciu!", it was considered very smart, but now people know it means: "Something stinks here!"
    FalBuggySmelter v.1.31
    [Updated on the 1st of March 2010]
    RimmBugger BETA V1.8

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •