Outputing data larger than the Format

Kirmik

Member
This one's bugging me probably because it's the end of the day but see if you can sort this.

I'm using a dyamic query to query a database with the purpose to output the values of the data into a flat file, using the PUT UNFORMATTED statement through an OUTPUT STREAM. Some of the data is larger than the field format so I'm getting error such as ** Value <value> cannot be displayed using <format>. (74).

It's blatantly obvious that the code i'm using is trying to use the field format but I'm struggling to override it.

I'm trying to use BUFFER-FIELD:STRING-VALUE so my attempt looks like this:

Code:
PUT STREAM sOut UNFORMATTED hField:STRING-VALUE.

I've also tried
Code:
PUT STREAM sOut UNFORMATTED hField:BUFFER-VALUE.

and
Code:
PUT STREAM sOut UNFORMATTED string(hField:BUFFER-VALUE, ">>>>>>>>>>9").


In all instances PROGRESS cries like a girl (sorry girls) with the same error message. This should be schoolboy stuff but I'm having a serious brainfart.
Any suggestions on how do get rid of that error message and override the field format?
 
it works for me, oe10b winxp
except string-value of course, which is formatted

what version are you using ( including patch number ) ?
post a more complete snippet of your code

here's what i've tried

<snippet>

do transaction:

create item.
assign
item.itemnum = 999999
item.price = 2000000000. /* dictionary format "->,>>>,>>9.99" */


define var cFile as char no-undo.
run adecomm/_tmpfile.p ("t", ".txt", output cFile).

define stream stOut.
output stream stOut to value( cFile ).


define var hBuffer as handle no-undo.
create buffer hBuffer for table "item".
hBuffer:find-first( "where itemnum = 999999", no-lock ).

define var hField as handle no-undo.
hField = hBuffer:buffer-field( "price" ).

/* formatted string cannot be displayed *
put stream stOut unformatted
hField:string-value. skip */

put stream stOut unformatted
hField:buffer-value skip.

put stream stOut unformatted
string( hField:buffer-value, ">>>>>>>>>>" ) skip.

delete object hBuffer.


output stream stOut close.
os-delete value( cFile ) no-error.


undo, leave.
end. /* transaction */

</snippet>
 
I tried the following code and no problem (9.1D06):

Code:
DEFINE VARIABLE h_buffer AS HANDLE	 NO-UNDO.
DEFINE STREAM s_out.
 
OUTPUT STREAM s_out TO c:\temp\test.p.
 
DEFINE TEMP-TABLE tt_temp
	FIELD it_temp AS INTEGER FORMAT '99'.
 
CREATE tt_temp.
ASSIGN tt_temp.it_temp = 999999999. /* maximum integer */
 
h_buffer = TEMP-TABLE tt_temp:DEFAULT-BUFFER-HANDLE.
 
/* PUT STREAM s_out UNFORMATTED tt_temp.it_temp + CHR(10). */
 
PUT STREAM s_out UNFORMATTED h_buffer:BUFFER-FIELD("it_temp"):BUFFER-VALUE + ';' + CHR(10). /* ?? */
 
PUT STREAM s_out UNFORMATTED string(tt_temp.it_temp,'999999999') + ';' + CHR(10).
 
PUT STREAM s_out UNFORMATTED STRING(h_buffer:BUFFER-FIELD("it_temp"):BUFFER-VALUE,'999999999') + ';' SKIP.

Strange,
if you uncomment the first put then it will not compile (offcourse).
But the second put compiles without a problem and converts the integer to a character???
I'm surprised, maybe someone can shed a light on this?

But anyway in all 3 cases it works.

What version are you on?

regards,

Casper.
 
Thanks for the quick reponse guys and thanks for reassuring me I'm not going mad (or am i).
See I believed that I knew that buffer-value wasn't formatted but it didn't seem to work. I'll have a look in the morning at the code again and if I can't see the solution through a fresh pair of eyes I'll post more detailed code.

I'm resisting the urge to remote log into work and have another look but it's 9:30 pm here and there's a few cold beers in the fridge with my favourite girls name on them (Stella) :awink:. Can't disappoint her so I'll catch you tomorrow.

Cheers


[EDIT] BTW I'm on 9.1D08[/EDIT]
 
I knew it..... A fresh pair of eyes and I saw the problem right away:rolleyes:

The problem wasn't where I was outputting the field. the problem was this:

Code:
[FONT=Courier New]CASE hField:DATA-TYPE:
WHEN "integer" THEN
	 IF hField:[COLOR=blue]STRING-VALUE[/COLOR] = ? THEN
	 {&sOut} lv-cDelimiter.
	 ELSE 
	 {&sOut} hField:BUFFER-VALUE lv-cDelimiter. 
END CASE.[/FONT]

hField:STRING-VALUE will attempt to format the field - DOH!!!!

solution was:

Code:
[FONT=Courier New]CASE hField:DATA-TYPE:
WHEN "integer" THEN
	 IF hField:[COLOR=blue]BUFFER-VALUE[/COLOR] = ? THEN
	 {&sOut} lv-cDelimiter.
	 ELSE 
	 {&sOut} hField:BUFFER-VALUE lv-cDelimiter. 
END CASE.[/FONT]

And so my problem is solved.
Thanks for your input fellas :cool:
 
Back
Top