Results 1 to 13 of 13

Thread: Problem with type record

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Problem with type record

    SCAR Code:
    type
      TLocation = record
        MultiCombat, Banking: boolean;
        LocToBank, BankToLoc: function(where: string): boolean;
        Bank: string;
      end;

    function WalkTo(where: string): boolean; forward;

    function InitLocation(Where: string): TLocation;
    var
      s: string;
    begin
      s := lowercase(Where);
      case s of
         
        'eastvarrock':
          with result do
          begin
            MultiCombat := false;
            Banking := true;
            Bank := 'veb';
            BankToLoc := @WalkTo('vebtoguards'); //LINE 107
            LocToBank := @WalkTo('guardstoveb');
          end;
         
      end;
    end;

    This gives me
    Line 107: [Error] (20047:21): Identifier expected in script.

    How can i make this work?
    Last edited by marpis; 07-25-2009 at 08:07 PM.

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    You need to put a:
    SCAR Code:
    Type

    before you make a record

    So
    SCAR Code:
    Type
      Tlocation = record; //e.t.c

    EDIT: Good Job on using Pointers

  3. #3
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    You need to put a:
    SCAR Code:
    Type

    before you make a record

    So
    SCAR Code:
    Type
      Tlocation = record; //e.t.c

    EDIT: Good Job on using Pointers
    that was just cut off my paste ^^ i have the Type there

  4. #4
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    that was just cut off my paste ^^ i have the Type there
    Well, you should have posted the whole script -_-.

  5. #5
    Join Date
    Aug 2008
    Location
    !!LOL!!
    Posts
    247
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i think there is an extra end to the script maybe i am wrong

  6. #6
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

    Default

    SCAR Code:
    type
      TLocation = record
        MultiCombat, Banking: boolean;
        LocToBank, BankToLoc: function(where: string): boolean;
        Bank: string;
      end;

    function WalkTo(where: string): boolean; forward;

    function InitLocation(Where: string): TLocation;
    var
      s: string;
    begin
      s := lowercase(Where);
      case s of
         
        'eastvarrock':
          with result do
          begin
            MultiCombat := false;
            Banking := true;
            Bank := 'veb';
            BankToLoc := WalkTo('vebtoguards'); //LINE 107
            LocToBank := WalkTo('guardstoveb');
          end;
         
      end;
    end;
    ? xD

  7. #7
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by BobboHobbo View Post
    SCAR Code:
    type
      TLocation = record
        MultiCombat, Banking: boolean;
        LocToBank, BankToLoc: function(where: string): boolean;
        Bank: string;
      end;

    function WalkTo(where: string): boolean; forward;

    function InitLocation(Where: string): TLocation;
    var
      s: string;
    begin
      s := lowercase(Where);
      case s of
         
        'eastvarrock':
          with result do
          begin
            MultiCombat := false;
            Banking := true;
            Bank := 'veb';
            BankToLoc := WalkTo('vebtoguards'); //LINE 107
            LocToBank := WalkTo('guardstoveb');
          end;
         
      end;
    end;
    ? xD
    No, it's a pointer do it needs a '@' at the beginning

  8. #8
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Posting this for Da 0wner: Add his MSN if you need any further help: kylewallaston@hotmail.com

    SCAR Code:
    type
      TLocation = record
        MultiCombat, Banking : boolean;
        BankToLoc, LocToBank : function(where : string) : boolean;
        Bank : string;
      end;

    function WalkTo(where:string) : boolean;
    begin
      writeln(where);
      result := true;
    end;

    function InitLocation(Where: string) : TLocation;
    var
      s: string;
    begin
      s := lowercase(Where);
      case s of

        'eastvarrock':
          with result do
          begin
            MultiCombat := false;
            Banking := true;
            Bank := 'veb';
            BankToLoc := @WalkTo; //LINE 107
            LocToBank := @WalkTo;
          end;

      end;
    end;

    var
      Loc : TLocation;
    begin
      Loc := InitLocation('eastvarrock');
      if Loc.BankToLoc <> nil then
        Writeln(BoolToStr(Loc.BankToLoc('vebtoguards')));
    end.

    Last edited by Coh3n; 07-25-2009 at 11:03 PM.

  9. #9
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Posting this for Da 0wner: Add his MSN if you need any further help: kylewallaston@hotmail.com

    SCAR Code:
    var
      Loc : TLocation;
    begin
      Loc := InitLocation('eastvarrock');
      if Loc.BankToLoc <> nil then
        Writeln(BoolToStr(Loc.BankToLoc('vebtoguards')));
    end.

    thats not what i want. I want to call just CurrentLocation.BankToLoc().
    I kinda solved this by making 1-line functions
    SCAR Code:
    function VEBtoGuards: boolean;
    begin
      result := WalkTo('vebtoguards');
    end;

    function GuardsToVEB: boolean;
    begin
      result := WalkTo('guardstoveb');
    end;

    function InitLocation(Where: string) : TLocation;
    var
      s: string;
    begin
      s := lowercase(Where);
      case s of

        'eastvarrock':
          with result do
          begin
            MultiCombat := false;
            Banking := true;
            Bank := 'veb';
            BankToLoc := @GuardsToVEB;
            LocToBank := @VEBToGuards;
          end;

      end;
    end;

    but this is not cool when i have like 12 1-line functions

  10. #10
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    thats not what i want. I want to call just CurrentLocation.BankToLoc().
    I kinda solved this by making 1-line functions
    SCAR Code:
    function VEBtoGuards: boolean;
    begin
      result := WalkTo('vebtoguards');
    end;

    function GuardsToVEB: boolean;
    begin
      result := WalkTo('guardstoveb');
    end;

    function InitLocation(Where: string) : TLocation;
    var
      s: string;
    begin
      s := lowercase(Where);
      case s of

        'eastvarrock':
          with result do
          begin
            MultiCombat := false;
            Banking := true;
            Bank := 'veb';
            BankToLoc := @GuardsToVEB;
            LocToBank := @VEBToGuards;
          end;

      end;
    end;

    but this is not cool when i have like 12 1-line functions
    Add Da 0wner on MSN, he said he'll find a work around.

  11. #11
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Add Da 0wner on MSN, he said he'll find a work around.
    If someone is banned, you don't go around making posts for him... He is banned from the community.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  12. #12
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    If someone is banned, you don't go around making posts for him... He is banned from the community.
    My apologies, I figured it wouldn't be allowed, but I thought as he was looking to help, it wouldn't be a big deal. It wont happen again.

    <3

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

    Default

    SCAR Code:
    function InitLocation(Where: string): TLocation;
    var
      s: string;
    begin
      s := lowercase(Where);
      case s of

        'eastvarrock':
          with result do
          begin
            MultiCombat := false;
            Banking := true;
            Bank := 'veb';
            BankToLoc := @WalkTo; //LINE 107
            LocToBank := @WalkTo;
          end;

      end;
    end;

    You would then have to do BankToLoc('vebtoguards') later in the script when you call it though, so you can't have it as you want. Your work around is probably a better solution to have it as an easy to call function as otherwise you have to supply the argument still
    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.

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
  •