[Implemented] Very long statements

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

I politely disagree, adding [ ] or the alike would break readablity of code, right now it's readable under most conditions, but adding things lile [ ] would break readable code, [IMHO].

Strings for example when the preprocessor see " Will contune to think that is it a string until it reaches another > " which will notify it of the end of the quote or string, any 0x0A or 0x0D found in the string are ignored.

ricardo: not quite sure what you mean by IF's ELSEIF's etc, could you elaborate ?
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Inner,

I shifted my stance here to use the existing brackets, rather than adding new ones.

So in your example

Code: Select all

Foo(apple, 
      fruity, 
      basket, 
      food, 
      fight) 
The CRs are ignored because they are inside the brackets (). I think these brackets are enough, there would be no need to add new ones.

So the rule is based on the existing brackets and not the comma, so that lines could also be broken up with the or operators, etc.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Don't much care how we do it - it'd be a great thing to have though!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

My two cents worth.

Post by oldefoxx »

Actujally, 3 cents:

(1) I like " _" in place of just "_". After all, underscore could be a valid
last letter of a variable name. The extra space or tab character prevents it from being interpreted as such. This method is used with several BASICs, and has the advantage that you mask out the quoted text and the comments, then search for the occurance of " _", and break the line at that point and join the next line to it. If that also ends in a " _", you
just repeat the process, as many times as necessary. It is a very simple parsing mechanism. Second, a number of programmers use this method
to add comments in innovative ways, since nothing after the " _" is handled by the compiler. So you could have the following:

:this is a comment _
and so is this _
and so is this.

You can even use it to align comments like this:

Code: Select all

 _ this is a comment
 _ and so is this
 _ and so is this.

or you could use it this way:             _ this is also a comment & line join

 ____________________ This starts a comment box ______________
 _ this is a comment                                                                     _
 _ and so is this                                                                            _
 _ and so is this                                                                            _
 ____________________ This ends a comment box _______________

In other words, you can get very creative with the use of the inderscore as a line join indicator.

(2) I tried to compile the purebasic.ide.pb program, but ran into some issues. I wanted to figure out where certain added capabilities could go. My idea is to do three things:

(a) extend the search to search each help in order -- PB, FASM, ASM, Win32, and so on. If it cannot find a match, it looks in other programs for declares, globals, and procedures that might match. Everything from the
PureBASIC root directory would be fair game for a search. Since a search could take a good while, I would attempt a crossreference index and also allow the search to be broken off if it runs too long.

(b) Use this technique to determine if a given file is a standalone executable, depends on terms, structures and constants found in any include files, and determine if it itself is subject to any include statements in any other programs. Again, crossreferencing would speed this process over time.

(c) Add a search for path for any include files, in case the PureBASIC tree on a target system differes from the source system. When there is more than one source, allow the user to designate, so that by a process of trial and error, the correct sequence can be established.

(d) Add a reformatting tool, so that source code can be optimized in
terms of readability. This would include such things as indent size, whether Case should indent further than Select and EndSelect, and whether code should have the main code first with Declares, followed by Procedures, or Procedures first. just for consistency. Line joins could be
inserted automatically to allow lines to wrap to fit within the IDE view window. It could also comment Next, Wend, and Until statements to make it easier to match to the original For, While, and Repeat stateents.
Technically, they might also be able to automatically tag comments to ElseIf, Else, and EndIf statements as well. This seems like overkill, but the ability could make it easier for someone to track up a long trail of statements to find the point of origin, or do down it to find the end.

But these are just to-do or would-be-nice ideas. The big one follows:

(3) HAVE THE COMPILER IGNORE EVERY DUPLICATE OF A DECLARE, STRUCTURE, OR CONSTANT. My point is that when you consolidate all your structures and constants together, you may have several secondary (include) as well as primary files pointed at that one reference. As long
as everything matches up in value or form, this should be tollerated and
ignored. When they don't match, the compiler should report that there is a conflict with a prior definition (different size, different fields, different
values for constants). XIncludeFile() ignores that a file was processed previously, but you still get the error on Structures that are redefined.
has-been wanna-be (You may not agree with what I say, but it will make you think).
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

Post by SofT MANiAC »

5 years...
no progress...
POiNT.OF.PRESENCE group
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Five years and TONS of progress (just look at PB 4)

Just not on this particular request. :)

But the other items have helped me MUCH MUCH more.

cheers
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

GedB wrote:Inner,

I shifted my stance here to use the existing brackets, rather than adding new ones.

So in your example

Code: Select all

Foo(apple, 
      fruity, 
      basket, 
      food, 
      fight) 
The CRs are ignored because they are inside the brackets (). I think these brackets are enough, there would be no need to add new ones.

So the rule is based on the existing brackets and not the comma, so that lines could also be broken up with the or operators, etc.
Finally some intelligence :)
I like logic, hence I dislike humans but love computers.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

I could work t either way as both those characters are on my keyboard without having to do some weird [ALT]+ combination.

I refuse to use a windows keyboard. I love my ALPS OmniKey/PLUS and my other IBM APLS models...

OK so no "windows" key. But you know, don't miss it that much!

Ending with a ' or even an ^, ~, or |\ / I am cool... I have several LONG lines that I would like to truncate so I can more easily read my code ON SCREEN! 8)

PB 4b4 is gonna rock!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

Post by SofT MANiAC »

So... and what in the end?
Next another-another-another pre-compiler?
POiNT.OF.PRESENCE group
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

I fully support the idea of having the possebility of breaking long lines and I don't care how we do it, as long as we can do it.

So use _ or | or ~ or whatever. But please make it happen.
Horizontal scrolling is annoying and sometimes not possible!

Therefore here's another request for the IDE: a vertical line that can be adjusted to show up at char 79 or 80,... some of you might know from other Editors (especially on Linux).
cheers,

bembulak
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Post by eesau »

bembulak wrote:Horizontal scrolling is annoying and sometimes not possible!
When is it not possible?
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

SSH / Telnet / Terminal Sessions. Mostly affects Linux users, but I also struggle with it on Windows now and then, working on the company's Server from outside via GSM-Connection (it's too slow to have RDP running).

80 characters, 24 Lines.
Image

http://en.wikipedia.org/wiki/Vt100
http://en.wikipedia.org/wiki/Terminal_emulator
cheers,

bembulak
benco5000
User
User
Posts: 13
Joined: Mon Mar 01, 2010 8:56 pm

Re: Very long statements

Post by benco5000 »

I'll just repost here to add my vote to have this done.
My code in other languages is overly documented (is this really possible) and very clean. I'd like to add pure basic to my arsenal. Below is an example of ugly vs. clean (artsy code) :)

Code: Select all

;------------------------------------------------------------
; create a main window
;------------------------------------------------------------
mainWin = OpenWindow(#PB_Any, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_SizeGadget |#PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)

vs.

;------------------------------------------------------------
; create a main window
;------------------------------------------------------------
mainWin = OpenWindow(#PB_Any,                                  ;; create a window and assign id to mainWin
                      0, 0, 270, 140,                          ;; window size
                      "ListViewGadget",                        ;; name of window appears in title bar
                      #PB_Window_SystemMenu |                  ;; include a system menu
                      #PB_Window_SizeGadget |                  ;; allow resizing
                      #PB_Window_MinimizeGadget |              ;; allow minimize button
                      #PB_Window_MaximizeGadget |              ;; allow maximize button
                      #PB_Window_ScreenCentered)               ;; center on screen
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Very long statements

Post by blueznl »

Touchy subject, and a very old one at that :-)

Many people have requested such a feature, but it hasn't surfaced yet.

The only way currently possible is a preprocessor, such as CodeCaddy, to add multiline capabilities to PureBasic, such as this:

Code: Select all

a.s = " 123
  _ 456
  _ 789"
Debug a.s

b.l = 1 + _
  2 + _
  3 + _
  4
Debug b
It's not perfect yet as the compiler doesn't let me easily preprocess include files. I hope that's an upcoming feature, in which case I do not need PureBasic itself to provide me multiline functionality.
( 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... )
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Very long statements

Post by Trond »

Multiline would be nice, unfortunately _ can't be used, as it's a legal variable name.
Post Reply