Page 2 of 4

Posted: Fri Nov 28, 2003 12:28 pm
by LarsG
As long as the (continous) line i seperated bu a comma, then it's all good for me.. :D

Re: continuation and white spaces

Posted: Sun Apr 18, 2004 8:56 am
by Amiga5k
oldefoxx wrote:as a r u l e y o u do n ot pu t sp
a
c es in side o f w o r d s. right?

So why would you want to haphazardly put spaces or new lines into terms and commands -- just to prove that you can? That serves no purpose, and onlyh makes it harder to read and maintain your code. In addition, it also makes the files bigger and puts a much greater demand on the compiler. which has to make sence of whether
How about this line, oldefoxx? (Taken from the 'Sprite_SpecialFX.pb' file):

Code: Select all

MessageRequester("Information", "This is a little demo of PureBasic real-time 2D effects:"+Chr(10)+Chr(10)+"F1: Enable/Disable RGB Filters"+Chr(10)+"F2: Enable/Disable AlphaChannel"+Chr(10)+"F3: Enable/Disable Shadow"+Chr(10)+"F4: Start screen fading"+Chr(10)+"F5: Enable/Disable AlphaChannel color rotation"+Chr(10)+"+/-: Add/Remove PureBasic AlphaBlending sprite"+Chr(10)+Chr(10)+"Use the mouse :)... Enjoy !", #MB_ICONINFORMATION)
(Yes, that was from ONE line in the program!)

Can you see where a simple "_" would break this up nicely and still leave it quite readable?

As for adding to file size... I think my source can stand an extra byte here and there for the "_" character ;)

This would be a nice option for us to have...
Russell

Re: continuation and white spaces

Posted: Sun Apr 18, 2004 10:04 am
by GPI

Code: Select all

