Home » Developer & Programmer » Forms » Text_io
Text_io [message #217731] Mon, 05 February 2007 02:46 Go to next message
rishi1979
Messages: 36
Registered: November 2006
Member
Hi all,

I am creating a text file using text_io from form .I need to create a new file after every 10 records .
only 10 records can be written into a file and there are 100 records.
How will i do that can someone plz help me.
rishi
Re: Text_io [message #217735 is a reply to message #217731] Mon, 05 February 2007 03:14 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

If you can create a single file then you can create multiple files. Just repeat the process every 10 records. What really the problem is?
Re: Text_io [message #217736 is a reply to message #217731] Mon, 05 February 2007 03:17 Go to previous messageGo to next message
rishi1979
Messages: 36
Registered: November 2006
Member
Thanks for replying.The problem is that i dont know from where to start the loop and where to end it.We need to write it inside a loop.but it's ot working.
Re: Text_io [message #217737 is a reply to message #217736] Mon, 05 February 2007 03:18 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
show us what you got so far
Re: Text_io [message #217740 is a reply to message #217731] Mon, 05 February 2007 03:51 Go to previous messageGo to next message
rishi1979
Messages: 36
Registered: November 2006
Member
v_current_row number:=1
loop
out_file := TEXT_IO.FOPEN('c:\mtl\T_mb100('||v_file_counter||').txt','W');

TEXT_IO.PUT_LINE(OUT_FILE,'PROCEDURE SET_ITEM_PROPERTY IS');
v_current_row := v_current_row+1;
TEXT_IO.PUT_LINE(OUT_FILE,'BEGIN');
v_current_row := v_current_row+1;
exit when v_current_row>10
text_io.fclose(out_file);
Re: Text_io [message #217751 is a reply to message #217740] Mon, 05 February 2007 05:00 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
I think you should read up on how loops work in programming.
Think what you need to do, think when you need to open a file, close a file and when to increase your counter.
First think, think hard, and then, when you got it clear, draw it on paper.
And only after that you try to code it. And start from scratch, do not use your current code.

This will make it a lot clearer for you, since I predict you will only get in a bigger mess if you try to fix it in your code before you REALLY know what to do.
Re: Text_io [message #217843 is a reply to message #217731] Mon, 05 February 2007 19:27 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

Here's the code, just modify it according to your needs.

I agree with Frank, you should study the concepts of loop, it's a main ingredient in programming.
Re: Text_io [message #217900 is a reply to message #217843] Tue, 06 February 2007 00:50 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
This will overwrite the first version of File1.txt
plus there is no need whatsoever to cd to that directory.

[Updated on: Tue, 06 February 2007 00:51]

Report message to a moderator

Re: Text_io [message #217911 is a reply to message #217731] Tue, 06 February 2007 01:28 Go to previous messageGo to next message
rishi1979
Messages: 36
Registered: November 2006
Member
Actually The requiremnt is that i need to put END; after every ten record and that i the same text file .I.e i am printng 100 record then i need to put an end after every TEN records.
Re: Text_io [message #217913 is a reply to message #217911] Tue, 06 February 2007 01:30 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
This should not be too hard for you to add yourself!
Re: Text_io [message #217916 is a reply to message #217731] Tue, 06 February 2007 01:41 Go to previous messageGo to next message
rishi1979
Messages: 36
Registered: November 2006
Member
Sir if u dont want to give any solution then plz dont reply .I am only posting this because i am facing some problem with the Text_io
Re: Text_io [message #217917 is a reply to message #217916] Tue, 06 February 2007 01:45 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Quote:
Actually The requiremnt is that i need to put END; after every ten record

The requirement clearly states YOU need to put end; after every tenth record...

You could put some effort in it before asking. You are handed a piece of code that closes your file after ten records. It really isn't that difficult to add another line prior to closing it, is it?

[Updated on: Tue, 06 February 2007 01:47]

Report message to a moderator

Re: Text_io [message #217919 is a reply to message #217731] Tue, 06 February 2007 01:51 Go to previous messageGo to next message
rishi1979
Messages: 36
Registered: November 2006
Member
TEXT_IO.PUT_LINE(out_file,'abs ');
TEXT_IO.PUT_LINE(out_file,'1);');
TEXT_IO.PUT_LINE(out_file,'2 ;');
TEXT_IO.PUT_LINE(out_file,'abs ');
TEXT_IO.PUT_LINE(out_file,'3);');
TEXT_IO.PUT_LINE(out_file,'4 ;');
TEXT_IO.PUT_LINE(out_file,'abs ');
TEXT_IO.PUT_LINE(out_file,'5);');
TEXT_IO.PUT_LINE(out_file,'6 ;');
TEXT_IO.PUT_LINE(out_file,'abs ');
TEXT_IO.PUT_LINE(out_file,'7);');
TEXT_IO.PUT_LINE(out_file,'8 ;');

I am printing these line into text file and then i need to put an end before evry four lines now where would i increment the counter .These are static lines i am not using any cursor ..
It should read like
1,
2,
,3
,4
end;
5,
6,
7,
8
end,
Re: Text_io [message #217970 is a reply to message #217731] Tue, 06 February 2007 04:35 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

Your original requirement is "create a new file after every 10 records"
I gave you code for these. This will not overwrtie the first file because filename vary from the counter(ctr1).

Now you want to put "end" every 10 counts of printing and on the same file.
Brother, you just see how to use counter right? Just like "ctr1" and "ctr2" in my example. Also how the loop behaves.

Where to put the counter?
Wow! You want to put an "end" on every 10 records, so therefore you have to count every time you print record.
..and don't forget to reset your counter every time you print "end".

Frank is right again, you have to exert some efforts of your own.
Here is how to increment without cursor.

For ctr IN 1..100
loop
TEXT_IO.PUT_LINE(out_file, ctr);
End loop;

Regards,
Wency

[Updated on: Tue, 06 February 2007 04:44]

Report message to a moderator

Re: Text_io [message #217990 is a reply to message #217731] Tue, 06 February 2007 05:25 Go to previous message
rishi1979
Messages: 36
Registered: November 2006
Member
Thanks to both of u Frank and wency sir .I have solved my problem....
Previous Topic: disable text items in enter_query mode
Next Topic: Forms_Ddl Problem
Goto Forum:
  


Current Time: Sun Dec 04 14:35:57 CST 2016

Total time taken to generate the page: 0.11061 seconds