# Fixed a ChoiceScript bug: blank lines at the end of \*if

**URL:** <https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836>\
**Category:** ChoiceScript Help\
**Tags:** choicescript-updates\
**Created:** [April 17, 2015, 5:24pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836 "2015-04-17T17:24:50Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [April 17, 2015, 5:24pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/1 "2015-04-17T17:24:50Z")

</div>

There’s been an annoying bug in ChoiceScript forever, like this:

```
Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!

Paragraph 2.

```

If `maybe = 1`, then there’s a paragraph break between “Maybe!” and “Paragraph 2.” But if `maybe = 0`, then the paragraph break is skipped; the user sees “Paragraph 1. Paragraph 2.” all in one line.

I’ve just pushed a fix to github, so there will now always be a paragraph break.

Give it a try and let me know if it breaks anything.

In particular, I know people have been working around the bug like this:

```
Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!
*comment endif

Paragraph 2.

```

Or like this:

```
Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!
*line_break
*line_break    
Paragraph 2.

```

Both of those still work just fine; it’s just unnecessary.

If you actually wanted to show a paragraph only if maybe = 1, then you’d now do it like this:

```
Paragraph 1.
*temp maybe
*rand maybe 0 1
*if maybe = 1
    Maybe!
    *line_break
    *line_break
Paragraph 2.
```

---

<div class="post-metadata">

**Author:** ![dashingdon](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dashingdon/32/4070_2.png) [@dashingdon](https://forum.choiceofgames.com/u/dashingdon)\
**Post date:** [April 17, 2015, 5:46pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/2 "2015-04-17T17:46:52Z")

</div>

Nice. I went the double line\_break route. It’s great to have this fix to avoid that since I usually don’t catch it until I’m testing.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [April 17, 2015, 7:39pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/3 "2015-04-17T19:39:43Z")

</div>

Yay from another double linebreaker…

---

<div class="post-metadata">

**Author:** ![Silverstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/silverstone/32/9901_2.png) [@Silverstone](https://forum.choiceofgames.com/u/Silverstone)\
**Post date:** [April 18, 2015, 4:41am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/4 "2015-04-18T04:41:09Z")

</div>

Lol… I thought I was just noob using the double line\_break. TY 😂

---

<div class="post-metadata">

**Author:** ![Sashira](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/sashira/32/2899_2.png) [@Sashira](https://forum.choiceofgames.com/u/Sashira)\
**Post date:** [May 31, 2015, 1:44am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/5 "2015-05-31T01:44:29Z")

</div>

Double line breaks are showing up in my code as double spaces between paragraphs. One line break displays the way you’d think it should. Spaces between paragraphs do not display if the paragraph ends with an \*if statement.

I have the latest version of Choicescript; am I missing something about how to fix this function? I didn’t have any issues with Monsters of New Haven High, but coding a new game with the latest version, I can’t seem to get a single blank line.

I’ll try the \*comment workaround, but I’m hoping there’s a better solution that I’m failing to understand.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [May 31, 2015, 3:56am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/6 "2015-05-31T03:56:25Z")

</div>

I’m pretty sure everything’s working exactly the way it’s supposed to, but you may not like the way it looks.

```
*create leadership 50
*create strength 50

This
is
all
one
line.

This is a new paragraph.

And this
*line_break
is two lines.

Here's another paragraph.

This paragraph ends with a true *if statement.
*if leadership = 50
  Leadership = 50.

Here's the next paragraph, which ends with a false *if statement.
*if leadership = 40
  Leadership = 40

Here's the last paragraph.

```

Looks like this:

![](https://global.discourse-cdn.com/choiceofgames/original/2X/4/4712c0dad59c3ba9d2d7c21218380e13fac53bca.png)

I would transcribe that as:

> This is all one line.
> 
> This is a new paragraph.
> 
> And this  
> is two lines.
> 
> Here’s another paragraph.
> 
> This paragraph ends with a true \*if statement. Leadership = 50.
> 
> Here’s the next paragraph, which ends with a false \*if statement.
> 
> Here’s the last paragraph.

1. Is that what you see as well?
2. Is that what you’d expect? If not, what would you expect instead?

---

<div class="post-metadata">

**Author:** ![Sashira](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/sashira/32/2899_2.png) [@Sashira](https://forum.choiceofgames.com/u/Sashira)\
**Post date:** [May 31, 2015, 6:28am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/7 "2015-05-31T06:28:06Z")

</div>

With double line breaks, I’m seeing what you list under “looks like this”. I’m trying to make it look like “I’d transcribe that as.” Looks Like This has a smaller space between paragraphs than I’d Transcribe That As. I’m trying to standardize the size of the break between paragraphs whether or not the paragraph ends with an \*if statement; with a double-line-break workaround those paragraphs are spaced twice as large as non-if paragraphs, and I’m reluctant to make them match by putting a double break between the unaffected lines.

If I’m understanding your example, the space in the code should just appear after the paragraph whether or not it ends with a true \*if statement, since the bug fix? That is not happening for me. I have the latest version of ChoiceScript, and a blank line between paragraphs is not doing anything if there’s an \*if statement there.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [May 31, 2015, 7:44am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/8 "2015-05-31T07:44:55Z")

</div>

I’m struggling to understand your question here. When reporting an issue, it’s important to provide three pieces of information in clear detail:

- Steps to reproduce
- What you’d expect to happen
- What actually happens instead

I _think_ you’re reporting two separate issues:

**Issue #1) When you take my code sample above and use it, you don’t see “Looks Like This,” (my screenshot) and instead you see something else.**

> [@Sashira](#):
>
> If I’m understanding your example, the space in the code should just appear after the paragraph whether or not it ends with a true \*if statement, since the bug fix? That is not happening for me.

I claim that if you use my code sample, you will reproduce the exact same screenshot I posted here.

If that’s not true, can you post a screenshot showing exactly what you do see when you use my code sample?

(The best way to make sure you’re running the latest version of ChoiceScript is to archive and delete your old one; it’s very easy to download multiple copies of ChoiceScript and accidentally use the wrong/old version without noticing.)

**Issue #2) Even if you did see the exact same thing as my screenshot, that’s not what you’d want it to look like. You’d want it to look different in some way.**

But I don’t understand how you want/expect it to be different.

I really don’t understand what you mean when you say,

> [@Sashira](#):
>
> I’m seeing what you list under “looks like this”. I’m trying to make it look like “I’d transcribe that as.” Looks Like This has a smaller space between paragraphs than I’d Transcribe That As.

Are you saying that the transcript and the screenshot look different to you? They look exactly the same to me, except that the screenshot is in the “Georgia” font at 16px and the transcript is in the forum’s default “Helvetica” font at 14px.

In both the screenshot and the transcript, there’s just one blank line separating paragraphs. If the font is bigger, then the space between paragraphs is bigger, because one blank line is bigger.

\*_Note that issue #2 has nothing to do with if._ If you use the following code sample #2, it’s guaranteed to look _exactly_ like my screenshot, despite the fact that it has no \*if.

```
This is all one line.

This is a new paragraph.

And this
*line_break
is two lines.

Here's another paragraph.

This paragraph ends with a true *if statement. Leadership = 50.

Here's the next paragraph, which ends with a false *if statement.

Here's the last paragraph.

```

If you want the screenshot to look differently (make it look more like the forum) then you’re talking about fonts, not about \*if.

---

<div class="post-metadata">

**Author:** ![cvaneseltine](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cvaneseltine/32/4047_2.png) [@cvaneseltine](https://forum.choiceofgames.com/u/cvaneseltine)\
**Post date:** [May 31, 2015, 4:30pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/9 "2015-05-31T16:30:42Z")

</div>

Ouch. I understand entirely why you did this - having the blank space be associated with the next section (as you have it now) is far more intuitive than having it be associated with the \*if statement (as it previously was).

But I’m really not looking forward to upgrading, because it will break the spacing in every \*if statement I have. And there are, um, rather a lot of them.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [May 31, 2015, 8:41pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/10 "2015-05-31T20:41:24Z")

</div>

It would surprise me a great deal if you had to update a lot of `*if` statements. I ran a test on all of our existing games before rolling out this change, and found that 99%+ of `*if` statements did _not_ need to change.

The only `*if` statements that _do_ need to change are those that really want to have _inconsistent_ paragraph spacing, where there would be a paragraph break if the `*if` statement is true, but no paragraph break if the `*if` statement is false. It’s pretty rare to want exactly that.

---

<div class="post-metadata">

**Author:** ![cvaneseltine](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cvaneseltine/32/4047_2.png) [@cvaneseltine](https://forum.choiceofgames.com/u/cvaneseltine)\
**Post date:** [May 31, 2015, 9:03pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/11 "2015-05-31T21:03:08Z")

</div>

> [@dfabulich](#):
>
> The only \*if statements that do need to change are those that really want to have inconsistent paragraph spacing, where there would be a paragraph break if the \*if statement is true, but no paragraph break if the \*if statement is false.

I’m a troublemaker. \> \<

I’ll doublecheck, but I suspect that I have exactly this problem.

---

<div class="post-metadata">

**Author:** ![cvaneseltine](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cvaneseltine/32/4047_2.png) [@cvaneseltine](https://forum.choiceofgames.com/u/cvaneseltine)\
**Post date:** [May 31, 2015, 9:18pm UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/12 "2015-05-31T21:18:25Z")

</div>

Okay - I do have some cleanup to do, but it’s nowhere near as bad as I thought, now that I understand your explanation. Thank you for clarifying!

---

<div class="post-metadata">

**Author:** ![Shawn\_Patrick\_Reed](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/shawn_patrick_reed/32/20691_2.png) [@Shawn\_Patrick\_Reed](https://forum.choiceofgames.com/u/Shawn_Patrick_Reed)\
**Post date:** [June 1, 2015, 1:24am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/13 "2015-06-01T01:24:44Z")

</div>

Well, I’ve been using  
\*line\_break  
\*line\_break  
to start a new paragraph. But I’ve also noticed a funny little thing CS does that I’ve been taking advantage of.

At the end of a sentence you type, if you add a single space, with the space bar.  
The next sentence you begin, such as one under an \*if statement, will have a nice regular sentence break between the two. However, when I tried adding a space on its own line under \*if, with that same one-space-creates-a-space, instead, it adds a blank line. Grammatically frustrating. I’d like to find a way to just add a single blank space into the writing, sometimes, without adding a blank line.

---

<div class="post-metadata">

**Author:** ![Shawn\_Patrick\_Reed](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/shawn_patrick_reed/32/20691_2.png) [@Shawn\_Patrick\_Reed](https://forum.choiceofgames.com/u/Shawn_Patrick_Reed)\
**Post date:** [June 1, 2015, 1:29am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/14 "2015-06-01T01:29:35Z")

</div>

_laughs maniacally_ Pretty rare, this one says… oh my. I’m glad I’m not using blank lines then. I’d be in big trouble. There are a lot of times I have another paragraph, or paragraph part, hidden under an \*if.

---

<div class="post-metadata">

**Author:** ![ballmot](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/ballmot/32/198924_2.png) [@ballmot](https://forum.choiceofgames.com/u/ballmot)\
**Post date:** [June 1, 2015, 1:49am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/15 "2015-06-01T01:49:32Z")

</div>

Ouch, I’m going to have to update about 50% of my code 😵

This is going to be a looooong day…

---

<div class="post-metadata">

**Author:** ![Sashira](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/sashira/32/2899_2.png) [@Sashira](https://forum.choiceofgames.com/u/Sashira)\
**Post date:** [June 1, 2015, 4:22am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/16 "2015-06-01T04:22:02Z")

</div>

I’ve had similar issues as the other people that posted since me, but I’ll post code and a screenshot ASAP. It should be just a matter of taking out the \*comment line and taking a screenshot.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [June 1, 2015, 4:56am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/17 "2015-06-01T04:56:09Z")

</div>

I bet you won’t have to update anywhere close to 50% of your game. No published CoG or HG game required that much updating.

This bug fix is extremely safe. If you think it involves changing all of your `*if` statements, then you’re probably misunderstanding what it does.

But the only way I can prove it is for you to try it on your own code. I think you’ll find that if your code was working correctly before, it will continue to work correctly after the bug fix, but if your code has buggy paragraph breaks before, it’s now fixed.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [June 1, 2015, 4:58am UTC](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836/18 "2015-06-01T04:58:03Z")

</div>

> [@Shawn\_Patrick\_Reed](#):
>
> laughs maniacally Pretty rare, this one says… oh my. I’m glad I’m not using blank lines then. I’d be in big trouble. There are a lot of times I have another paragraph, or paragraph part, hidden under an \*if.

That’s perfectly fine, and will continue working correctly after this bug fix.

For example, all of this code would work unchanged.

```
1) First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.
*comment endif

Last paragraph.

2) First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.
*line_break
*line_break    
Last paragraph.

3) First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.
    *line_break
    *line_break
Last paragraph.

```

The only sample that would change is this one:

```
First paragraph.
*if maybe = 1
    Maybe paragraph.

    Another maybe paragraph.

Last paragraph.

```

I think you’ll find that if you had code like that, it was buggy before, and now it’s fixed.
