- blinking a led: Delphi PCHAR->CP array?

From: Douglas G. Danforth <"Douglas>
Date: Mon, 29 May 2006 11:53:31 -0400

----boundary-LibPST-iamunique-1575147694_-_-
Content-type: text/plain

Frans,
I find that in Delphi

  type : Char = #0..#255;

which is 8 bits. A CHAR in Component Pascal is 16 bits.
A SHORTCHAR is 8 bits. Try using SHORTCHAR.

-Doug Danforth


frans-pietervonck{([at]})nowhere.xy
> Hello Blackboxers,
>
> I want to blink a led using using Kainka's "PC Interfaces under Windows".
> The book comes with a dll - PORT.DLL - which enables communication
> with the serial ports under XP.
> With Delphi the led blinks. In BlackBox, I can't get it light. I
> suspect that my way of translating the delphi PCHAR-type
> into an array is not correct. Can I use an array as an null terminated
> string? Anyone some advice?
>
> In delphi, opening the com-port is done as follows.
>
> Function OPENCOM(S:PCHAR):Integer;stdcall; external PORT.DLL;
>
> for example: OpenCom (Pchar('COM1:9600,N,8,1'));
> OpemCom returns a 1 when connected, 0 when failed.
>
> Following my the translation of the function to component pascal
>
> INTERFACE:
> constr* = ARRAY 18 OF CHAR;
> PROCEDURE opencom* ["OPENCOM"]
> (Constr:constr) : INTEGER;
>
> TESTFUNCTION:
> open := PortDLL.opencom("COM1:9600,N,8,1");
>
>
>
> The two modules I've used.
> -----------------------
> INTERFACE
> ----------------------
> MODULE PortDLL ["PORT.DLL"];
> IMPORT SYSTEM;
> TYPE
>
> constr* = ARRAY 18 OF CHAR;
>
> PROCEDURE opencom* ["OPENCOM"]
> (Constr:constr) : INTEGER;
>
> END PortDLL.
>
> ----------------------------------
> TESTMODULE
> ----------------------------------
> MODULE TestPort;
>
> IMPORT PortDLL, StdLog;
> VAR open: INTEGER;
> PROCEDURE Do*;
> BEGIN
> open := 3;
> open := PortDLL.opencom("COM1:9600,N,8,1");
> IF open = 1 THEN
> StdLog.String("Opening COM1 successful. "); StdLog.Ln
> END;
> IF open = 0 THEN
> StdLog.String("Opening COM1 failed."); StdLog.Ln
> END;
> END Do;
>
> END TestPort.
> -----------------------------------
>
> --- BlackBox
> --- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
>
>

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-1575147694_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEZyYW5zLFxwYXINCkkgZmluZCB0aGF0IGluIERl
bHBoaVxwYXINClxwYXINCiAgdHlwZSA6IENoYXIgPSAjMC4uIzI1NTtccGFyDQpccGFyDQp3aGlj
aCBpcyA4IGJpdHMuICBBIENIQVIgIGluIENvbXBvbmVudCBQYXNjYWwgaXMgMTYgYml0cy5ccGFy
DQpBIFNIT1JUQ0hBUiBpcyA4IGJpdHMuICBUcnkgdXNpbmcgU0hPUlRDSEFSLlxwYXINClxwYXIN
Ci1Eb3VnIERhbmZvcnRoXHBhcg0KXHBhcg0KXHBhcg0KZnJhbnMtcGlldGVydm9uY2tAaGV0bmV0
Lm5sIHdyb3RlOlxwYXINCj4gSGVsbG8gQmxhY2tib3hlcnMsXHBhcg0KPlxwYXINCj4gSSB3YW50
IHRvIGJsaW5rIGEgbGVkIHVzaW5nIHVzaW5nIEthaW5rYSdzICJQQyBJbnRlcmZhY2VzIHVuZGVy
IFdpbmRvd3MiLlxwYXINCj4gVGhlIGJvb2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MCxOLDgsMSIpO1xwYXINCj4gICAgICAgIElGIG9wZW4gPSAxIFRIRU5ccGFyDQo+ICAg
ICAgICAgICAgU3RkTG9nLlN0cmluZygiT3BlbmluZyBDT00xIHN1Y2Nlc3NmdWwuICIpOyBTdGRM
b2cuTG5ccGFyDQo+ICAgICAgICBFTkQ7XHBhcg0KPiAgICAgICAgSUYgb3BlbiA9IDAgVEhFTlxw
YXINCj4gICAgICAgICAgICBTdGRMb2cuU3RyaW5nKCJPcGVuaW5nIENPTTEgZmFpbGVkLiIpOyBT
dGRMb2cuTG5ccGFyDQo+ICAgICAgICBFTkQ7XHBhcg0KPiAgICBFTkQgRG87XHBhcg0KPlxwYXIN
Cj4gRU5EIFRlc3RQb3J0LlxwYXINCj4gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS1ccGFyDQo+XHBhcg0KPiAtLS0gQmxhY2tCb3hccGFyDQo+IC0tLSBzZW5kIHN1YmplY3QgSEVM
UCBvciBVTlNVQlNDUklCRSB0byBibGFja2JveEBvYmVyb24uY2hccGFyDQo+XHBhcg0KPlxwYXIN
ClxwYXINCi0tLSBCbGFja0JveFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlND
UklCRSB0byBibGFja2JveEBvYmVyb24uY2hccGFyDQp9fQAwNiAx


----boundary-LibPST-iamunique-1575147694_-_---
Received on Mon May 29 2006 - 17:53:31 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:57 UTC