Give me a break

General FreeBASIC programming questions.
JustMe
Posts: 8
Joined: Aug 25, 2005 13:17

Give me a break

Postby JustMe » Aug 25, 2005 13:26

Hi people,

I'm new to FreeBasic but not to programming, and was just messing around with FB a bit. I've noticed two rather (well for me) annoying things. Fist there is no break statement and second the thing with end if, wend and so on isn't very consistent.
Are there plans to fix this? Add break and change to just end for all blocks. Or do I have to learn to live with this?
Oz
Posts: 585
Joined: Jul 02, 2005 14:21
Location: Waterloo, Ontario, Canada
Contact:

Postby Oz » Aug 25, 2005 13:35

there is no break, because BASIC syntax did not originally have this

instead, use EXIT [method]

ex.

Code: Select all

do
  if len(inkey$) then exit do
loop


if the keyboard buffer has any length to it, exit the do/loop

END IF and WEND are very consistant....if it screws up, it's the programmers error, not compilers

Oz~
Sterling Christensen
Posts: 142
Joined: May 27, 2005 6:13

Postby Sterling Christensen » Aug 25, 2005 13:51

Well, maybe WEND would be more consistant as "END WHILE". Or maybe if "END IF" were changed to "IEND". But I think they should be left the way they are for compatibility with qbasic.
JustMe
Posts: 8
Joined: Aug 25, 2005 13:17

Postby JustMe » Aug 25, 2005 14:42

There don't appear to be Boolean constants or variables either.

This is what I have now for a mainloop:

Code: Select all

while 1
  print "bla"
  exit while
wend


What I would like to write is this:

Code: Select all

while true
  print "bla"
  break
end


I’m not really into the historic syntax thing and think there are some things that could need a good spring cleaning. @ Oz: There is no way that you can convince me that end if and wend are consistent. @ Sterling Christensen: Iend looks bad :) I’d avoid it at all cost. Exit while vs. break, break is more concise but exit while is more consistent with the postfix notation (which makes wend just much more annoying).

I'd settle for:

Code: Select all

while true
  print "bla"
  exit while
end while
Dare2
Posts: 75
Joined: Aug 23, 2005 12:07

Postby Dare2 » Aug 25, 2005 14:52

Actually While .. end looks odd to me.

"Improving" the basic syntax eventually leads to things like:

codeblock { code }

And then we're no longer coding in basic. :)
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Aug 25, 2005 14:55

omg, don't event think about it ;P
Dare2
Posts: 75
Joined: Aug 23, 2005 12:07

Postby Dare2 » Aug 25, 2005 14:56

:)
JustMe
Posts: 8
Joined: Aug 25, 2005 13:17

Postby JustMe » Aug 25, 2005 14:56

You would be hardprest to find me advocating producing another curly bracket syntax language. My concern is rather self consistency.
VirusScanner
Posts: 775
Joined: Jul 01, 2005 18:45

Postby VirusScanner » Aug 25, 2005 15:21

In much of the FB code, you will see

Code: Select all

#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE NOT(FALSE)
#endif

or something similar, which sets true to the opposite of zero, which will never cause problems even if the value of true (1/ -1) is changed.
jofers
Posts: 1525
Joined: May 27, 2005 17:18
Contact:

Postby jofers » Aug 25, 2005 15:53

WEND has been around since the 60s, you couldn't really change it while still calling the language "BASIC". More consistant languages with "block...end" forms are closer to Pascal.

Since loops are sort of a basic programming construct, they can have their own ending:

Code: Select all

FOR...NEXT
WHILE...WEND
DO...LOOP

Only logic & structure blocks do the "end" thing:

Code: Select all

IF...END IF
SELECT CASE...END SELECT
TYPE...END TYPE
WITH...END WITH

It makes sense in my twisted mind anyway.
fsw
Posts: 260
Joined: May 27, 2005 6:02

Postby fsw » Aug 25, 2005 16:44

What about:

Code: Select all

FOR...NEXT
WHILE...REPEAT
DO...LOOP

Just joking, even if it's more locical ;)

BTW: you can use macros and use the words you like:

Code: Select all

WHY_NOT_RISK...ANOTHER_ONE
COULD_YOU_PLEASE...DO_IT_AGAIN
TRY_TO_DO...TRY_AGAIN


:)))
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Postby dumbledore » Aug 25, 2005 17:34

Code: Select all

#define BREAK EXIT WHILE

:D

Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests