IF ... then ... else ... all in the same line
issueid=296 29-06-2011 21:01
thinBasic author
Number of reported issues by ErosOlmi: 35
IF ... then ... else ... all in the same line

Please check if possible to add single line statement: IF ... then ... else ...

See post http://www.thinbasic.com/community/showthread.php?11236-You-rate-better-than-4-stars&p=83858&viewfull=1#post83858

Issue Details
Issue Number 296
Issue Type Feature
Project thinBasic
Category Core engine (thinCore.dll)
Status Suggested
Priority Unknown
Suggested Version 1.8.8
Implemented Version (none)
Milestone (none)
Votes for this feature 1
Votes against this feature 0
Assigned Users (none)
Tags (none)

05-10-2011 05:36
I believe this is my first posting here and I hope it's somewhat useful?

Edit: Went back and found I needed to double-check something further. What I thought, wasn't in fact working. I'll check some more <embarrassed>.

Edit2: Single line If...Then...Else doesn't flow to the FALSE condition (Else), with or without a trailing EndIf on the line. Breaking it down to multi-line code does trigger either the TRUE or FALSE condition.

Dim A As Integer
Dim B As Integer
A = 23
B = 1
If A > 50 Then B = A + 10 Else B = A + 20 EndIf
PrintL B

Uses "Console"
Dim A As Integer
Dim B As Integer
A = 23
B = 1
If A > 50 Then
  B = A + 10
  B = A + 20
PrintL B
Now I hope my first posting (edited a couple of times) has been useful and I look forward to getting deeper into thinBasic and having it work through a few BIG projects.


05-10-2011 07:20
thinBasic author
Hi LCSims,

the fact is that I do not like single IF lines because they do not produce clean and easy to be quickly understandable code.
So I didn't implement it at first.
Than I added it because requested by many users but in simple form: IF <test> then <statement>

I will see what I can do.


06-10-2011 04:25
Greets Eros,

I too like the structured code, so there need not be any changes on my behalf. I saw the thread as part of my forum surfing and tinkered a little to see if it was a "bug" or not.

I appreciate your work and your passion. Now to dig in and see how best thinBasic can assist me in my programming tasks. The world of programming has changed considerably from the days of Basic PDS 7.1 and the spaghetti code that could come out of it.


+ Reply