<div dir="ltr">Hi all!<div><br></div><div>I want to extend some operators in Freepascal. I want to achieve something like this:</div><div><br></div><div>if aStr in ['string item 1', 'string item 2', 'string item 3'] then</div><div> ...</div><div>else</div><div> ...;</div><div><br></div><div>Following the examples to overload operators, I wrote:</div><div><br></div><div><div>operator in (a:String; b:array of string):Boolean;</div><div>var</div><div> c: Integer;</div><div>begin</div><div> Result:=false;</div><div> for c:=0 to High(b) do</div><div> if b[c]=a then begin</div><div> result:=true;</div><div> exit;</div><div> end;</div><div>end;</div></div><div><br></div><div>But when I try compile this piece of code:</div><div><br></div><div><div>if aStr in ['string item 1', 'string item 2', 'string item 3'] then</div><div> ...</div><div>else</div><div> ...;</div></div><div><br></div><div>I got:</div><div><br></div><div>Error: Ordinal expression expected<br></div><div><br></div><div>Looking to Freepascal documentation, IN operator overloading is possible:</div><div><br></div><div><a href="https://www.freepascal.org/docs-html/ref/refse104.html">https://www.freepascal.org/docs-html/ref/refse104.html</a><br></div><div><br></div><div>So if the overloading is possible, Is possible to get this example working?</div><div><div><div><div><br></div>-- <br><div class="gmail_signature">The best regards,<br><br>Fabio Luis Girardi<br>PascalSCADA Project<br><a href="http://sourceforge.net/projects/pascalscada" target="_blank">http://sourceforge.net/projects/pascalscada</a><br><a href="http://www.pascalscada.com" target="_blank">http://www.pascalscada.com</a></div>
</div></div></div></div>