boris.nihil
-
Content Count
21 -
Joined
-
Last visited
Posts posted by boris.nihil
-
-
-
Does anybody have experience with 2d barcode, TurboPower SysTools, component StPDF417Barcode...
I can't add StPDF417Barcode1.code = '...' witch contains some local letters (ŠĐČĆŽš), it says
"Range check error"...
virm_grad ,virm_adresa ,virm_naziv:string;
virm_naziv := utf8encode('dsdddddd');
virm_adresa := utf8encode('ŠĐŠĐČĆĆČĆČ');
virm_grad := utf8encode('špšpUIZUZUZ');StPDF417Barcode1.Code := 'HRVHUB30' + #13#10 + 'EUR' + #13#10 +
virm_naziv + #10 +
virm_adresa + #10 +
virm_grad + #10;
-
16 hours ago, Skrim said:A big thank you to you Boris, also to Remy.
I also read this thread with great interest, New to JSON.
In addition to the code above I had to paste GetObject and GetValue from New to Json.
I could not have done this on my own.
all thanks goes to Remy
-
function GetValue(JsonObject: TJSONObject; const PairName: string): TJSONValue;
var
JsonPair: TJSONPair;
begin
JsonPair := JsonObject.Get(PairName);
if JsonPair = nil then
raise Exception.Create('Pair "' + PairName + '" not found');
Result := JsonPair.JsonValue;
end;function GetObject(JsonObject: TJSONObject; const PairName: string): TJSONObject;
begin
Result := GetValue(JsonObject, PairName) as TJSONObject;
end;
-
var
JsonValueArr,JsonValue: TJSONValue;
JsonObject: TJSONObject;jasonArr: TJSONArray;
begin
JsonValue := TJSONObject.ParseJSONValue(memoRequest.Lines.Text);
if JsonValue = nil then
begin
ShowMessage('Error');
end else
begin
JsonObject := JsonValue as TJSONObject;
JsonObject := GetObject(JsonObject, 'forretningsadresse');
jasonArr := GetValue(JsonObject, 'adresse') as TJSONArray;
for JsonValueArr in jasonArr do
begin
showmessage(JsonValueArr.Value);
end;end;
end;
-
you are right,
thanks for you help and your time
-
this works ok..
var
jasonArr:TJSONArray;
par: TJSONPair;
i: Integer;
LItem:TJSONValue;
JsonValueArr : TJSONValue;
testValue: TJSONValue;
beginjasonArr := GetValue(JsonObject, 'documentStatus') as TJSONArray;
for JsonValueArr in jasonArr do
begin
for LItem in TJSONArray(JsonValueArr) do
begin
if TJSONPair(LItem).JsonString.Value = 'statusCode' then
odgovorFinaStatus.b2gStatus := TJSONPair(LItem).JsonValue.Value else
if TJSONPair(LItem).JsonString.Value = 'statusText' then
odgovorFinaStatus.b2gStatusTekst := TJSONPair(LItem).JsonValue.Value else
if TJSONPair(LItem).JsonString.Value = 'statusTimestamp' then
odgovorFinaStatus.b2gStatusVrijeme := TJSONPair(LItem).JsonValue.Value else
if TJSONPair(LItem).JsonString.Value = 'note' then
odgovorFinaStatus.b2gStatusNapomena := TJSONPair(LItem).JsonValue.Value else
if TJSONPair(LItem).JsonString.Value = 'partialAmount' then
begin
try
odgovorFinaStatus.b2gDjelIzn := StrToFloat(TJSONPair(LItem).JsonValue.Value);
except
odgovorFinaStatus.b2gDjelIzn := 0
end;
end;
-
when i write
for LItem in TJSONObject(JsonValueArr) do
it says:
[dcc32 Error] Unit1.pas(568): E2010 Incompatible types: 'TJSONValue' and 'TJSONPair'
-
something like this, seems to work:
jasonArr := GetValue(JsonObject, 'documentStatus') as TJSONArray;
for JsonValueArr in jasonArr do
begin
for LItem in TJSONArray(JsonValueArr) do
begin
ShowMessage(TJSONPair(LItem).JsonString.Value + '/' + TJSONPair(LItem).JsonValue.Value);
end;
end;
-
it works fine,thanks
but now i have some array inside object
how to acces this documentStatus element ?
{
"messageAck": {
"messageID": "Middleware_002",
"messageAckID": "a98d281b-9608-4b25-be03-7be0403916dd",
"messageType": 9012,
"ackStatus": "ACCEPTED",
"ackStatusCode": 10,
"ackStatusText": "Message received!"
},
"b2GOutgoingInvoiceStatus": {
"supplierID": "9934:86167814130",
"additionalSupplierID": null,
"invoiceID": 83703,
"supplierInvoiceID": "IR-19-1766-1-1",
"invoiceTimestamp": "28-02-2020",
"documentStatus": [
{
"statusCode": "RECEIVED",
"statusText": "Received",
"statusTimestamp": "28-02-2020",
"note": null,
"partialAmount": null} ]
}
}
-
uh, it's very complicated..
Thank a lot on your effort
-
you are right, from small to big picture
i think this will do:
JSonObject := TJSonObject.Create;
JsonValue := JSonObject.ParseJSONValue(memoRequest.Lines.Text);JsonValue := (JsonValue as TJSONObject).Get('b2GOutgoingInvoiceEnvelope').JSONValue;
JsonValue := (JsonValue as TJSONObject).Get('b2GOutgoingInvoiceProcessing').JSONValue;
JsonValue := (JsonValue as TJSONObject).Get('correctB2GOutgoingInvoice').JSONValue;
JsonValue := (JsonValue as TJSONObject).Get('invoiceID').JSONValue;
-
i can't figure out how to parse json answer from some invoice company
I use Delphi XE4, DBXJSON...
How to get Jsonpairs insde nested objects...
Example:
{
"messageAck": {
"messageID": "Middleware_002",
"messageAckID": "8f50dd66-a77f-45ec-9049-0faadb69ff43",
"messageType": 9002,
"ackStatus": "ACCEPTED",
"ackStatusCode": 10,
"ackStatusText": "Poruka zaprimljena!"
},"b2GOutgoingInvoiceEnvelope": {
"b2GOutgoingInvoiceProcessing": {
"correctB2GOutgoingInvoice": {"supplierInvoiceID": "dokument1","invoiceID": 84001,"invoiceTimestamp": "03-03-2020"},
"incorrectB2GOutgoingInvoice": null}}}
-
ok..thanks a lot for all the help!
-
Thank a lot for a time you spend for this..
Solution 2 with timer works on some way...it's hard to work since i can't play with this device so i need to improvise..
Problem is that timer must work all the time until transaction is complete..
After i received message 'INSERT CARD' timer stops and i can't read anymore.
Could you help me how to send some message from server I made with IdTCPServer1 component
to Client program with some Button on server form ?
Something like "AContext.Connection.IOHandler.Write"...
-
i tryed
IdTCPClient1.IOHandler.InputBuffer.Clear;
IdTCPClient1.IOHandler.Write(s + chr(strtoint(lrc)), IndyTextEncoding_8bit);and then i activate timer:
if IdTCPClient1.IOHandler.InputBufferIsEmpty then
begin
if IdTCPClient1.IOHandler.CheckForDataOnSource(500) then
begin
receivedtext1 := IdTCPClient1.IOHandler.WaitFor(#6,true,true,IndyTextEncoding_8bit);
memo1.SelStart := memo1.GetTextLen;
memo1.SelLength := 0;
memo1.SelText := 'Received ACK:' + receivedtext1 + #13#10;
sleep(500);receivedtext := IdTCPClient1.IOHandler.WaitFor(#3,true,true,IndyTextEncoding_8bit);
memo1.SelStart := memo1.GetTextLen;
memo1.SelLength := 0;
memo1.SelText := 'Received message:' + receivedtext + #13#10;
end; -
>> Though I suspect the POS is actually expecting binary data for the message content, not hex-encoded strings, so try something more like this:
>> s := #2#2'000000000001000'#28'1000'#28#28'+0'#28'191'#28#28#28#28#28#28#28#28#28#28#28'00'#28'1'#12#28#28#28#28#28#28#28#28#3',';
>> IdTCPClient1.IOHandler.Write(s, IndyTextEncoding_8bit);you were right, this works !
But now program hangs for a while waiting for some response or something..
How to receive ACK from POS terminal and other data from POS ?
I need to send ACK after every returned answer from POS..
ECR-->POS: <STX><STX>303030303030303030303031303030<FS>31303030<FS><FS>2B30<FS>313931<FS><FS><FS><FS><FS><FS><FS><FS><FS><FS><FS>3030<FS>31<FF><FS><FS><FS><FS><FS><FS><FS><FS><ETX>2C
POS-->ECR: <ACK>
POS-->ECR: <STX>32303030303030305542414349204B415254494355<ETX>2E
(insert CARD)ECR-->POS: <ACK>
POS-->ECR: <STX>(CARD in process)ECR-->POS: <ACK>
POS-->ECR: <STX>(wait)ECR-->POS: <ACK>
POS-->ECR: <STX(aproved)ECR-->POS: <ACK>
Maybe this code is not good ?
answer := IdTCPClient1.IOHandler.ReadLn();
showmessage(answer );Here is Protocol what POS terminal use..
-
thanks a lot for a help,
i will try it tommorow and see...
-
7 minutes ago, Lars Fosdal said:That protocol looks more like a Serial cable protocol, than a TCP protocol?
no, it is connected to local network with fixed ip 192.168.1.23 and port 3000..
on POS screen its written:
LISTEN 192.168.1.23:3000
-
hi
i need to send some HEX to POS terminal, amount of money, and POS will then check if credit card if valid
and send me some answers..like this: (<STX><STX>message<ETX><LRC>)
ECR-->POS: <STX><STX>303030303030303030303031303030<FS>31303030<FS><FS>2B30<FS>313931<FS><FS><FS><FS><FS><FS><FS><FS><FS><FS><FS>3030<FS>31<FF><FS><FS><FS><FS><FS><FS><FS><FS><ETX>2C
POS-->ECR: <ACK>
POS-->ECR: <STX>32303030303030305542414349204B415254494355<ETX>2E
ECR-->POS: <ACK>
-------------------------------------------------------------------I try with Indy IdTCPClient1 but I dont receive nothing from POS.
Am i sending wrong code or I dont know how to receive answer ?
They say i need do send HEX string..
So i translate this HEX:
<STX><STX>303030303030303030303031303030<FS>31303030<FS><FS>2B30<FS>313931<FS><FS><FS><FS><FS><FS><FS><FS><FS><FS><FS>3030<FS>31<FF><FS><FS><FS><FS><FS><FS><FS><FS><ETX>2C
to
02023030303030303030303030313030301C313030301C1C2B301C3139311C1C1C1C1C1C1C1C1C1C1C30301C310C1C1C1C1C1C1C1C1C032C
and send it like
IdTCPClient1.IOHandler.WriteLn(edit7.Text, IndyTextEncoding_OSDefault);
timer1.Enabled := true;
This is how i wait for server ansver:
procedure TForm1.Timer1Timer(Sender: TObject);
var receivedtext:string;
begin
with IdTCPClient1 do
begin
try
if IOHandler.InputBufferIsEmpty then
begin
IOHandler.CheckForDataOnSource(0);
IOHandler.CheckForDisconnect;
if IOHandler.InputBufferIsEmpty then Exit;
end;
receivedtext := IOHandler.ReadLn;
except
Timer1.Enabled := False;
Exit;
end;
if receivedtext <> '' then
ShowMessage(receivedtext);
end;
end;
pdf417
in VCL
Posted
Thanks Brian, by putting Datamode to binary solved the problem