Results 1 to 12 of 12

Thread: Strict Parameter Values?

  1. #1
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Strict Parameter Values?

    Hello,

    A while back I ran into a thread that had an example of a procedure with a parameter that could only be set to certain values.

    I have been trying to search the forums all day for that same thread, without any luck.

    From what I can recall the procedure had the usable values in an array, like...
    procedure ProcName(['ValueA', 'ValueB', 'ValueC']);

    I also believe that the value of the paramter is the index of the Value used in the Array.


    Sorry if my question doesn't seem to make a lot of sense. It is hard to explain in great detail something that you don't know...


    Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    http://www.villavu.com/forum/showthr...533#post619533

    I think you're asking about the TVariantArray.
    Well Variants can have different things in them, such as strings or integers (But are not limited to).

    Like

    var
    wat: TVariantArray;
    begin
    wat := [0, 'wsdf', true, 0.234];
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  3. #3
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you for your reply.

    I am familiar with Variants, but that is not what I am after.

    I will try to give an example of a script...
    Code:
    program StrictParameterValues;
    
    procedure ProcName(Parameter['Option1', 'Option2', 'Option3'] : Integer);
    begin
      WriteLn(Parameter); // Should return 1 (Index of 'Option2')
    end;
    
    begin
      ProcName('Option2');
    end.
    I wish I could find the original thread...
    Last edited by The_Scripts; 08-24-2009 at 09:50 AM.

  4. #4
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    like this?
    SCAR Code:
    type
      ScreenChoice = (BankScreen, SmithingScreen);

    function ScreenWait(Screen : ScreenChoice; Seconds : Integer) : Boolean;
    var T : LongInt; S : Integer;
    begin
      S := Seconds * 1000;
      if not LoggedIn then Exit;
      MarkTime(T);
      repeat
        Wait(100);
        Result := Screen;
      until Result or (TimeFromMark(T) >= S);
      if (TimeFromMark(T) >= S) then
      begin
        WriteLn('No Screen... Probably Lagged Out!');
        Exit;
      end;
    end;

  5. #5
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @mormonman: Somewhat, but I do recall there being an array within the parameter list.

    I shall continue searching the forums!!!

  6. #6
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Try:

    SCAR Code:
    procedure WriteValue(v: (Blah, Boo, Took));
    begin
      Writeln(IntToStr(v));
    end;
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  7. #7
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @Nava2: That is exactly what I was looking for.

    Thanks everyone!

  8. #8
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by The_Scripts View Post
    @Nava2: That is exactly what I was looking for.

    Thanks everyone!
    My pleasure.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  9. #9
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by The_Scripts View Post
    @Nava2: That is exactly what I was looking for.
    Both Nava2's and mormonman's examples were basically the same thing; mormonman's was just a preset type.

    It is called enumeration, in case you were wondering.

  10. #10
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question

    I have read up on enumeration and everything I read has indicated that it returns an integer. However I am having problems doing any math using the variables value.

    Nava2 wrote the following...
    Code:
    procedure WriteValue(v: (Blah, Boo, Took));
    begin
      Writeln(IntToStr(v));
    end;
    Produces this error: "[Error] (19848:21): Type mismatch in script".

    When I tested the procedure I used this...
    Code:
    procedure WriteValue(v: (Blah, Boo, Took));
    begin
      Writeln(v);
    end;
    It is fairly similar exept I have not converted the variable "v" to an Integer.

    The problem is that when I try to convert variable "v" to an Integer, or use it in a mathematical statement it produces an error.

    So my question is, what Variable Type does "v" have?

    Edit: Added Error Details.
    Last edited by The_Scripts; 09-05-2009 at 11:56 AM.

  11. #11
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  12. #12
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @Dan's The man: Thank you very much. I have got it working now.

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
  •