Results 1 to 9 of 9

Thread: Or Statement

  1. #1
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default Or Statement

    how do you properly use the or statement in this situation, i cant seem to find my way through it

    I am checking to see if the Text in the Combobox matches what it needs to match in order for the script to work. Its a failsafe

    The below code works for checking the text of one of the Options but i have multiple Options that could be a possibility i need to check for. for example if the text is not 'Man' 'Woman' 'Spider' 'Vampire' 'Billy Bob' then i want to display the message to pick a valid Npc

    Simba Code:
    if(not(Comboboxes[0].Text = 'Man')) then
    begin
      ShowMessage('Please choose a valid NPC.');
      Exit;
    end;

    thanks

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  2. #2
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    how do you properly use the or statement in this situation, i cant seem to find my way through it

    I am checking to see if the Text in the Combobox matches what it needs to match in order for the script to work. Its a failsafe

    The below code works for checking the text of one of the Options but i have multiple Options that could be a possibility i need to check for. for example if the text is not 'Man' 'Woman' 'Spider' 'Vampire' 'Billy Bob' then i want to display the message to pick a valid Npc

    Simba Code:
    if(not(Comboboxes[0].Text = 'Man')) then
    begin
      ShowMessage('Please choose a valid NPC.');
      Exit;
    end;

    thanks
    I think this is what you're looking for:

    Simba Code:
    if(not((Comboboxes[0].Text = 'Man') or (Comboboxes[0].Text = 'Woman') or (Comboboxes[0].Text = 'Spider'))) then
    begin
      ShowMessage('Please choose a valid NPC.');
      Exit;
    end;

    Also if I remember correctly comboboxes have a set list to choose from, so you could make a default option called 'Monster' and then do

    Simba Code:
    if (Comboboxes[0].Text = 'Monster') then
    begin
      ShowMessage('Please choose a valid NPC.');
      Exit;
    end;

  3. #3
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    I think this is what you're looking for:

    Simba Code:
    if(not((Comboboxes[0].Text = 'Man') or (Comboboxes[0].Text = 'Woman') or (Comboboxes[0].Text = 'Spider'))) then
    begin
      ShowMessage('Please choose a valid NPC.');
      Exit;
    end;
    nice, it works. i only had 1 parenthesis after the not when i tried it that way:P. any idea how to make the default list? cause the next one i have over 10 options to pick from ha

    *i guess ive +1ed ur rep to much so it wont let me haha thanks

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  4. #4
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by ibot_dung11 View Post
    any idea how to make the default list? cause the next one i have over 10 options to pick from ha
    This is from my boot crafter (outdated now, was for srl5/ascalscript)
    Simba Code:
    ComboBox:= TComboBox.Create(settingsForm);
    ComboBox.Parent:= settingsForm;
    ComboBox.Left:= 270;
    ComboBox.Top:= 108;
    ComboBox.Width:= 110;
    ComboBox.Style:= csDropDownList;
    ComboBox.Items.Add('Duel Arena');
    ComboBox.Items.Add('Gamer''s Grotto');
    ComboBox.Items.Add('Burthorpe');
    ComboBox.Items.Add('Falador West');
    ComboBox.Items.Add('Varrock East');
    ComboBox.Items.Add('Varrock West');
    ComboBox.Items.Add('Draynor');
    ComboBox.Items.Add('Lumbridge');
    ComboBox.ItemIndex:= 0;

    The 'Duel Arena' option would be the default.

  5. #5
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    ComboBox.Style:= csDropDownList;
    thats the part i needed!

    i didnt have that so it let you type inside the combo box. now i dont need to make the failsafe and 50 or statements whoop whoop

    thanks man

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  6. #6
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    I'm a fan of using the case statement
    Simba Code:
    Case ComboBox.index of
      'Man':code for if man selected
      'Blah':blah blah
      'None':default in none selected
    End;
    To set a default ComboBox.Caption:= 'None';

    Short and brief hope you understand.
    If not hit me up on this thread i will be more than willing to help.
    Previously Known or not Known as CRU1Z1N.
    If you want to succeed you should strike out on new paths, rather than travel the worn paths of accepted success.(John D. Rockefeller)

  7. #7
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    In such situation just make custom function:
    Simba Code:
    program new;

    function IsStrOnList (s:string; list:TstringArray) :boolean;
    var h,i:integer;
    begin
      h := High(list);
      for i:=0 to h do
        if s = list[i] then
        begin
          Result := TRUE;
          exit;
        end;
    end;

    begin
      if not IsStrOnList('blah blah',['NPC','Monster','Women','Man']) then
        ShowMessage('Please choose a valid NPC.');
    end.

  8. #8
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by bg5 View Post
    In such situation just make custom function:
    Simba Code:
    program new;

    function IsStrOnList (s:string; list:TstringArray) :boolean;
    var h,i:integer;
    begin
      h := High(list);
      for i:=0 to h do
        if s = list[i] then
        begin
          Result := TRUE;
          exit;
        end;
    end;

    begin
      if not IsStrOnList('blah blah',['NPC','Monster','Women','Man']) then
        ShowMessage('Please choose a valid NPC.');
    end.
    nice thanks! what I was originally looking for but bmwxi gave a line to avoid it. saved for future use tho:P

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  9. #9
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    anyone know how to make it so the user can only type integers in a text box? that way they cant enter like 56bk for their bank pin or some similiar situation

    thanks

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

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
  •