Does Purebasic supports multiline programming?

Just starting out? Need help? Post your questions and find answers here.
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post 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)
%1>>1+1*1/1-1!1|1&1<<$1=1
u9
User
User
Posts: 55
Joined: Tue May 09, 2006 8:43 pm
Location: Faroe Islands
Contact:

Post 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.
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)
http://www.wirednerd.com
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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)
;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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."
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post 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.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply