472,327 Members | 1,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,327 software developers and data experts.

how to read from a formatted file, and then call object's methods

I have got formatted files. All of these file takes this form:
obj1 method1 obj2 string1 obj3 string2 argument.

Of course, each file can have maximum fields as shown above, or
minimun fields
like this:
obj1 method1.

For example, file1 can be like this:
10 obj1 method1
20 obj1 method2 obj2 string1 obj3 string2 argument1
30 obj5 method3 obj1 string1 obj3

Another example is as in file2:
10 obj10 method55 obj30
20 obj1 method7 obj3 string1 obj7
30 obj11 method2 obj20 string1 obj30 string2 argument2

As you can imagine, obj means object, the target is to read one line
by one
line. At each line, call object's method then go to next line until
the final
line reaches.

The difficult for it is each line calls the different method by
passing different parameters. For example, in file1, the first line do
this: int obj1.method1(), however, the second line might do this: int
obj1.methods2(obj2, string1, obj3, string2, argument1), then the third
line do this: obj5.methods3(obj1, string1, obj3).

I wonder whether it is possible to create a dynamic template, where
the format is stored there. This template will store each field of
each line dynamically. For example, int pos=0, in files1, the first
field of the first line will be stored into firstobj[pos], the second
field into method[pos], since the first line reaches end, the rest
fields are set to null. then call firstobj[pos].method[pos](). then
pos++. Then read second line, the first field firstobj[pos],
method[pos], secondobj[pos], string1[pos], thirdobj[pos],
string2[pos], argument1[pos]. Then call
firstobj[pos].methods[pos](secondobj[pos], string1[pos],
thirdobj[pos], string2[pos], argument1[pos]).

The above is what I intend to do. However, it seems not practical to
use arrays to store each field and call object method because each
line has different length.
Jul 19 '05 #1
0 2503

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Garyrek | last post by:
Hi I have an url where I have xml data POSTED and I need to parse the URL to read the data - Meanwhile here is my xml data...
6
by: Jason Heyes | last post by:
I am starting to worry about the performance of formatted read/write operations on data-redundant objects in my program.What can I do to improve...
6
by: BBM | last post by:
I have an object that has a fairly complex construction sequence, so I have written a dedicated "factory" class that invokes the constructor of my...
6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only...
3
by: John | last post by:
I have a text file that is formatted like this: 123456789 SOLD 1 12/12/2006 Smith 45,525 987654321 SOLD ...
7
by: Tracks | last post by:
I have old legacy code from vb5 where data was written to a file with a variant declaration (this was actually a coding error?)... in vb5 the...
11
by: waffle.horn | last post by:
Hi, if this makes sense i want to create a function that can be called so that it reads a single line from a file, then after using the...
0
by: satarupa | last post by:
I want to read the formatted (bold,underline,italics) text of a word dcoument using c# i can read the document even the paragraphn in it but not the...
6
by: Sean Davis | last post by:
I have a large file that I would like to transform and then feed to a function (psycopg2 copy_from) that expects a file-like object (needs read and...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.