<br><br><div class="gmail_quote">On 12 September 2010 13:05, Vincent Snijders <span dir="ltr"><<a href="mailto:vincent.snijders@gmail.com">vincent.snijders@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
2010/9/12 Frank Church <<a href="mailto:vfclists@gmail.com">vfclists@gmail.com</a>>:<br>
<div class="im">> I need to elaborate more on this code<br>
><br>
> On this line<br>
><br>
> d := stTypes[i - Ord(low(stType))];<br>
><br>
> since stTypes is an array, I expect stTypes[n], with n being 1 to 4, to<br>
> retrieve an array value and as 'i - Ord(low(stType)) evaluates to integer it<br>
> should compile but it generates an error.<br>
><br>
> What would be the correct way?<br>
><br>
> On 12 September 2010 12:51, Frank Church <<a href="mailto:vfclists@gmail.com">vfclists@gmail.com</a>> wrote:<br>
>><br>
>> program testnums;<br>
>> //{$APPTYPE CONSOLE}<br>
>><br>
>> uses<br>
>> Classes, SysUtils;<br>
>> type<br>
>> stType = (stLite := -100, stDb, stBothLite, stBothDb); //settings<br>
>> location Type<br>
>> stTypes = Array [stType] of integer;<br>
>> var<br>
>> d : stType;<br>
>> s : string;<br>
>> i : integer;<br>
<br>
>> begin<br>
>> writeln('');<br>
>> for i := Ord(low(stType)) to Ord(high(stType)) do<br>
</div>for d:= low(stType) to high(stType) do<br>
<div class="im"><br>
>> begin<br>
>> d := stTypes[i - Ord(low(stType))];<br>
</div>i := stTypes[d];<br>
<div class="im">>> writestr(s,d);<br>
>> writeln(d + ' ' + IntToStr(Integer(i)));<br>
>> end;<br>
>> readln;<br>
>><br>
>> end.<br>
>><br>
>> --<br>
>> Frank Church<br>
>><br>
>> =======================<br>
>> <a href="http://devblog.brahmancreations.com" target="_blank">http://devblog.brahmancreations.com</a><br>
><br>
><br>
><br></div></blockquote><div><br>Does that mean that although an enum is an ordinal type, an integer cannot be coerced into using it to index an array?<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">
> --<br>
> Frank Church<br>
><br>
> =======================<br>
> <a href="http://devblog.brahmancreations.com" target="_blank">http://devblog.brahmancreations.com</a><br>
><br>
</div><div><div></div><div class="h5">> _______________________________________________<br>
> fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
> <a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
><br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Frank Church<br><br>=======================<br><a href="http://devblog.brahmancreations.com">http://devblog.brahmancreations.com</a><br>