Continuation line for source file

Working on new editor enhancements?
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

As long as the (continous) line i seperated bu a comma, then it's all good for me.. :D

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Re: continuation and white spaces

Post 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
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: continuation and white spaces

Post 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.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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")
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Re: continuation and white spaces

Post 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
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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.
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post 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
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: continuation and white spaces

Post 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).
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi cwhite.

In case you took the link that leads here, welcome to the forums. ;)
naw
Enthusiast
Enthusiast
Posts: 573
Joined: Fri Apr 25, 2003 4:57 pm

Post 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)...
Ta - N
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

The tilde '~'-character is used for binary Not, so it's not an ideal choice either.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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. ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Two unique and otherwise invalid characters?

space_
..

Or similar.
@}--`--,-- A rose by any other name ..
naw
Enthusiast
Enthusiast
Posts: 573
Joined: Fri Apr 25, 2003 4:57 pm

Post 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 )
Ta - N
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post 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
Post Reply