# Serial if statements

**URL:** <https://forum.kirupa.com/t/serial-if-statements/331956>\
**Category:** Uncategorized\
**Created:** [December 6, 2013, 3:44pm UTC](https://forum.kirupa.com/t/serial-if-statements/331956 "2013-12-06T15:44:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpann](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tpann](https://forum.kirupa.com/u/tpann)\
**Post date:** [December 6, 2013, 3:44pm UTC](https://forum.kirupa.com/t/serial-if-statements/331956/1 "2013-12-06T15:44:49Z")

</div>

Say I have the following function:

```php
function foo():void {
     var a:Boolean = true;
     var b:Boolean = true;
     if (a) {
          trace("1"); trace("2"); trace("3"); trace("4"); trace("5");
     }
     if (b) {
          trace("A"); trace("B"); trace("C"); trace("D"); trace("E");
     }
}

```

Note that the second if statement is not an “else” and I don’t want it to be.

The trace consistently indicates that the first if statement completes before the second starts. But what if both if statements call several functions that do lots of things? Will everything happen synchronously? Or should I expect that one or more of the functions called in the second if statement might complete before those in the first if statement?

If the behavior is asynchronous, but I want the second if statement to wait until the first on is done, I could set them up in separate functions and have the first call the second when it’s complete. But is there a more elegant way to keep them in the same function and still make the second if statement wait?  
Thank you!
