ReceiveFile method dies
ReceiveFile method dies
(OP)
I am trying to transfer a file in myExtra 7.11 from the mainframe to my desktop using VBA in Excel. My first step was to simply use myExtra's macro recorder while I did the transfer. The part of the macro that initiates the transfer is as follows:
' This section of code contains the recorded events
Sess0.FileTransferScheme = "C:\Program Files\Attachmate\E!E2K\Schemes\ENU\Text Default.eis"
Sess0.FileTransferHostOS = 1
Sess0.ReceiveFile "C:\Documents and Settings\T78384\Desktop\DOWNLOADS\EXPORTED.TXT","T78384.EXP.DATA"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
System.TimeoutValue = OldSystemTimeout
' This code was added to give VBA something to look for when the macro is done.
Sess0.screen.PutString "DONE", 10, 1
When I call the above macro through the shell, it works reliably. Now I need to move this code into VBA. I switched out the line that calls the macro with the following code:
'Sess0 is the same object as in myExtra Basic
Sess0.FileTransferScheme = "C:\Program Files\Attachmate\E!E2K\Schemes\ENU\Text Default.eis"
Sess0.FileTransferHostOS = 1
Sess0.ReceiveFile "C:\Documents and Settings\T78384\Desktop\DOWNLOADS\EXPORTED.TXT", "T78384.EXP.DATA"
For some reason, the same code doesn't work anymore! It doesn't give me any errors compiling or running. I've tried filling it up with all sorts of delays, and that doesn't affect it. Finally, I tried stepping through it with F8. It just gets to ReceiveFile and continues on without any feedback at all.
Any ideas?
' This section of code contains the recorded events
Sess0.FileTransferScheme = "C:\Program Files\Attachmate\E!E2K\Schemes\ENU\Text Default.eis"
Sess0.FileTransferHostOS = 1
Sess0.ReceiveFile "C:\Documents and Settings\T78384\Desktop\DOWNLOADS\EXPORTED.TXT","T78384.EXP.DATA"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
System.TimeoutValue = OldSystemTimeout
' This code was added to give VBA something to look for when the macro is done.
Sess0.screen.PutString "DONE", 10, 1
When I call the above macro through the shell, it works reliably. Now I need to move this code into VBA. I switched out the line that calls the macro with the following code:
'Sess0 is the same object as in myExtra Basic
Sess0.FileTransferScheme = "C:\Program Files\Attachmate\E!E2K\Schemes\ENU\Text Default.eis"
Sess0.FileTransferHostOS = 1
Sess0.ReceiveFile "C:\Documents and Settings\T78384\Desktop\DOWNLOADS\EXPORTED.TXT", "T78384.EXP.DATA"
For some reason, the same code doesn't work anymore! It doesn't give me any errors compiling or running. I've tried filling it up with all sorts of delays, and that doesn't affect it. Finally, I tried stepping through it with F8. It just gets to ReceiveFile and continues on without any feedback at all.
Any ideas?
RE: ReceiveFile method dies
I wrote this off as one of the quirks of Extra. I moved the code to another user because I had that option.
calculus
RE: ReceiveFile method dies
I found a sloppy work-around in the mean time. Basically, I left the macro in Extra Basic, and when I need to transfer a file, I simply call that macro from the commandline. There are two down sides though:
1. Because I send the data for the transfer to the macro by writing to the screen in VBA and having the macro read it from the screen, there's extra code. It doesn't run as fast or as pretty, but it's adequate.
2. The only way I've found to detect when the macro is done (so VBA can continue) is to have the macro signal back somehow. I have the macro log out when it's done, and have VBA patiently wait for that screen.
Unfortunately, that brings up a related problem I've been having. -_- Some of the users have startup macros. Since I didn't write the startup macros, I have no way of knowing when myExtra is done running them! I've looked over every property and method I could find - and I just can't find a way!
It would be so much easier there was a collection like "Sess0.activeMacros" so I could get a count, or just an integer like "Sess0.MacroStatus". But there isn't.
Any ideas? :)
RE: ReceiveFile method dies
For your issue where you drop the information on the screen, you could drop it in a file and have the EB read the file. I'm not sure how important this is though. You also have the option of sending arguments to an EB macro. See the Command[$] function.
RE: ReceiveFile method dies
I'd rather not deal with any more code in Extra than I have to, since it's less than friendly to debug and the code I have now works AOK. Sending the arguments on the command line isn't something I'd considered; if I get some time in between projects, I'll go back and try that.
Incidentally, I finally got this project up and running! Woohoo! I really appreciate the advice you both gave me. Also, I hope NEVER to deal with Extra again after this. ^_-
RE: ReceiveFile method dies
CODE
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'ebrun.exe'")
For Each objProcess in colProcesses
MsgBox objProcess.CommandLine
' To Kill
' objProcess.Terminate
Next
RE: ReceiveFile method dies
So I'm gonna sweep this solution under the rug and use the problem as an excuse to get them to deactivate that inane startup macro. Still, I'm keeping this code for later. I'm sure it will come in handy.
Thanks again!