<div dir="ltr">Fair enough. That wasn't entirely clear so thought it worth clarifying in case the OP was confused into thinking this was somehow involved in the AV.<br><br>(Incidentally, "buffer" is used in the original code - it receives the keydata string via the call to StrPCopy. "key" ends up as effectively @buffer[0]).</div><div class="gmail_extra"><br><div class="gmail_quote">On 28 May 2015 at 15:31, Karl Reynolds <span dir="ltr"><<a href="mailto:kreynolds@chocfishsoft.co.nz" target="_blank">kreynolds@chocfishsoft.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Jolyon, I was pointing out a separate error that had nothing to do with the AV he was getting.<span class=""><div><br></div><div><span style="font-size:12.8000001907349px"><i>> there looks to be an error in your code <b>even if it works</b></i></span></div><div><span style="font-size:12.8000001907349px"><b><br></b></span></div></span><div><span style="font-size:12.8000001907349px">Cheers,</span></div><div><span style="font-size:12.8000001907349px">Carl</span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 28, 2015 at 2:43 PM, Jolyon Smith <span dir="ltr"><<a href="mailto:jsmith@deltics.co.nz" target="_blank">jsmith@deltics.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">@Carl, <div><br><div>Although the code probably is incorrect in the way that it references buffer after the call, rather than bufferr, this in itself will not cause an AV since both buffer and bufferr are both statically allocated arrays and thus references to items in these arrays will be valid, even if not correct, as long as those references are within the bounds of the array, which they are in this case.</div></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 28 May 2015 at 12:33, Karl Reynolds <span dir="ltr"><<a href="mailto:kreynolds@chocfishsoft.co.nz" target="_blank">kreynolds@chocfishsoft.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8000001907349px">I don't know the API_PCDRead function. But there looks to be an error in your code even if it works. You are passing bufferr (two 'r's) to the function but referring to buffer (one 'r') afterwards, which wasn't used (unless there's other code you didn't show). So you need to look at that.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">That aside, for the bit leading up to the call, try something like:</span></div><div><br></div><div><span style="font-size:12.8000001907349px">var</span></div><div><span style="font-size:12.8000001907349px"> key, bufferr: PChar;</span></div><div><span style="font-size:12.8000001907349px"> keydata: string;</span></div><div><span style="font-size:12.8000001907349px"> buffdata: array[0..255] of char;</span></div><div><span style="font-size:12.8000001907349px"> ...</span></div><div><span style="font-size:12.8000001907349px">begin</span></div><div><span style="font-size:12.8000001907349px"> // Allocate a string of six consecutive $FFs</span><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"> keydata := #255#255#255#255#255#255;</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"> // Convert to a PChar, an easy way to avoid having to allocate memory explicitly</span><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"> key := PChar(keydata);</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">// </span><span style="font-size:12.8000001907349px">Once again avoid having to allocate memory explicitly</span></div><div><span style="font-size:12.8000001907349px">// Point bufferr at the </span><span style="font-size:12.8000001907349px">address of an </span><span style="font-size:12.8000001907349px">array of </span><span style="font-size:12.8000001907349px">256 characters</span></div><div><span style="font-size:12.8000001907349px"> bufferr := PChar(@buffdata); </span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"> receive:=API_PCDRead(0,0,$00,</span><span style="font-size:12.8000001907349px">10,1,key,bufferr);</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px"> ...</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Cheers,</span></div><div><span style="font-size:12.8000001907349px">Carl</span></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 28, 2015 at 11:33 AM, Marshland Engineering <span dir="ltr"><<a href="mailto:marshland@marshland.co.nz" target="_blank">marshland@marshland.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the replies.<br>
<br>
this is the line<br>
<br>
> receive:=API_PCDRead(0,0,$00,10,1,key,bufferr);<br>
<br>
I'm way out my depth with the workings of this function. I just do simple<br>
coding - A ex dBase3 programmer.<br>
<br>
I took the sample code that the RFID supplier gave, stripped off everything I<br>
didn't need other than the read line for RFID card and then copied the bits<br>
into my program which now crashes.<br>
<br>
I was wondering if the XPMENU call or something like that is interfering with<br>
other modules ?<br>
<br>
My debugging is limited to finding the line with the error.<br>
<br>
Both programs are run in Delphi 6, same machine and same environment.<br>
<br>
I can't find how to code this, where ever I put it, it crashes. - Expected<br>
expression but ARRAY found.<br>
<span><br>
const<br>
KEY = array[0..6] of Byte = ($FF,$FF,$FF,$FF,$FF,$FF,$00);<br>
<br>
</span>Thanks Wallace.<br>
<div><div><br>
<br>
_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br></blockquote></div><br></div>