Page 2 of 2

Posted: Sat Feb 10, 2007 2:33 pm
by Froggerprogger
...which would look like this:

Code: Select all

Out("sprite(" + \Name + ", " \
    + Str(Value) + ", " \
    + Str(\Width) + ", " \
    + Str(\Height) + ", " \
    + Str(\left) + ", " \
    + Str(\right) + ", " \
    + Str(\bottom) + ", " \
    + Str(\top) + ", " \
    + Str(\Transparent) + ", " \
    + Str(\Smooth) + ", " \
    + Str(\Preload) + ", " \
    + Str(\BoundingBox) + ", " \
    + Str(\Precise) + ", " \
    + Str(\Origin\x) + ", " \
    + Str(\Origin\y) + ", " \
    + Str(\SubimageCount) + ")")
which is better (in my eyes) than using a temp variable:

Code: Select all

s.s = "sprite(" + \Name + ", "
s + Str(Value) + ", "
s + Str(\Width) + ", "
s + Str(\Height) + ", "
s + Str(\left) + ", "
s + Str(\right) + ", "
s + Str(\bottom) + ", "
s + Str(\top) + ", "
s + Str(\Transparent) + ", "
s + Str(\Smooth) + ", "
s + Str(\Preload) + ", "
s + Str(\BoundingBox) + ", "
s + Str(\Precise) + ", "
s + Str(\Origin\x) + ", "
s + Str(\Origin\y) + ", "
s + Str(\SubimageCount) + ")"
Out(s)
though the last approach isn't too bad as long as you combine just one parameter. But for multiple parameters it becomes worse:

Code: Select all

OpenWindow(#WindowId, \
           GetXPosition(#WindowId), \
           GetYPosition(#WindowId), \
           GetW(#WindowId), \
           GetH(#WindowId), \
           "This is just a test-window doing nothing but hanging around...", \
           #PB_Window_BorderLess | #PB_Window_Invisible | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
is much better than introducing lots of temp variables:

Code: Select all

id = #WindowId
x = GetXPosition(#WindowId)
y = GetYPosition(#WindowId)
w = GetW(#WindowId)
h = GetH(#WindowId)
title.s = "This is just a test-window doing nothing but hanging around..."
flags = #PB_Window_BorderLess | #PB_Window_Invisible | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered
OpenWindow(id, x, y, w, h, title, flags)

Posted: Sun Feb 11, 2007 2:56 am
by u9
Derek wrote:O.k. I stand corrected.

Still think u9 was a bit off though.

Code: Select all

// check that Character can move in direction
If (destTile == This.map.TITANIUM || destTile == This.map.TITANIUM2 || destTile == This.map.BRICK || IsObject( destBomb ) || IsObject( destPlayer ) )
curSpeed--;
I didn't have any PB example as I am not using PB any more. The line above is from a game I made with Jamagic. But I wouldn't recommend making these variable names shorter becuase that comes at the cost of readability. But then again, so does the line-length.

I often encountered if-statements that are quite long and could be written nicely on several lines. But anyways, the examples presented here are excellent.

Posted: Fri Feb 16, 2007 9:35 am
by PB
I just had another reason for multiline programming:

Code: Select all

a$=OpenFileRequester("Select a file:","","All files|*.*|Documents|*.chm;*.doc;*.htm;*.html;*.rtf;*.txt|Images|*.bmp;*.gif;*.ico;*.jpg;*.jpeg;*.png;*.tga;*.tif;*.tiff|Sounds|*.mod;*.mp3;*.ogg;*.ra;*.wav;*.wma|Videos|*.avi;*.asf;*.flv;*.mov;*.mpg;*.mpeg;*.wmv",0)
;)

Posted: Fri Feb 16, 2007 12:03 pm
by Kaeru Gaman
so, you all stated you want it. fine.

...did anyone test the plugin?
Kaeru Gaman wrote:there is a preparser by Little John released in the german forum
http://www.purebasic.fr/german/viewtopic.php?t=10350

if you need help with usage, feel free to ask in that topic in english.

Posted: Fri Feb 16, 2007 9:41 pm
by Pantcho!!
whats the use of the plug in?
You need to input a source code and then gets an output source code.

thats nice and all but i think it is much more relevant if its done while you can actually test the code, in its IDE.

Posted: Sat Feb 17, 2007 12:18 am
by PB
> so, you all stated you want it. fine.
> ...did anyone test the plugin?

Doing it natively is what we want -- not a thirdparty solution.

Also, yes, I tested it, but I note that it doesn't support the correct syntax
coloring on the broken lines. For example, the following code looks terrible:

Code: Select all

a$="This small test example is _
Not in the correct color Or Case."
If PureBasic did it natively, it would ideally look like this:

Code: Select all

a$="This small test example is _
not in the correct color or case."

Posted: Sat Feb 17, 2007 12:30 am
by ricardo
PB wrote:I just had another reason for multiline programming:

Code: Select all

a$=OpenFileRequester("Select a file:","","All files|*.*|Documents|*.chm;*.doc;*.htm;*.html;*.rtf;*.txt|Images|*.bmp;*.gif;*.ico;*.jpg;*.jpeg;*.png;*.tga;*.tif;*.tiff|Sounds|*.mod;*.mp3;*.ogg;*.ra;*.wav;*.wma|Videos|*.avi;*.asf;*.flv;*.mov;*.mpg;*.mpeg;*.wmv",0)
;)
Yes, a good reason.

I think that at this point maybe most of use has found situatiosn where multiline could be nice.

Posted: Mon Mar 26, 2007 2:36 pm
by blueznl
I seem to vaguely recall that Alpha once said he would one day add multiline support... until then I use my good ol' CodeCaddy (as I'm using the backup feature of that thing anyway) to add multiline support.

Ie.

Code: Select all

  a.s = "this is" _
    + " a " _
    + "test"
  b.s = "so there you have it"
would turn into:

Code: Select all

  a.s = "this is" + " a " + "test"


  b.s = "so there you have it"
multilines are converted into single lines, but some spare lines are (optionally) added to keep error reports on the proper line number