Page 2 of 2

Re: howto with function, if possible.

Posted: Fri Dec 23, 2022 3:22 pm
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.

Re: howto with function, if possible.

Posted: Fri Dec 23, 2022 3:55 pm
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 :)

Re: howto with function, if possible.

Posted: Fri Dec 23, 2022 3:59 pm
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!

Re: howto with function, if possible.

Posted: Fri Dec 23, 2022 4:30 pm
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).

Re: howto with function, if possible.

Posted: Fri Dec 23, 2022 6:22 pm
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.

Re: howto with function, if possible.

Posted: Fri Dec 23, 2022 7:57 pm
by hugblue
Thanks all ..

And sorry for continuing with the openGPT thing.

Re: howto with function, if possible.

Posted: Fri Dec 23, 2022 11:22 pm
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!

Re: howto with function, if possible.

Posted: Sat Dec 24, 2022 11:08 am
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.

Re: howto with function, if possible.

Posted: Sat Dec 24, 2022 11:46 am
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'

Re: howto with function, if possible.

Posted: Sat Dec 24, 2022 1:15 pm
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.

Re: howto with function, if possible.

Posted: Sat Dec 24, 2022 1:24 pm
by mk-soft
Google search example:
functions site:purebasic.fr

Re: howto with function, if possible.

Posted: Sat Dec 24, 2022 3:54 pm
by Olli

Code: Select all

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