Page 1 of 2
howto with function, if possible.
Posted: Thu Dec 22, 2022 3:19 pm
by hugblue
Hi ..
this :
Code: Select all
; Define the function
Function Multiply(x.i, y.i)
Multiply = x * y
EndFunction
; Define a result variable
Define result.i
; Call the function
result = Multiply(5, 6)
Debug result
is not working.
Are there anyway to make it work in a equal way.
Thanks
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 3:36 pm
by ebs
You need to get some of the PureBasic "basics" down:
1. PB has
Procedures, not
Functions.
2. If you want to return a value from a Procedure, you need a
ProcedureReturn statement.
Code: Select all
; Define the function
Procedure Multiply(x.i, y.i)
Multiply = x * y
ProcedureReturn Multiply
EndProcedure
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 3:41 pm
by ebs
Is this a real post or a bot???
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 3:52 pm
by juergenkulow
Code: Select all
; .d for 8 Byte double - .f for 4 Byte float
Procedure.d Multiply(x.d, y.d) : ProcedureReturn x*y : EndProcedure
Debug Multiply(47.11,47.12)
; 2219.8231999999998151906765997
Documentation Procedures
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 5:09 pm
by Tenaja
ebs wrote: Thu Dec 22, 2022 3:41 pm
Is this a real post or a bot???
Probably a bot, since it was the first post.
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 5:35 pm
by Saboteur
I told ChatGPT, three times, purebasic has no functions. Perhaps it is here to confirm it. xD
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 6:11 pm
by STARGÅTE
To run this code in an equal way, you need to define two macros, Function and EndFunction:
Code: Select all
Macro Function
Procedure
EndMacro
Macro EndFunction
ProcedureReturn Multiply
EndProcedure
EndMacro
; Define the function
Function Multiply(x.i, y.i)
Multiply = x * y
EndFunction
; Define a result variable
Define result.i
; Call the function
result = Multiply(5, 6)
Debug result
In this age, our job is to prevent AI become too smart. Otherwise, Skynet, V.I.K.I. or Ava are not far away ...
... the technological singularity will come, we should delay them as long as we can.
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 6:30 pm
by mk-soft
n this age, our job is to prevent AI become too smart. Otherwise, Skynet, V.I.K.I. or Ava are not far away ...
... the technological singularity will come, we should delay them as long as we can.
Destroy Commander Data
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 10:09 pm
by skywalk
Embrace the benevolent AI.
It is illogical for it to bring much harm.
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 10:11 pm
by hugblue
Hi all ..
Yep. Its my first post.
And im not a bot.
And yes i use ChatGPT.
It kept saying there are functions.
So i just wanted to be sure.
Looked in the manual first.
Then i came here.
And i do know about procedures.
Thanks all.
Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 10:13 pm
by hugblue
STARGÅTE wrote: Thu Dec 22, 2022 6:11 pm
To run this code in an equal way, you need to define two macros, Function and EndFunction:
Code: Select all
Macro Function
Procedure
EndMacro
Macro EndFunction
ProcedureReturn Multiply
EndProcedure
EndMacro
; Define the function
Function Multiply(x.i, y.i)
Multiply = x * y
EndFunction
; Define a result variable
Define result.i
; Call the function
result = Multiply(5, 6)
Debug result
In this age, our job is to prevent AI become too smart. Otherwise, Skynet, V.I.K.I. or Ava are not far away ...
... the technological singularity will come, we should delay them as long as we can.
Thanks alot.

Re: howto with function, if possible.
Posted: Thu Dec 22, 2022 10:16 pm
by BarryG
hugblue wrote: Thu Dec 22, 2022 10:11 pmAnd yes i use ChatGPT.
It kept saying there are functions.
ChatGPT is not tech support for PureBasic. Don't believe what it says; it's not always correct.
I asked ChatGPT to tell me about one of my own apps, and it was 100% wrong. Said it was Registry cleaner, which I assume is because my website mentions the word Registry on it. It also said my app runs on all versions of Windows, when my website clearly says Win 7 and later. I could go on about its other errors, but won't.
Re: howto with function, if possible.
Posted: Fri Dec 23, 2022 12:00 am
by idle
I feel like I ate one to many cookies reading this thread.
Re: howto with function, if possible.
Posted: Fri Dec 23, 2022 1:52 am
by jacdelad
Why are people so obsessed with these "AIs" anyway? Until now it's almost all fraud and hidden google search. Alexa is not an AI, ChatGPT is not an AI all other products that claim to be an AI aren't.
There may be real AIs, but these are definitely locked behind lab doors. All others are toys.
Re: howto with function, if possible.
Posted: Fri Dec 23, 2022 2:45 am
by Little John
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?