howto with function, if possible.

Just starting out? Need help? Post your questions and find answers here.
hugblue
New User
New User
Posts: 6
Joined: Tue Oct 11, 2022 12:24 pm

Re: howto with function, if possible.

Post by hugblue »

Little John wrote: Fri Dec 23, 2022 2:45 am
hugblue wrote: Thu Dec 22, 2022 10:11 pm Looked in the manual first.
Then i came here.

And i do know about procedures.
You know about procedures?
And what did you read in the manual about functions?
Hi ..

I thought it would have been great if the chatGPT had been better.
It could have accelerated the learning processes.

When i looked into functions and procedures. I think they looked very alike. But chatGPT kept saying that purebasic uses functions.

So :

procedure :
A code module, sub-routine. with its own code or shared.
A building block separated until called and needed.

Functions :
I believe this is somehow equal to procedures. Problably also why it is not in purebasic.

Normally. I have not programmed so much. Mostly used Macro Toolworks. Where i can just move building block around, insert data into the blocks. Kinda. But that is not enough anymore.

Now i have looked into Purebasic. Wished there were more books, that described everything from beginner to advanced and books with lots of exercises and solutions, to quickly getting everything into routine.
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: howto with function, if possible.

Post by Mijikai »

hugblue wrote: Fri Dec 23, 2022 3:22 pm Wished there were more books, that described everything from beginner to advanced and books with lots of exercises and solutions, to quickly getting everything into routine.
There are many examples for beginners and more advanced coders available through the Help/Documentation
or as source code in the Examples Directory.

PB provides excellent Help/Documentation within the IDE or Online (with many source code examples):https://www.purebasic.com/documentation/index.html

PB Reference:
https://www.purebasic.com/documentation/PureBasic.pdf

Not to mention that the forum itself has many useful tips, tricks and examples.
So there is a ton of help and code available :)
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: howto with function, if possible.

Post by Little John »

hugblue wrote: Fri Dec 23, 2022 3:22 pm I thought it would have been great if the chatGPT had been better.
It could have accelerated the learning processes.

When i looked into functions and procedures. I think they looked very alike. But chatGPT kept saying that purebasic uses functions.
ChatGPT is not a reference for PureBasic. And this is not the proper place for discussing ChatGPT issues.
You could post those problems on a ChatGPT forum, if they have one.
Mijikai wrote: Fri Dec 23, 2022 3:55 pm So there is a ton of help and code available :)
Exactly!
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: howto with function, if possible.

Post by Marc56us »

For the general culture of ChatGPT :mrgreen:
Many of us started / learned coding with the Pascal language.
In Pascal:
- A procedure is a subprogram
- A function is a subprogram that transforms a data
So a function alway get and return value ( i.e: Sin(x) ) a procedure can but not necessary

PB uses the Procedure keyword for both, many languages use Function or any other for both (i.e Perl use Sub).
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: howto with function, if possible.

Post by juergenkulow »

Marc56us wrote: Fri Dec 23, 2022 4:30 pmSo a function alway get and return value ( i.e: Sin(x) ) a procedure can but not necessary

Code: Select all

// Procedure Proc()
static integer f_proc() {
integer r=0;
// EndProcedure
r=0;
end:
return r;
}

Code: Select all

; Procedure Proc()
_Procedure0:
  PS0=48
  SUB    rsp,40
; EndProcedure
_EndProcedureZero1:
  XOR    rax,rax
_EndProcedure1:
  ADD    rsp,40
  RET
XOR rax,rax is 0. Procedure returns rax with the value 0.
Please ask your questions, because switch on the cognition apparatus decides on the only known life in the universe.Wersten :DDüsseldorf NRW Germany Europe Earth Solar System Flake Bubble Orionarm
Milky Way Local_Group Virgo Supercluster Laniakea Universe
hugblue
New User
New User
Posts: 6
Joined: Tue Oct 11, 2022 12:24 pm

Re: howto with function, if possible.

Post by hugblue »

Thanks all ..

And sorry for continuing with the openGPT thing.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: howto with function, if possible.

Post by jacdelad »

You seem to be not a bot (which is suspected first), so be welcomed in this forum and feel free to ask everything!
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
hugblue
New User
New User
Posts: 6
Joined: Tue Oct 11, 2022 12:24 pm

Re: howto with function, if possible.

Post by hugblue »

jacdelad wrote: Fri Dec 23, 2022 11:22 pm You seem to be not a bot (which is suspected first), so be welcomed in this forum and feel free to ask everything!
I come here to learn.

What would be the point to use a bot ? Makes no sense.
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: howto with function, if possible.

Post by mk-soft »

Welcome
hugblue wrote: Sat Dec 24, 2022 11:08 am What would be the point to use a bot ? Makes no sense.
There is no point in using bots. Except to annoy us here.

Unfortunately, we have already had advertising bots here and probably chat bots as well.

P.S.
New bots again. See forum 'General Discussion'
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Axolotl
Enthusiast
Enthusiast
Posts: 798
Joined: Wed Dec 31, 2008 3:36 pm

Re: howto with function, if possible.

Post by Axolotl »

Welcome hugblue,

yes, this is a great place to learn purebasic.
Many questions have already been asked and also answered. Therefore, it is always a good idea to try the search first.
Sometimes also the search via a (large) search engine gives better results than the search here in the forum.

Merry christmas, happy coding and stay healthy.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: howto with function, if possible.

Post by mk-soft »

Google search example:
functions site:purebasic.fr
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Olli
Addict
Addict
Posts: 1196
Joined: Wed May 27, 2020 12:26 pm

Re: howto with function, if possible.

Post by Olli »

Code: Select all

Procedure.i Sum(a.i, b.i)
   ProcedureReturn a + b
EndProcedure
Post Reply