dondeebarrera
New Member
Hi ,
Happy New year... i have written a programs that writes to a raw field, but the problem is its alway have this weird characters after the proper file. Any suggestions so i can only store the proper file.... any idea? is it the writing or the storing is the problem because in both places im setting the file size to 30KB...
/*Reads a File to Stores it to a Field*/
input from value("./tmp/pda-" + lc-postfix-name + ".req") BINARY NO-MAP NO-CONVERT.
repeat:
empty temp-table ttb-file-content.
set-size(memptr-data) = 30 * 1024.
import unformatted memptr-data.
create ttb-file-content.
assign i-pos = i-pos + 1
ttb-file-content.ttf-pos = i-pos
ttb-file-content.ttf-content = memptr-data
ttb-file-content.ttf-filename = "pda-" + lc-postfix-name.
create xmldoc_content.
assign xmldoc_content.xmldoc_filename = ttb-file-content.ttf-filename.
raw-transfer ttb-file-content to xmldoc_content.
end.
input close.
set-size(memptr-data) = 0.
----------------------------------------------------------------------------------------------------
/*Writes the Field to File*/
for each xmldoc_content where xmldoc_content.xmldoc_filename = ip-filename no-lock :
create ttb-file-content.
buffer-copy xmldoc_content using xmldoc_filename to ttb-file-content.
buffer-copy xmldoc_content using xmldoc_document to ttb-file-content.
end.
for each ttb-file-content break by ttb-file-content.xmldoc_filename:
if last-of(ttb-file-content.xmldoc_filename ) then do:
run create-file.
empty temp-table ttb-file-content.
end.
end.
procedure create-file :
assign ip-filename = ip-file-output + ip-filename + ".req".
output to value(ip-filename) NO-MAP NO-CONVERT BINARY.
for each ttb-file-content by ttb-file-content.xmldoc_pos:
set-size(lmemptr-data) = (30) * 1024.
put-bytes(lmemptr-data, 1) = ttb-file-content.xmldoc_document.
export lmemptr-data.
end.
output close.
end procedure.
Tried this but does not work....
/*************************************************************************************
def var lc-clear-mem as char no-undo.
def var lf-ini-memsize as integer no-undo.
def var li-ascii as integer no-undo.
def var li-ctr as integer no-undo.
assign lf-ini-memsize = 30 * 1024.
set-size(memptr-data) = lf-ini-memsize.
input from value("./tmp/pda-" + lc-postfix-name + ".req") BINARY NO-MAP NO-CONVERT.
repeat:
empty temp-table ttb-file-content.
import unformatted memptr-data.
end.
input close.
do li-ctr = 1 to lf-ini-memsize:
li-ascii = get-byte(memptr-data, li-ctr).
if li-ascii = 0 then leave.
lc-clear-mem = lc-clear-mem + chr(li-ascii).
end.
set-size(memptr-data) = 0.
set-size(memptr-data) = length(lc-clear-mem) + 1.
put-string ( memptr-data , 1) = lc-clear-mem.
create ttb-file-content.
assign i-pos = i-pos + 1
ttb-file-content.ttf-pos = i-pos
ttb-file-content.ttf-content = memptr-data
ttb-file-content.ttf-filename = "pda-" + lc-postfix-name.
create xmldoc_content.
assign xmldoc_content.xmldoc_filename = ttb-file-content.ttf-filename.
raw-transfer ttb-file-content to xmldoc_content.
set-size(memptr-data) = 0.
**************************************************************************************/
Happy New year... i have written a programs that writes to a raw field, but the problem is its alway have this weird characters after the proper file. Any suggestions so i can only store the proper file.... any idea? is it the writing or the storing is the problem because in both places im setting the file size to 30KB...

/*Reads a File to Stores it to a Field*/
input from value("./tmp/pda-" + lc-postfix-name + ".req") BINARY NO-MAP NO-CONVERT.
repeat:
empty temp-table ttb-file-content.
set-size(memptr-data) = 30 * 1024.
import unformatted memptr-data.
create ttb-file-content.
assign i-pos = i-pos + 1
ttb-file-content.ttf-pos = i-pos
ttb-file-content.ttf-content = memptr-data
ttb-file-content.ttf-filename = "pda-" + lc-postfix-name.
create xmldoc_content.
assign xmldoc_content.xmldoc_filename = ttb-file-content.ttf-filename.
raw-transfer ttb-file-content to xmldoc_content.
end.
input close.
set-size(memptr-data) = 0.
----------------------------------------------------------------------------------------------------
/*Writes the Field to File*/
for each xmldoc_content where xmldoc_content.xmldoc_filename = ip-filename no-lock :
create ttb-file-content.
buffer-copy xmldoc_content using xmldoc_filename to ttb-file-content.
buffer-copy xmldoc_content using xmldoc_document to ttb-file-content.
end.
for each ttb-file-content break by ttb-file-content.xmldoc_filename:
if last-of(ttb-file-content.xmldoc_filename ) then do:
run create-file.
empty temp-table ttb-file-content.
end.
end.
procedure create-file :
assign ip-filename = ip-file-output + ip-filename + ".req".
output to value(ip-filename) NO-MAP NO-CONVERT BINARY.
for each ttb-file-content by ttb-file-content.xmldoc_pos:
set-size(lmemptr-data) = (30) * 1024.
put-bytes(lmemptr-data, 1) = ttb-file-content.xmldoc_document.
export lmemptr-data.
end.
output close.
end procedure.
Tried this but does not work....
/*************************************************************************************
def var lc-clear-mem as char no-undo.
def var lf-ini-memsize as integer no-undo.
def var li-ascii as integer no-undo.
def var li-ctr as integer no-undo.
assign lf-ini-memsize = 30 * 1024.
set-size(memptr-data) = lf-ini-memsize.
input from value("./tmp/pda-" + lc-postfix-name + ".req") BINARY NO-MAP NO-CONVERT.
repeat:
empty temp-table ttb-file-content.
import unformatted memptr-data.
end.
input close.
do li-ctr = 1 to lf-ini-memsize:
li-ascii = get-byte(memptr-data, li-ctr).
if li-ascii = 0 then leave.
lc-clear-mem = lc-clear-mem + chr(li-ascii).
end.
set-size(memptr-data) = 0.
set-size(memptr-data) = length(lc-clear-mem) + 1.
put-string ( memptr-data , 1) = lc-clear-mem.
create ttb-file-content.
assign i-pos = i-pos + 1
ttb-file-content.ttf-pos = i-pos
ttb-file-content.ttf-content = memptr-data
ttb-file-content.ttf-filename = "pda-" + lc-postfix-name.
create xmldoc_content.
assign xmldoc_content.xmldoc_filename = ttb-file-content.ttf-filename.
raw-transfer ttb-file-content to xmldoc_content.
set-size(memptr-data) = 0.
**************************************************************************************/