pjohns
23rd July 2002, 13:50
Simple question.

How do I suppress blank address lines from printing in my layout.

Some delivery address have been entered as below:-

Add Line 1 = text
Add Line 2 = 'blank'
Add Line 3 = text
Add Line 4 = 'blank'


When the above address gets printed on my report the blank lines are being included.

I think I need to use the 'not isspace' in my output expression box for my layout but I'm unsure of the syntax. The address fields on my report are cdel.nama, cdel.namb, cdel.namc, cdel.namd, cdel.name and cdel.namf

Thanks in advance

PJ

carice
23rd July 2002, 14:16
Simple answer.

Put your address lines in an array and loop
domain tcmcs.str60 AddLine(4), HulpAddLine(4)
long count1, count2

AddLine(1) = text
AddLine(2) = 'blank'
AddLine(3) = text
AddLine(4) = 'blank'

count2 = 1
for count1 = 1 to 4
if isspace(AddLine(count1)) then
HulpAddLine(count2) = AddLine(count1)
count2 = count2 + 1
endif
endfor

carice
23rd July 2002, 14:19
second solution;

put every addressline in a different layout and in the 'Output Expression' of the layout put ;

not isspace(variable)

I prefer the first solution

evesely
23rd July 2002, 15:56
There is a standard Baan function that you can #include in your code:

function itccom0006.remove.blank.address.fields(
ref domain tcnama shf.nama,
ref domain tcnamb shf.namb,
ref domain tcnamc shf.namc,
ref domain tcnamd shf.namd,
ref domain tcname shf.name,
ref domain tcnamf shf.namf,
ref domain tcdsca shf.ccty.dsca)


This can do what you want. All blank lines are removed and everything is shifted towards the first argument (i.e., shf.nama). In your example, after running the function, only the first two arguments would be filled.

I'm not sure if this code is delivered for those without source code. If not, my apologies. I would then suggest an approach similar to the one above.:cool:

Lokendra Kumar
25th July 2002, 16:42
Hi,

Maintaining the seperate report layouts can be the solution for your problem.

At report script write the following code.

layout.1:
before.layout:
if issapce(add1) then
lattr.print = false
else
lattr.print = true
endif

Hope this will help you.
Thanks
Lokendra Kumar

pjohns
25th July 2002, 17:33
Thanks for all you advice.

The problem I have with creating separate layouts is that I have two addresses side by side. So your suggestions wouldn't work as only one address may have blank lines.

I don't understand Carice's array solution? (I am only a novice!:( )

The address fields on my report are cdel.nama, cdel.namb, cdel.namc, cdel.namd, cdel.name and cdel.namf so how do I incorporate these into the 'array' suggestion?

Regards

PJ

carice
25th July 2002, 17:47
hi,

with my code it's possible to work with two addresses side by side.

ex.1:
Suppose

Leftaddress(1) = text Rightaddress(1) = text
Leftaddress(2) = 'blank' Rightaddress(2) = text
Leftaddress(3) = text Rightaddress(3) = 'blank'
Leftaddress(4) = 'blank' Rightaddress(4) = 'blank'

Use this code:

domain tcmcs.str60 Leftaddress(4), HulpLeft(4), Rightaddress(4), HulpRight(4)
long count1, count2

|blank addresses
for count1 = 1 to 4
HulpLeft(count1) = ""
HulpRight(count1) = ""
endfor

|put leftaddresses in HulpLeft when not blank
count2 = 1
for count1 = 1 to 4
if isspace(Leftaddress(count1)) then
HulpLeft(count2) = Leftaddress(count1)
count2 = count2 + 1
endif
endfor

|put right addresses in Hulpright when not blank
count2 = 1
for count1 = 1 to 4
if isspace(Rightaddress(count1)) then
HulpRight(count2) = Rightaddress(count1)
count2 = count2 + 1
endif
endfor


You will have:

HulpLeft(1) = text HulpRight(1) = text
HulpLeft(2) = text HulpRight(2) = text
HulpLeft(3) = 'blank' HulpRight(3) = 'blank'
HulpLeft(4) = 'blank' HulpRight(4) = 'blank'

Hope this will help you

evesely
25th July 2002, 18:09
If you want to pursue the array method given your current field names, you could do something like the following:

domain tcnama addr.fld(6)
long arr.ctr, next.line

addr.fld(1,1) = cdel.nama
addr.fld(1,2) = cdel.namb
...
addr.fld(1,6) = cdel.namf

next.line = 1
for arr.ctr = 1 to 6
if not isspace(addr.fld(1,arr.ctr)) then
if arr.ctr > next.line then
addr.fld(1,next.line) = addr.fld(1,arr.ctr)
addr.fld(1,arr.ctr) = ""
endif
next.line = next.line + 1
endif
endfor

After running this, the filled address fields will begin at addr.fld(1). Thus, add.fld(6) will only be non-blank if all of the original fields were filled.

The addr.fld(1,x) notation may be a bit confusing. This is because of the way Baan references strings. The 1 indicates that we should start looking at the first character, and the x indicated the array index.

pjohns
25th July 2002, 18:49
Thanks All,

Ed, what section in my script should I include your suggested code? I've treid a couple of sections, the script compiles okay but nothing seems to happen.

Regards

PJ

evesely
25th July 2002, 23:39
You could put it in the before.layout section for the layout that prints the address fields. If you want to put your variables in the layout, make sure you assign them back at the end of the code (e.g., cdel.nama = addr.fld(1,1), etc.). Otherwise, make sure you declare the array in the declaration section of the report script (I use extern for these) and then put the proper array value in your layout.

Does that clear things up?

pjohns
26th July 2002, 12:42
Thanks for all you help Ed everything works fine now. I had entered the code into the correct section of my script but I hadn't assigned the variables back.

Thanks to you too Carice for suggesting the array idea.

I would say that I'd pay you back but's it's quite apparent that my skill levels are way below yours. Maybe one day when I reach your heights :p

Have a good weekend!

PJ

carice
28th July 2002, 19:19
No problem at all,

i'm happy that it works.


See you