Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (RealSerious3D, AndrewAMD, chsmac85, dr_panther, TedMar), 942 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Optional parameters in functions #479977
05/11/20 07:44
05/11/20 07:44
Joined: Feb 2016
Posts: 15
Milan, Italy
F
fsgi Offline OP
Newbie
fsgi  Offline OP
Newbie
F

Joined: Feb 2016
Posts: 15
Milan, Italy
I wanted to ask wheter (and how) is it possible to code optional parameters in Zorro functions, like in C/C++ something like
Code
void myfunction(int par1, double par2 = 3.14) {...}

where of course par2 is optional (i.e. it has the defatult value 3.14 if the client does not specifies anything else).

It looks like that Zorro clearly uses optional parameters but I have not found any spec about it in the manual.

In addition, always in the manual, it is very (very very) hard to get a clear-cut, immediate understanding of wich parameters are optional. Take for instance the description of the lhour function:

Quote
lhour (int zone, int offset): int
Closing local hour of the given bar in the given time zone (see timeOffset below), considering daylight saving time (see dst below). F.i. lhour(EST) returns the current hour at the New York Stock Exchange.


From the example in the description it is then obvious that int offset is optional (and... obviously = 0). But for more complex functions wouldn't be nicer to include in the reference which are the parameters that can be omitted and how do they get assigned by default (e.g. indicating them with the "= xyz" label, or, I don't know... putting them at least in italic)?

Thank you in advance.

Re: Optional parameters in functions [Re: fsgi] #479979
05/11/20 08:51
05/11/20 08:51
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Lite-C has no optional parameters, but supports overriding. That's used for omitting parameters in some Zorro functions.

void myfunction(int par1, double par2) {...}

void myfunction(int par1) { myfunction(par1,3.14); }

The optional parameters in the manual are in italics.

Re: Optional parameters in functions [Re: fsgi] #479987
05/11/20 12:24
05/11/20 12:24
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
Nice example of that is in the CCY scripts of Petra on the finacial hacker.

Re: Optional parameters in functions [Re: fsgi] #479989
05/11/20 16:28
05/11/20 16:28
Joined: Feb 2016
Posts: 15
Milan, Italy
F
fsgi Offline OP
Newbie
fsgi  Offline OP
Newbie
F

Joined: Feb 2016
Posts: 15
Milan, Italy
Thank you so much for the explanation jcl. Meaningful. Please correct the manual, in this case, because lhour offset parameter is NOT italics.

Re: Optional parameters in functions [Re: fsgi] #480002
05/12/20 15:59
05/12/20 15:59
Joined: Feb 2016
Posts: 15
Milan, Italy
F
fsgi Offline OP
Newbie
fsgi  Offline OP
Newbie
F

Joined: Feb 2016
Posts: 15
Milan, Italy
jcl, just on the same line of overloading and basic C-lite (coming from a C++ background)...

In lite-C isn't there anything like templatized functions?

I'm asking because I would like to write some array-manipulation functions (for an #include) and it would be tedious to re-write all of them one for integers, one for doubles, one for strings... you know... Is there any alternative ?

Re: Optional parameters in functions [Re: fsgi] #480003
05/12/20 16:17
05/12/20 16:17
Joined: Feb 2017
Posts: 1,729
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,729
Chicago
Like C, Lite-C has no templates.

You can always use conventional C++ to write strategies:
https://zorro-project.com/manual/en/dlls.htm

In the future, oP group plans on adding "Support for .cpp scripts by directly calling the VC++ compiler and linker." This means you'll be able to do rapid prototyping without having to fire up Visual Studio every time.
https://zorro-project.com/manual/en/new.htm

Re: Optional parameters in functions [Re: fsgi] #480035
05/15/20 09:31
05/15/20 09:31
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
As to the time offset, it's not in italics because it's not optional in the VC++ version.


Moderated by  aztec, Inestical, Matt_Coles, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1