a$=              "This is a little demo of PureBasic real-time 2D effects:"
a$+Chr(10)
a$+Chr(10)+"F1: Enable/Disable RGB Filters"
a$+Chr(10)+"F2: Enable/Disable AlphaChannel"
a$+Chr(10)+"F3: Enable/Disable Shadow"
a$+Chr(10)+"F4: Start screen fading"
a$+Chr(10)+"F5: Enable/Disable AlphaChannel color rotation"
a$+Chr(10)+"+/-: Add/Remove PureBasic AlphaBlending sprite"
a$+Chr(10)
a$+Chr(10)+"Use the mouse :)... Enjoy !"
MessageRequester("Information", a$, #MB_ICONINFORMATION)
Is much better readable and you can see the formation of the message.

Posted: Mon Apr 19, 2004 2:31 am
by Dare2
This is also quite readable

Code: Select all

winID=OpenWindow(#_win, 216, 0, 480, 320,   _
  #PB_Window_SystemMenu |  _
  #PB_Window_MinimizeGadget |  _
  #PB_Window_SizeGadget |  _
  #PB_Window_TitleBar |  _
  #PB_Window_ScreenCentered ,  _
  "NoSidewaysScrolling")

Re: continuation and white spaces

Posted: Mon Apr 19, 2004 7:12 am
by Amiga5k
GPI wrote:

Code: Select all

a$=              "This is a little demo of PureBasic real-time 2D effects:"
a$+Chr(10)
a$+Chr(10)+"F1: Enable/Disable RGB Filters"
a$+Chr(10)+"F2: Enable/Disable AlphaChannel"
a$+Chr(10)+"F3: Enable/Disable Shadow"
a$+Chr(10)+"F4: Start screen fading"
a$+Chr(10)+"F5: Enable/Disable AlphaChannel color rotation"
a$+Chr(10)+"+/-: Add/Remove PureBasic AlphaBlending sprite"
a$+Chr(10)
a$+Chr(10)+"Use the mouse :)... Enjoy !"
MessageRequester("Information", a$, #MB_ICONINFORMATION)
Is much better readable and you can see the formation of the message.
More readable is a matter of opinion, but it certainly involves a lot more typing on my part! BTW, your example is pretty much the way we are currently forced to do it if we don't want a line 500 characters long. It'd be nice to have a choice. That way, we can do less typing and still have everything nicely indented and readable and you can continue to self-chain your variables (a$ = a$ + ..., a$ = a$ + ... {I thought BASIC had moved beyond this?}) as much as you want...Works for both of us! ;)

This could be added to the editor or the compiler: If it's done in the editor, then the editor would have to do some simple checks like make sure that the "_" character is not in the middle of a quote (this is a standard guideline in other languages that support the continuation character) and then send the converted ascii file with the "_" removed (and the extended lines put back on the same line) to the compiler.
Of course, if it's done in the compiler then that extra step would not be necessary as the compiler would know how to deal with it.

Russell

p.s. This is not a feature that no one would use, but would be useful for actually keeping code more readable by keeping important information on the same screen without having to scroll to the right to see everything. Must be somewhat desired, considering how many times it has been asked for, eh? :P

Posted: Tue Apr 20, 2004 1:49 am
by Dare2
Some simple code that would do it:

Code: Select all

While LinesLeftToProcess
  z$ = GetNextLine()
  While Right(z$, 1) = "_"  ; where _ is continuation
    z$ + GetNextLine()
  Wend
  ParseAndProcessLine(z$)
Wend
Being very little extra code at the point where the next line is accessed.

Posted: Tue Apr 20, 2004 3:03 am
by Amiga5k
In C and some other languages the ";" character is used to denote the end of a "line". Although it can be annoying having to remember this, the plus side is that there's a lot more freedom as to where you can put your code, since CR and LF are essentially ignored by the compiler.

This is not the direction I'd like to see PB go, however. "_" would be much more Basic-like...

Russell

Re: continuation and white spaces

Posted: Tue Apr 20, 2004 6:22 am
by PB
> a$+Chr(10)+"F1: Enable/Disable RGB Filters"
> a$+Chr(10)+"F2: Enable/Disable AlphaChannel"

Yes, this is readable, but it presents two problems:

(1) More typing.
(2) More code in the app.

Using a$="1" : a$+"2" is more code than just a$="12" alone... which
is what a line continutation would provide. (Without line continuation,
you're using more code to build the string).

Posted: Fri Apr 23, 2004 5:03 am
by Dare2
Hi cwhite.

In case you took the link that leads here, welcome to the forums. ;)

Posted: Mon Oct 11, 2004 4:41 pm
by naw
I'd like a continuation character too - perhaps "~" tilde character at the end or beginning of a line. Would be better than "_" 'cos the underscore char is allowable in variable names, but "~" isnt used by PB anywhere (that I can see) and could therefore become a reserved character making it easier to parse. Perhaps it would be a possibility for JaPBE (unless it already does that)...

Posted: Mon Oct 11, 2004 4:55 pm
by Pupil
The tilde '~'-character is used for binary Not, so it's not an ideal choice either.

Posted: Mon Oct 11, 2004 9:41 pm
by PB
Using " _" (that is, a space followed by an underscore as the last 2 characters
on a line) is the time-tested method used by Visual Basic and makes perfect
sense, IMO. As for the compiler reporting the line on which an error occurred,
it would report the first line, since the compiler considers all subsequent lines
to be one line (internally) anyway. I see no problem with this at all. It also
makes cutting/pasting of Visual Basic code very simple, as you don't need to
reformat the multiple lines to work in PureBasic. ;)

Posted: Mon Oct 11, 2004 9:44 pm
by Dare2
Two unique and otherwise invalid characters?

space_
..

Or similar.

Posted: Tue Oct 12, 2004 1:18 pm
by naw
- seems to me that Fred released the IDE source so that people would contribute changes themselves and *good/nice* changes would be adopted into the standard IDE...
Everyone seems to like the idea of being able to break a command over several lines, I assume it can be done in the IDE without affecting the Compiler, so perhaps someone other than Fred could do it? I'm not volunteering (wouldnt want to :oops: humiliate :oops: myself )

Posted: Tue Oct 12, 2004 2:37 pm
by MrMat
Please don't add things like this to the editor/IDE because it breaks code for everyone who doesn't use it. In the compiler for compatibility please! :-D