471,627 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Looking for proper way to code this

Is there a better way to break this out a bit?

static void Main(string[] args)
{
try
{
int rc1;
ROBOFTPAUTOMATIONLib.Automate RoboFTPSession = new
ROBOFTPAUTOMATIONLib.Automate();
RoboFTPSession = new Automate();
rc1 = RoboFTPSession.RoboStartSession("PUC-FTP", 1, 0, "");
rc1 = RoboFTPSession.RoboSendCommand("FTPLOGON \"ftp.xxxxxx.com\"
/user=xxxxx /pw=xxxxxx", 10 * 10);
rc1 = RoboFTPSession.RoboSendCommand("CHGDIR \"C:\\\"", 100 * 10);
rc1 = RoboFTPSession.RoboSendCommand("FTPCD \"test\"", 100 * 10);
rc1 = RoboFTPSession.RoboSendCommand("SENDFILE \"*.txt\"", 10000000
* 10);
rc1 = RoboFTPSession.RoboSendCommand("FTPLOGOFF", 10 * 10);
rc1 = RoboFTPSession.RoboSendCommand("STOP", 10 * 10);
}
catch(Exception)
{

}

}

Jan 12 '06 #1
2 1264
Not really. The best I think you could do is change the variable name
from RoboFTPSession to ftp, and that should make it look a little better.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<df********@hotmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Is there a better way to break this out a bit?

static void Main(string[] args)
{
try
{
int rc1;
ROBOFTPAUTOMATIONLib.Automate RoboFTPSession = new
ROBOFTPAUTOMATIONLib.Automate();
RoboFTPSession = new Automate();
rc1 = RoboFTPSession.RoboStartSession("PUC-FTP", 1, 0, "");
rc1 = RoboFTPSession.RoboSendCommand("FTPLOGON \"ftp.xxxxxx.com\"
/user=xxxxx /pw=xxxxxx", 10 * 10);
rc1 = RoboFTPSession.RoboSendCommand("CHGDIR \"C:\\\"", 100 * 10);
rc1 = RoboFTPSession.RoboSendCommand("FTPCD \"test\"", 100 * 10);
rc1 = RoboFTPSession.RoboSendCommand("SENDFILE \"*.txt\"", 10000000
* 10);
rc1 = RoboFTPSession.RoboSendCommand("FTPLOGOFF", 10 * 10);
rc1 = RoboFTPSession.RoboSendCommand("STOP", 10 * 10);
}
catch(Exception)
{

}

}

Jan 12 '06 #2
df********@hotmail.com <df********@hotmail.com> wrote:
Is there a better way to break this out a bit?


Well, you could encapsulate a command and whatever the second parameter
is into a struct or class, then have a list of them:

RoboCommand[] commands = new RoboCommand[]
{
new RoboCommand ("FTPLOGON \"ftp.xxxxxx.com\" [...]", 10*10),
new RoboCommand ("CHGDIR ....", 100*10),
new RoboCommand ("FTPCD ....", 100*10),
etc
}

foreach (RoboCommand command : commands)
{
RoboFtpSession.RoboSendCommand (command.Name,
command.OtherParameter);
}

(Depending on exactly what RoboFtpSession is, you could change that to
just command.Send() perhaps.)

Also, you're not using the value of the rc1 variable, so I'd get rid of
it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Chris Lott | last post: by
8 posts views Thread by Jonathan Gennick | last post: by
46 posts views Thread by vvk4 | last post: by
2 posts views Thread by mathieu | last post: by
6 posts views Thread by Jonathan Wood | last post: by
reply views Thread by krzysztof.konopko | last post: by
12 posts views Thread by alexander | last post: by
12 posts views Thread by Rex | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.