user1788373
user1788373

Reputation: 39

save datawindow as text in powerbuilder with some additional text

***Process Date From:           
01/05/2012 0:00         
Group;Member        

 Status:****            
 Rcp Cd    Health Num        Rcp Name          Rcp Dob
1042231         1                  MARIA TOVAR DIAS 14-Feb-05
1042256         2                  KHALID KHAN      04-Mar-70
1042257         3                  SAMREEN ISMAT    25-Mar-80
1042257         5                  SAMREEN ISMAT    25-Mar-80
1042257         4                  SAMREEN ISMAT    25-Mar-80

I want my Powerbuilder datawindow Save As text look like this Bold text are the additional text want to add and rest is the current save as text result.

Upvotes: 0

Views: 2263

Answers (3)

Hugh Brackett
Hugh Brackett

Reputation: 2706

Pseudo code

Do the SaveAs to temp file
Open the temp file for read in line mode
Open output file for write (replace) in line mode 
Write your additional text lines to the output file (note: you can include CRLF to
write multiple lines at once)
Loop:
  Read line from temp file
  If EOF exit loop. Note: 0 is not EOF, -100 is EOF
  Write line to output file
Close temp file, output file
Delete temp file

Upvotes: 0

Rich Bianco
Rich Bianco

Reputation: 4174

Well, you didn't mention which version of PB you are using, so I'll assume a recent one in which case you have some better options such as SaveAsAscii and/or SaveAsFormattedText which offer more flexibility in displaying column headers, computed fields, etc.

If you want to add the top section, I would add one or more additional dummy columns (or computed fields) to your dataobject for the additional data. Then either populate the dummy columns manually after retrieve, or via expression in computed field. You could put all of it in one computed field that wraps, or use four different ones (e.g. process_date_label, process_datetime, group_status, status).

The two newer versions of SaveAs will work better for you as they display column header values instead of the column header name. SaveAsAscii came out pretty early somewhere around version 7 of PowerBuilder. SaveAsFormattedText is relatively new and came out somewhere around PB version 11 and it is a lot like SaveAsAscii but it lets you choose file encoding.

If you need more explicit detail let me know but I am sure you can get something to work using SaveAsAscii and extra columns.

Upvotes: 1

Text files cannot contain formatting. There's no way to get bold text in a plain text file. I suggest adding the text to your datawindow header band (bolded, with an expression to make sure it only displays on the first page), then saving the results as HTML.

Upvotes: 2

Related Questions