Page 1 of 1

If...Then

Posted: 03 Oct 2008 12:58
by arco
It would be very nice if one-line if...then loops were allowed for simple tests, allowing for writing more compact sourcecode.

Code: Select all

If x=1 then y=0
Or:

Code: Select all

If x=1 Then y=0 Else z=2
Most Basic dialects allow this usage...

Posted: 03 Oct 2008 13:48
by yo2lio
Sorry but I don't understand your wishes ...

The lines like this :

Code: Select all

if xx = 5 then zz = 7 else yy = 3 end if 
works OK in MikroBasic.

Posted: 03 Oct 2008 15:38
by arco
Thanks,

Never tried it with End If at the and. (All other Basic dialects I ever used had the If...Then...Else syntax without End If on one-liners...)

Posted: 04 Oct 2008 01:02
by arco
Also use of Unions for Type Structures or dimensioning multiple 'overlapping' types at the same location would be very helpful.

Code: Select all

Structure MyStructure1
  Dim Var1 As Byte
  Dim Var2 As Byte
  Dim Var3 As Word
End Structure  

Structure MyStructure2 At MyStructure1
  Dim Var4 As String[4]
End Structure
This would allow both structures to occupy the same memory locations.

Posted: 04 Oct 2008 07:35
by yo2lio
:idea: Use absolute directive :

Code: Select all

Structure MyStructure1
  Dim Var1 As Byte
  Dim Var2 As Byte
  Dim Var3 As Word
End Structure

Structure MyStructure2
  Dim Var4 As String[4]
End Structure

dim aaa as MyStructure1 absolute $100
    bbb as MyStructure2 absolute $100

Posted: 04 Oct 2008 12:58
by arco
Use absolute directive
Yes, I know that, but I don't need fixed addresses, I just want them at the same address...