PDA

Click to See Complete Forum and Search --> : Evaluating Items from a File


Lana
Nov 15th, 1999, 12:45 AM
Let's say I have 2 functions called Function1 and Function2

I then have a file, sample.txt, in which the first 2 lines are as follows:
Function1(arguments)
Function2(arguments)

How would I read this file, in such a way that I could then call the functions from the file.

There would actually be hundreds of functions, so I cannot assign each line from the file to a string and then say
if string = "Function1" Then
Call Function1

if string = "Function2" Then
Call Function2

This would be far too unwieldy for 100's of different functions, which is why I would like to be able to evaluate the lines I'm reading in from the file and activate the functions as they are read in.

Mimo
Nov 15th, 1999, 01:51 PM
Try using: "select case" on the string
then
case : "....."
case: "......"
;
;

if any problem mail me:
MYR@cyberia.net.lb
Mimo

Serge
Nov 15th, 1999, 06:09 PM
If you have VB6 then you can use CallByName function. But you would have to have your functions in a Class Module (not regular mudule) because CallByName function has first parameter as an object.

Syntax: CallByName(object, procname, calltype,[args()])

Example:
iSum = CallByName(Class1, "Multiply", VbMethod, 5, 5)
MsgBox iSum


Assuming that I have function Multiply in calss called Class1.

Regards,

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)