From 07bb6b82d49e08158d506f84515a06370df8ef02 Mon Sep 17 00:00:00 2001 From: Rahul Prajapati Date: Tue, 10 Mar 2026 15:20:07 +0530 Subject: [PATCH 1/2] removed type not null to get all the fields accurately --- src/tests/dspf.test.ts | 46 ++++++++++++++++++++++++++++++++++++++++++ src/ui/dspf.ts | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/tests/dspf.test.ts b/src/tests/dspf.test.ts index 655d3e0..6c1acb8 100644 --- a/src/tests/dspf.test.ts +++ b/src/tests/dspf.test.ts @@ -137,4 +137,50 @@ describe('DisplayFile tests', () => { expect(new Set(names).size).toBe(names.length); }); + it("should parse field with type and attach keywords", () => { + const lines = [ + " A FIELD1 10A", + " A TEXT('Customer Name')", + " A COLHDG('Cust' 'Name')" + ]; + + const file = new DisplayFile(); + file.parse(lines); + + const record = file.formats[0]; + const field = record.fields[0]; + + expect(record.fields.length).toBe(1); + expect(field.name).toBe("FIELD1"); + expect(field.type).toBe("A"); + expect(field.length).toBe(10); + expect(field.keywords.length).toBe(2); + expect(field.keywords[0].name).toBe("TEXT"); + expect(field.keywords[0].value).toBe("'Customer Name'"); + expect(field.keywords[1].name).toBe("COLHDG"); + expect(field.keywords[1].value).toBe("'Cust' 'Name'"); + }); + + it("should parse field without type (REFFLD) and attach keywords", () => { + const lines = [ + " A FIELD2", + " A REFFLD(ADRNO)", + " A TEXT('Address Number')" + ]; + + const file = new DisplayFile(); + file.parse(lines); + + const record = file.formats[0]; + const field = record.fields[0]; + + expect(record.fields.length).toBe(1); + expect(field.name).toBe("FIELD2"); + expect(field.type).toBe(""); + expect(field.keywords.length).toBe(2); + expect(field.keywords[0].name).toBe("REFFLD"); + expect(field.keywords[0].value).toBe("ADRNO"); + expect(field.keywords[1].name).toBe("TEXT"); + expect(field.keywords[1].value).toBe("'Address Number'"); + }); }); diff --git a/src/ui/dspf.ts b/src/ui/dspf.ts index d272a6e..66e58b8 100644 --- a/src/ui/dspf.ts +++ b/src/ui/dspf.ts @@ -95,7 +95,7 @@ export class DisplayFile { x: totalX, y: 0 }; - } else if (name !== undefined && type !== "") { + } else if (name!=="" && name !== undefined) { // Some fields have no positions if (this.currentField) { this.currentField.handleKeywords(); From 5759ce4d8d93debc8429e98d8e7364d2644f83e7 Mon Sep 17 00:00:00 2001 From: Rahul Prajapati Date: Tue, 10 Mar 2026 15:38:16 +0530 Subject: [PATCH 2/2] new field when name exists --- src/ui/dspf.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/dspf.ts b/src/ui/dspf.ts index 66e58b8..b10d80f 100644 --- a/src/ui/dspf.ts +++ b/src/ui/dspf.ts @@ -95,7 +95,7 @@ export class DisplayFile { x: totalX, y: 0 }; - } else if (name!=="" && name !== undefined) { + } else if (name!=="" && name !== undefined) { // start a new field if a field name exists // Some fields have no positions if (this.currentField) { this.currentField.handleKeywords();