Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP Automation 1

Status
Not open for further replies.

JimmyK

Programmer
Sep 8, 2000
142
VN
Hello,
I make an Automation (remote) to transfer small files between 2 computers

Define Class MyFTP As Custom OLEPUBLIC
proc GetFile
lpara whatfile
f =fopen(whatfile)
n =fseek(f,0,2)
=fseek(f,0)
buff = fread(f,n)
=fclose(f)
return buff

endproc
Enddefine


If i get a text or dbf files, it's OK but when i get FPT (memo file) it is error. The FPT file's contain changed.
i guess that's because BUFF contain binary character (DBF also, why there is no errors)

Does anyone have experience in this? plz help me!!!

Jimmy
mailto:nhan_tiags@yahoo.com
 
Hi!

Close that dbf before reading. In addition, there is very nice fnction FileToStr() that allows do the same as you did with low-level functions, but more quickly and in a single line of code. Try it.

Finally, can you make me a favor? I'm interested too in the reliability of the binary data transfer using remote objects, so can you get original fpt file, your result fpt file at the client side and compare them to see what is changed? To compare, use FC standard Windows command (it should run just from the command line).

Let me know if you can do this.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Hi Vlad Grynchyshyn and All,

Reliability?
- I cannot say 'cause i just test for a few files. I tried to get DOC;GIF;DBF;BMP it's OK, except FPT.

How can i know FPT file changed?
- Read them into buffer and print them out at both sides. They show that they are different. Although FPT file changed i can open that DBF ( USE command). i guess it's because the file size is equal to the original one.
When i use BROWSE command, all of memo fields is empty (the original one has some words)

BTW, May i ask: Have you ever used _VFP.RequestData ?
Do you know why it can return multi-dimension ARRAY?
I am thinking about an Automation that can return multi-dimension ARRAY like _VFP

All responses appreciated

Thanks

Jimmy
mailto:nhan_tiags@yahoo.com
 
Doesnt the File Scripting host have any commands for this? Seems like it should for sure. John Durbin
john@johndurbin.com
MCP Visual FoxPro
ICQ VFP ActiveList #73897253
 
Hi!

Some more thoughts...

- Does your dbf file you going to send is in the database on the server side?
- can you use fc utility and compare exactly what the difference? In other words, which binary codes excluded/corrupted in fpt file when it transferred by such way?




Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Hello John Durbin,
File Scripting? , i have not used it and my Automation must process data, calculate something so I dont consider File Scripting.

Hello Vlad Grynchyshyn,
I trick VFP by adding some characters at the start of buffer

buff = [###] + FileToSTr("c:\tmp\1.fpt")

So It's OK now to transfer FPT files. I guess that SOME BYTEs AT BEGINNING OF FPT FILES is special. That's why it's error.

Reliability? Up to now, evrything is OK but i am NOT sure there is no error. I tell you later if you are interested in this.

BTW, As you told, FileToStr is VERY VERY fast and there is no errors when DBF is opened (FOPEN() fail).

Thanks All

Jimmy
mailto:nhan_tiags@yahoo.com
 
Thanks Jimmy, I'm glad to know this problem solved.

As about _VFP.RequestData - better do not use it, and do not use arrays/subobject at all. It does not works through DCOM (remote automation), because both array and object are reqlly just a pointer in the memory that is on another computer, so no way to access it. It even does not works with local COM when COM object is standalone (in EXE file), just because different memory spaces. MS have a solution for that, however, you cannot use it in VFP. We made a simple test - DCOM object with array property and subobject in the main object. Neither array nor subobject were accessable through DCOM. However, try to run Word.Application COM object from some machine through DCOM and you will see that subobjects of Word object are accessible... How MS did it???

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Hi Vlad Grynchyshyn,

I run C:\WINDOWS\SYSTEM\Racmgr32.exe to register remote automation. Click at "Server Connection",look at "Remote Transport". There are two options:
- Distributed COM
- Remote Automation

So, Is there any differences btw DCOM and Remote Automation??

BTW, Have you ever tried CREATEOBJECTEX() ?.(just version 6) It let you to declare which PC to create object. (Ofcourse,that PC must allow Remote Automation)
I have tried and use RequestData to fetch data, It does the job beutifully!! And here is my code

aa = CreateObjectEx("VisualFoxpro.Application.6", "\\PC1")
aa.Docmd("Use c:\tmp\depart")
buff = aa.RequestData("depart")

Now, buff is a multi-dimention array (MS say that the number of record you can get depends on available memory)

And, Do you mean that?: if server object declare an array, you can access ONLY one element of that array at a time, not the whole array.

Jimmy

mailto:nhan_tiags@yahoo.com
 
Hi!

Jimmy, you really show you know more than me ;-)
DCOM is a variant of remote automation, as far as I know. I don't know the differense. It looks like I should read more now...
As about the RequestData method - I just noticed that it returns array, that you cannot make in the custom function. I meant custom array property or passing arrays to COM objects. RequestData seems works by completely diffetent way because it returns array as a result of function! I guess MS did some underlying work to pass array data through DCOM to return it correctly at the client side. Anyway, it is a significant thing for me because I just making a testing program to test different approaches for data transferring between remote COM object and client side. I will include this approach in my tests. I hope you will see these tests and article at the Universal Thread site soon. (That is why I asked about reliability).
Thanks a lot for pointing me to this thing!
Do you know the similar easy way to pass data back to COM object?

PS: In my tests FPT file sent in the single string together with DBF file. The string format is following:
<32-bit separator key><DBF content><Separator key><fptcontent>
That is why FPT file transferring worked in my case ;-)


Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top