[Implemented] Nice to have...
[Implemented] Nice to have...
Just to save typing
============
Global Myvariable.l = 123 ; Assign variable as global and initial value
and...
Protected LocalVariable.l = 456 ; For locals
Useful when the string length is not known... common in other BASICS
===========================
k$ = Mid(Mystring$,N) ; k$ gets all the string starting at character N
To aid clarity...
==========
Sub gets ignored, but maybe we can then get the nice guys at jaPBe to fold Sub.... Return. That would really tidy things up. Folding is so nice I have given up subroutines and use Procedures because editing is so much easier. GFA folded both.
Sub SubroutineName():
.
.
Return
============
Global Myvariable.l = 123 ; Assign variable as global and initial value
and...
Protected LocalVariable.l = 456 ; For locals
Useful when the string length is not known... common in other BASICS
===========================
k$ = Mid(Mystring$,N) ; k$ gets all the string starting at character N
To aid clarity...
==========
Sub gets ignored, but maybe we can then get the nice guys at jaPBe to fold Sub.... Return. That would really tidy things up. Folding is so nice I have given up subroutines and use Procedures because editing is so much easier. GFA folded both.
Sub SubroutineName():
.
.
Return
Re: Nice to have...
ok the Global myvar.l = 123
I agree.
But it should be optional, so old sources will work, and so those who
might not need a specific value to the variable just write the usual.
But:
after some looking i cant see how to make subs in purebasic using Sub routin() The only sub thing is Gosub, and gosub uses labels.
Since labels are used for more than subroutines, such as goto and adressing of variables and procedures, and include binarie's.
So you want to fold every labels, wich i would not recommend
I agree.
But it should be optional, so old sources will work, and so those who
might not need a specific value to the variable just write the usual.
But:
subs?RichardL wrote: Sub gets ignored, but maybe we can then get the nice guys at jaPBe to fold Sub.... Return. That would really tidy things up. Folding is so nice I have given up subroutines and use Procedures because editing is so much easier. GFA folded both.
Sub SubroutineName():
.
.
Return
after some looking i cant see how to make subs in purebasic using Sub routin() The only sub thing is Gosub, and gosub uses labels.
Since labels are used for more than subroutines, such as goto and adressing of variables and procedures, and include binarie's.
So you want to fold every labels, wich i would not recommend

"Sub" or "Subroutine"
==============
The current syntax for calling a subroutine is
Gosub MyLabel
The subroutine is identified by the label
Mylabel:
Code goes here
Return
What I am proposing is that the call remains the same, so no compatibility issues and that the word Sub is optional in front of the label.
Sub Mylabel:
Code goes here
Return
The compiler disregards the word "Sub" and uses the label that follows; it treats existing code the same way, so no backward compatibility issues here.
Intelligent editors can fold from the word Sub until and including the word Return, just like they fold from Procedure to EndProcedure.
My pet topic... (Rant warning ON)
=========
The editor is the tool that makes you creative, you use it more than any other tool so I am in favour of any item that simplifies editing, reduces screen clutter and catches errors. jaPBe has started taking this route and I hope it continues that way. Also, have a look at Power Basic's SED, it is also a community developed editor that runs rings around the "official" editor... it shares a lot with jaBPe, is ahead in some places and behind in others (very specifically auto unindent, which jaPBe has in a basic form)
Have a look at the GFA editor (free to try at GFA.net, BUT is only 16 bit and shows its age) Eight years of almost solid use tells me good folding improves productivity. F11 folds and unfolds routines (Functions AND Procedures) at the cursor, F12 folds and unfolds the current routine and all subsequent. It is perfectly practical to acheive a listing that has a comment or two and everyting folded thereafter.
Rant warning OFF.
==============
The current syntax for calling a subroutine is
Gosub MyLabel
The subroutine is identified by the label
Mylabel:
Code goes here
Return
What I am proposing is that the call remains the same, so no compatibility issues and that the word Sub is optional in front of the label.
Sub Mylabel:
Code goes here
Return
The compiler disregards the word "Sub" and uses the label that follows; it treats existing code the same way, so no backward compatibility issues here.
Intelligent editors can fold from the word Sub until and including the word Return, just like they fold from Procedure to EndProcedure.
My pet topic... (Rant warning ON)
=========
The editor is the tool that makes you creative, you use it more than any other tool so I am in favour of any item that simplifies editing, reduces screen clutter and catches errors. jaPBe has started taking this route and I hope it continues that way. Also, have a look at Power Basic's SED, it is also a community developed editor that runs rings around the "official" editor... it shares a lot with jaBPe, is ahead in some places and behind in others (very specifically auto unindent, which jaPBe has in a basic form)
Have a look at the GFA editor (free to try at GFA.net, BUT is only 16 bit and shows its age) Eight years of almost solid use tells me good folding improves productivity. F11 folds and unfolds routines (Functions AND Procedures) at the cursor, F12 folds and unfolds the current routine and all subsequent. It is perfectly practical to acheive a listing that has a comment or two and everyting folded thereafter.
Rant warning OFF.
I see nothing wrong with having distinct methods for a section of code that performs some work and a section of code that performs some work and return a value. In GFA (16 bit) they were called "procedures" and "functions", respectively. I used them both. In Pure Basic they are "subroutines" and "procedures". (Even the terminology is inconsisten, but I doubt it matters.)
The case I am making is that editing is vastly easier when you can fold finished code sections so you are able to concentrate on new things. This becomes much easier if the editor can fold procedures AND subroutines; and that currently there is no reserved word to identify the start of a subroutine; thus the editor has difficulty identifying the start of a subroutine and commence folding.
Placing the word "Sub" (or anything else you choose) before a subroutine clearly identifies its purpose and would make no difference to the overall philosophy of Pure Basic. It is benign, it clarifies the purpose of the section of code that follows and could be usefully exploited by editors.
In the past I wrote editors that used #Fold and #EndFold. On slow scrolling, small screens this cut down the amount of time to scroll around the source file. Nowdays the screens are bigger and faster but the files have also grown!
The case I am making is that editing is vastly easier when you can fold finished code sections so you are able to concentrate on new things. This becomes much easier if the editor can fold procedures AND subroutines; and that currently there is no reserved word to identify the start of a subroutine; thus the editor has difficulty identifying the start of a subroutine and commence folding.
Placing the word "Sub" (or anything else you choose) before a subroutine clearly identifies its purpose and would make no difference to the overall philosophy of Pure Basic. It is benign, it clarifies the purpose of the section of code that follows and could be usefully exploited by editors.
In the past I wrote editors that used #Fold and #EndFold. On slow scrolling, small screens this cut down the amount of time to scroll around the source file. Nowdays the screens are bigger and faster but the files have also grown!
In PB the GFA "procedures" and "functions" is replaced with just 'procedure'.In GFA (16 bit) they were called "procedures" and "functions", respectively. I used them both. In Pure Basic they are "subroutines" and "procedures". (Even the terminology is inconsisten, but I doubt it matters.)
Coming from GFA you should check out the survival guide from a former GFA programmer:
http://www.xs4all.nl/~bluez/datatalk/purebasic.htm#top
I guess that GFA's syntax of GOSUB name, [parameters] and the named routine terminating with RETURN qualifies it as a subroutine call.
Also GFA's FUNCTION uses syntax like Bottles = @CountBottles()
FUNCTION CountBottles()
Code here............
RETURN NumberOf Bottles
ENDFUNC
... qualifies as a FUNCTION.
Regardless of the details of Subroutine / Procedure / Function syntax my point about putting SUB at the front of a SUBROUTINE in PB still stands.
"It is benign, it clarifies the purpose of the section of code that follows and could be usefully exploited by editors."
Enough.
Also GFA's FUNCTION uses syntax like Bottles = @CountBottles()
FUNCTION CountBottles()
Code here............
RETURN NumberOf Bottles
ENDFUNC
... qualifies as a FUNCTION.
Regardless of the details of Subroutine / Procedure / Function syntax my point about putting SUB at the front of a SUBROUTINE in PB still stands.
"It is benign, it clarifies the purpose of the section of code that follows and could be usefully exploited by editors."
Enough.
i'm a former gfa user as well, may i ask why you'd like to use sub's instead of procedures?
(i assume you're using japbe, as any gfa programmer is wont to do, i suppose
)
(i assume you're using japbe, as any gfa programmer is wont to do, i suppose

( 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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
OK... I'm a happy bunny
Thanks to caos.kin I have a solution that works with jaPBe
There are some folding instructions that can fold any section of code. In this simple example I want to fold a subroutine, so ;{ and ;} are placed as shown and the subroutine labelled Total: gets folded.
BRILLIANT... andother jaPBe gem!
Total: ;{- Subroutine to total Items
Total = 0
For n=1 To 10
Total+Item(n)
Next
Return ;}
Here is a snip from caos...
;{ custom fold
;}
;{- Custom Fold+Bookmark
;}
;/Headline

Thanks to caos.kin I have a solution that works with jaPBe
There are some folding instructions that can fold any section of code. In this simple example I want to fold a subroutine, so ;{ and ;} are placed as shown and the subroutine labelled Total: gets folded.
BRILLIANT... andother jaPBe gem!
Total: ;{- Subroutine to total Items
Total = 0
For n=1 To 10
Total+Item(n)
Next
Return ;}
Here is a snip from caos...
;{ custom fold
;}
;{- Custom Fold+Bookmark
;}
;/Headline