• MPLC IF THEN ELSE

    From Nugax@21:1/107 to All on Saturday, January 06, 2018 16:55:54
    How in the world do you do a nested MPL If Then else?

    For example:

    If a = b Then
    If b = c Then
    a+b+c = d;
    Else
    whateer
    else
    whatever21

    This gives errors on the else?



    -Nugax

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: -=The ByteXchange BBS : bbs.thebytexchange.com=- (21:1/107)
  • From g00r00@21:1/108 to Nugax on Sunday, January 07, 2018 00:30:26
    For example:

    If a = b Then
    If b = c Then
    a+b+c = d;
    Else
    whateer
    else
    whatever21

    This gives errors on the else?

    When it comes to syntax, you should include the actual code so we can see the typo. An example doesn't really work :) Here's an example of some code that works. The Syntax is the same in MPL as it is in Turbo/Free/Virtual Pascal.

    Var
    A,B,C : Byte = 0;
    Begin
    If A = B Then
    If B = C Then
    A := 10
    Else
    B := 10;
    Else
    C := 10;
    End.

    --- Mystic BBS v1.12 A39 2018/01/06 (Windows/32)
    * Origin: Sector 7 [Mystic BBS WHQ] (21:1/108)
  • From Nugax@21:1/107 to g00r00 on Monday, January 08, 2018 10:47:54
    For example:

    If a = b Then
    If b = c Then
    a+b+c = d;
    Else
    whateer
    else

    I got it working. The issue is:

    if on a line i have:

    If a>1 Then
    SomeCode; delay(3000); (for a 3 second pause)
    Else
    SomeCode


    it errors out on the delay. If I simply remove delay it works fine.


    Any idea what I should use for delay? or pausing?



    -Nugax

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: -=The ByteXchange BBS : bbs.thebytexchange.com=- (21:1/107)
  • From xqtr@21:1/111 to Nugax on Monday, January 08, 2018 19:11:10
    if on a line i have:
    If a>1 Then
    SomeCode; delay(3000); (for a 3 second pause)
    Else
    SomeCode
    it errors out on the delay. If I simply remove delay it works fine.

    After the IF..THEN statement you can only pass one command/function or if you want multiple commands you must enclose them in a BEGIN..END block. So, your code should be like this:

    If a>1 Then Begin
    SomeCode; delay(3000); //(for a 3 second pause)
    End
    Else
    SomeCode;

    .----- --- -- -
    | Another Droid BBS
    : Telnet : andr01d.zapto.org:9999 [UTC 11:00 - 20:00]
    . Contact : xqtr.xqtr@gmail.com

    --- Mystic BBS v1.12 A38 2018/01/01 (Raspberry Pi/32)
    * Origin: Another Droid BBS (21:1/111)
  • From g00r00@21:1/108 to Nugax on Monday, January 08, 2018 15:27:27
    If a>1 Then
    SomeCode; delay(3000); (for a 3 second pause)
    Else
    SomeCode


    it errors out on the delay. If I simply remove delay it works fine.


    Any idea what I should use for delay? or pausing?

    Your issues are related to syntax of the If statement not delay. You need to open a block if you have more than one statement in an IF statement. This is covered in the Whats new and any Google on Pascal syntax IF statement will explain it if you need more examples:

    If A > 1 Then BEGIN
    somecode
    delay(3000)
    End Else
    oneline

    The rule is:

    If a single function follows you don't need BEGIN/END. If you have multiple functions, then you need BEGIN/END

    If A = 1 Then Begin
    // lots of code goes here
    End Else Begin
    // lots of code goes here
    End;

    If A = 1 Then
    // One statement can go here
    Else
    // One statement can go here

    --- Mystic BBS v1.12 A39 2018/01/08 (Windows/32)
    * Origin: Sector 7 [Mystic BBS WHQ] (21:1/108)
  • From Nugax@21:1/107 to All on Monday, January 08, 2018 22:22:26
    Ah! Gotcha thanks

    On 09:27 08/01 , g00r00 wrote:
    If a>1 Then
    SomeCode; delay(3000); (for a 3 second pause)
    Else
    SomeCode


    it errors out on the delay. If I simply remove delay it works fine.


    Any idea what I should use for delay? or pausing?

    Your issues are related to syntax of the If statement not delay. You need to >open a block if you have more than one statement in an IF statement. This is >covered in the Whats new and any Google on Pascal syntax IF statement will >explain it if you need more examples:

    If A > 1 Then BEGIN
    somecode
    delay(3000)
    End Else
    oneline

    The rule is:

    If a single function follows you don't need BEGIN/END. If you have multiple >functions, then you need BEGIN/END

    If A = 1 Then Begin
    // lots of code goes here
    End Else Begin
    // lots of code goes here
    End;

    If A = 1 Then
    // One statement can go here
    Else
    // One statement can go here

    --- Mystic BBS v1.12 A39 2018/01/08 (Windows/32)
    * Origin: Sector 7 [Mystic BBS WHQ] (21:1/108)


    --
    yrNews Usenet Reader for iOS
    http://appstore.com/yrNewsUsenetReader

    --- Mystic BBS/NNTP v1.12 A38 2018/01/01 (Linux/64)
    * Origin: -=The ByteXchange BBS : bbs.thebytexchange.com=- (21:1/107)