Results 1 to 10 of 10

Thread: Possible to {Define} in a if else statement?

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

    Default Possible to {Define} in a if else statement?

    I got
    SCAR Code:
    if(ZMAFButton.checked)then
      begin
        writeln('1');
      end;
    if(ZDMButton.checked)then
      begin
        {$DEFINE zasz}
        writeln('Defining Zasz''s Dummy Mager.');
      end;
      {$IFDEF zasz}
        writeln('Defined ok!');
      {$ENDIF}

    But no matter what, it says it defined ok..

    Help plz
    I do visit every 2-6 months

  2. #2
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Yeah, you can't use compiler directives inside if statements like that. You'll have to use regular booleans and more regular if statements.

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

    Default

    Can I use if blah.checked then
    {.include myfile.scar}???
    I do visit every 2-6 months

  4. #4
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    take a look at how wizzup did his with his multiminer? I'm pretty sure he used pointers, or something that acts like a pointer.
    “Ignorance, the root and the stem of every evil.”

  5. #5
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by Zasz View Post
    Can I use if blah.checked then
    {.include myfile.scar}???
    Um, I don't think so. Is there any particular reason you can't have it included from the start?

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

    Default

    Quote Originally Posted by senrath View Post
    Um, I don't think so. Is there any particular reason you can't have it included from the start?
    Yep. There is, so I need a good way to include files if its checked.
    I do visit every 2-6 months

  7. #7
    Join Date
    Mar 2008
    Location
    ::1
    Posts
    915
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    {.include and {define and things like that are used by the preprocessor which meens that when scar "compiles" the code, the thing will be defined no matter what. It is not defined during runtime. Hope that made since...

    Records and Types Save Code (and make you look better)
    Quote Originally Posted by Wizzup? View Post
    Is it possible to make Runescape a 2D game with this?... That would greatly simplify... Just about anything.

  8. #8
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    When it looks through the code all at once and it finds a Define, it is automatically defined. Even if the condition have not been met.

    Hope that was a little more easier to understand .

    SCAR Code:
    program New;

    procedure Define;
    begin
      {$DEFINE BLAH}
    end;

    begin
      {$IFDEF BLAH}
        writeln('Blah is defined.');
      {$ENDIF}
    end.

    You see? The procedures were not called but since the define was found in the code, it is defined.

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

    Default

    Just remember this they are called compiler directives for a reason.
    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

  10. #10
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Use booleans..

    And for the include part.. You can check that if you put a {$Define IncludeFileSRLUsed} in the include file..

    Then {$ifdef IncludeFileSRLUsed} Writeln('We included that file!'); {$else} writeln('Nope'); {$ENDIF}
    Verrekte Koekwous

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
  •