PDA

Click to See Complete Forum and Search --> : Read and execute


Devan
Apr 28th, 2004, 02:40 AM
Hi all....tAKE A LOOK AT THIS...

Call DriveDCMotors(0,0,-1,-1)
Call DriveDCMotors(0,0,1,-1)
Call DriveDCMotors(0,0,0,-1)
Call DriveDCMotors(0,0,-1,1)
Call DriveDCMotors(0,0,1,1)

This is part of a program function i wrote for parallel port program which will enable a robot to move...it only uses 2 motor, anyway i dont think so that matters cuz i haf already got it working...it works perfectly fine...My question is this...the current function as i haf shown above is written in the source code itself....What i want to do is to read the same functions from a text file and execute it.For example lets say that i wrote the above codes on a text file and saved it.My program should 1st read the text file, which has the codes above, and then it should be able to perform the task of the codes written.I would like to make things clear again that my program works, and so does the code i gave above, i only want to know how to read and execute the code from and external file rather than by predifining the movements in the underlying codes itself. It should be programmable. Please anyone do help me out in this, as i need it urgently.Thank U.

Ecniv
Apr 28th, 2004, 03:34 AM
Something like :


dim strFilename as string, strLine as string
dim aryCmds() as string

redim aryCmds(4)
strFilename = "Text filename and path"
close #1
open strFilename for input as #1
strline=""
line input #1,strline
if len(strline)>0 then
aryCmds = split(strline,",")
DriveDCMotors arycmds(0),arycmds(1),arycmds(2),arycmds(3)
end if

close #1


See whether that works...
Nice project; for school?

Vince

Devan
Apr 29th, 2004, 03:59 AM
hey vince, i tried ur codes but i seem to haf some problem.
i am attaching the codes to u, can u please modify it such tat it works as i wanted it.Dont modify the core program, as that might distort my original protocols.IF u look at the program, it has 5 buttons, front,reverse,left,right and stop.u see all of it works because on_Click function i call the DriveDCMotors function.
Now i want the same thing to happen but this time instead of writing the DriveDCMotors function on the code itself, i want to write it on a text file regardless of the text file's name...the program must be able to read the file that i specify and then when i click lets say a command button , EXECUTE, thne it must perform the functions written on the text file...Hope u can modify the program for me. U might not know if it works , because the only way i haf been doing my test is by using the circuit and sending the circuit for u to test will be out of the question i guess...I really hopw u can help me out in this..Oh yeah, it is my university's final year project.The core function i did for robotics competition, and now this additionla function is for me to finish up my project.Really hope u can help me thx.1 more thing there are some unnecessary codes in it, dont bother abt it, i havent fullly furnished my programe so it looks distorted....Thx again..Just focus on one of the 5 buttons on the interface, if it can work with either 1 of the button i am sure the work is pretty much done.

Dave Sell
Apr 29th, 2004, 08:51 AM
1) Make a class exposing your 5 functions as public.
2) Read in the text file in a main loop
3) For each command you find use CallByName on your class like:


CallByName objYourClass, strCommand, VbCallType


I don't know all the different VbCallType's I think there's just the 3 - "vbMethod" should work, or try searching around for it - start here:

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=14759&lngWId=1

and here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctcallbynamefunction.asp

Dave

:afrog: