Page 38 of 42
Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 15, 2022 5:38 am
by jacdelad
@plouf: What if I create an include file which us used by someone else? I don't know what value the other person set.
Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 15, 2022 8:31 am
by BarryG
Rename any global variables that you get from someone else. It's what I did for some "eval(string$)" code I got from somone. I renamed all the variables and procedures in it to be prefixed with "MyCompanyMyAppname_" so it won't clash with any of my existing code or any future code from others.
Alternatively wrap it in a module so it doesn't clash.
Re: PureBasic 6.00 Beta 10 released !
Posted: Thu Jun 16, 2022 4:40 am
by plouf
jacdelad wrote: Wed Jun 15, 2022 5:38 am
@plouf: What if I create an include file which us used by someone else? I don't know what value the other person set.
if you create an include file, would not use ANY other variables?
based in your logic if your include has a function with same name of other person own fucntion ?
my point is, that an include /dll has "guidelines" for other persons to use and a well named declared variable called "global httptimeoutvalue.l"
is really difficult to mean anythink else
Re: PureBasic 6.00 Beta 10 released !
Posted: Thu Jun 16, 2022 2:04 pm
by jacdelad
Wouldn't it be easier to simply receive the timeout instead of proposing global variables and "the programmer should follow this or that"?
Re: PureBasic 6.00 Beta 10 released !
Posted: Thu Jun 16, 2022 3:14 pm
by RichAlgeni
Fred wrote: Thu Jun 09, 2022 8:37 pm
Code: Select all
- Added: HTTPTimeout() for HttpRequest commands (reverted the changes from beta 9)
Thinking about this, I do not believe this is best practice. For single threaded apps, it is probably fine. But for multi-threaded apps, I can envision this causing multiple headaches.
You NEVER want to change the number of parameters passed to a procedure. And you never want a global command to set parameters in a thread, unless they are defaults, and can be overridden per thread.
Given this, I would rather see two new commands, which include the extra parameters for timeout variables.
Re: PureBasic 6.00 Beta 10 released !
Posted: Mon Jun 20, 2022 1:32 pm
by Fred
I will just remove the command and do it in a future release as it needs more thinking.
Re: PureBasic 6.00 Beta 10 released !
Posted: Mon Jun 20, 2022 5:02 pm
by RichAlgeni
Fred wrote: Mon Jun 20, 2022 1:32 pm
I will just remove the command and do it in a future release as it needs more thinking.
This was the right decision.
Re: PureBasic 6.00 Beta 10 released !
Posted: Tue Jun 21, 2022 6:57 am
by Rinzwind
Timeout as a parameter with a default value to procedures where it was severely missed since beginning would be the right decision. Btw, We had breaking changes frequently in PB during the years.
Re: PureBasic 6.00 Beta 10 released !
Posted: Tue Jun 21, 2022 12:21 pm
by the.weavster
Imo having it as a global setting is better than not having it at all

Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 22, 2022 8:26 am
by infratec
There is definately no problem adding the OPTIONAL parameter timeout as the last one in the command.
It will break nothing and if needed you can fill the parameters before with 0 or #Null or the requested default values.
I was amazed that Fred placed it somewhere in between which definately breaks old code.
Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 22, 2022 8:34 am
by jacdelad
I also think it would be the best just add another parameter at the end. Full compatibility plus full control for every single download, no matter if it's done in the main program or an include or whatever.
Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 22, 2022 8:36 am
by PureBasti
infratec wrote: Wed Jun 22, 2022 8:26 am
There is definately no problem adding the OPTIONAL parameter timeout as the last one in the command.
It will break nothing and if needed you can fill the parameters before with 0 or #Null or the requested default values.
I also think THIS option is the best!!!

Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 22, 2022 10:43 am
by Fred
infratec wrote: Wed Jun 22, 2022 8:26 am
There is definately no problem adding the OPTIONAL parameter timeout as the last one in the command.
It will break nothing and if needed you can fill the parameters before with 0 or #Null or the requested default values.
I was amazed that Fred placed it somewhere in between which definately breaks old code.
You can't pass #Null or 0 to a Map parameter for now, that's why I switched it as you would need to always create an empty map. I will probably add the possibility to pass #Null for a map but it requiers a compiler change, so it's postponed for next version.
Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 22, 2022 1:30 pm
by User_Russian
Fred wrote: Wed Jun 22, 2022 10:43 amYou can't pass #Null or 0 to a Map parameter for now, that's why I switched it as you would need to always create an empty map.
I think the solution may be like that.
https://www.purebasic.fr/english/viewtopic.php?t=79379 Code: Select all
Procedure Proc(Array a(1), List l(), Map m())
If IsArray(a())
; This code will be executed if the Array is valid.
EndIf
If IsList(l())
; This code will be executed if the List is valid.
EndIf
If IsMap(m())
; This code will be executed if the Map is valid.
EndIf
EndProcedure
Proc(0, 0, 0)
https://www.purebasic.fr/english/viewtopic.php?t=79379
Re: PureBasic 6.00 Beta 10 released !
Posted: Wed Jun 22, 2022 1:46 pm
by NicTheQuick
A good solution would be named parameters:
Code: Select all
HttpRequest = HTTPRequest(#PB_HTTP_Get, "https://www.google.com", "", 0, timeout=30000)
This way optional parameters could be set by name in any order like Python can do it. And if names are not given the original order is assumed so it would not break old code.