function compile error  [SOLVED]

Questions about MultiCharts and user contributed studies.
masterchanger
Posts: 36
Joined: 03 Sep 2013
Location: Chicago, IL
Has thanked: 14 times
Been thanked: 12 times

function compile error

Postby masterchanger » 10 Oct 2020

I get this error and I can't figure out why the top half of the function, which is the same syntax is ok but the bottom half I get an error at line 15, tried closing editor and reopening but same issue. Any help appreciated.

Code: Select all

//Time filter function inputs: StartTime(NumericSimple), EndTime(NumericSimple); If StartTime > EndTime then begin if (Time > StartTime and Time < 2359) or (Time >= 000 and Time < EndTime) then BoxTime = true Else BoxTime = false; End; End; If StartTime < EndTime then Begin If (Time > StartTime and Time < EndTime) then BoxTime = True Else BoxTime = False; End; End;
https://www.screencast.com/t/Ps10tRdCEvF
Image

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: function compile error

Postby TJ » 10 Oct 2020

If you format your code this way
ie with the BEGIN at the left edge,
then you can see the matching END,
and you will never have mismatched BEGIN and ENDs.

Code: Select all

//Time filter function inputs: StartTime(NumericSimple), EndTime(NumericSimple); If StartTime > EndTime then BEGIN if (Time > StartTime and Time < 2359) or (Time >= 000 and Time < EndTime) then BoxTime = true Else BoxTime = false; END; If StartTime < EndTime then BEGIN If (Time > StartTime and Time < EndTime) then BoxTime = True Else BoxTime = False; END;

McGeorge
Posts: 49
Joined: 22 Jun 2018
Has thanked: 10 times
Been thanked: 6 times

Re: function compile error

Postby McGeorge » 03 Nov 2020

I get this error and I can't figure out why the top half of the function, which is the same syntax is ok but the bottom half I get an error at line 15, tried closing editor and reopening but same issue. Any help appreciated.

Code: Select all

//Time filter function inputs: StartTime(NumericSimple), EndTime(NumericSimple); If StartTime > EndTime then begin if (Time > StartTime and Time < 2359) or (Time >= 000 and Time < EndTime) then BoxTime = true Else BoxTime = false; End; End; If StartTime < EndTime then Begin If (Time > StartTime and Time < EndTime) then BoxTime = True Else BoxTime = False; End; End;
https://www.screencast.com/t/Ps10tRdCEvF
Image
An If Else statement, if written in one sentence, should be "If xxx Then xxx Else xxx;". There should not be an "End;" at the end. You made the same mistake two times in your codes.

masterchanger
Posts: 36
Joined: 03 Sep 2013
Location: Chicago, IL
Has thanked: 14 times
Been thanked: 12 times

Re: function compile error  [SOLVED]

Postby masterchanger » 05 Nov 2020

Thanks!


Return to “MultiCharts”