FTP_STATUS and FTPGetFile weirdness/bugs

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

FTP_STATUS and FTPGetFile weirdness/bugs

Post by Captive » Tue Mar 11, 2003 4:40 am

I wrote a script that fetches the file at: ftp.mjtnet.com/pub/mscver.txt
and obtains the latest version number at the end of the first line.
It then compares that with what your %MSCHED_VER% is, and reports one message if you have the same version, and another message if they're different.

In doing so, I noticed that even in setting FTP_STATUS to 0, the ftp status window still appears.

A few other errors occured using different values of "Mode" (at the end of the "FTPGetFile" command)
A or a (asci) = Acts ok
i (binary) = Acts ok
I (binary) = Acts screwey, script fails to find a certain label.
(So an upper case i will produce errors in this script.)

Here's the script:

Rem>The %MSCHED_VER% variable was introduced in v7.1.18
Let>VAREXPLICIT=1

IfFileExists>%WIN_DIR%\_msver.txt,DeleteVerFile
Goto>FetchVerFile

Label>DeleteVerFile
DeleteFile>%WIN_DIR%\_msver.txt

Rem>-- Fetch the mscver.txt file from the MSched web site.
Label>FetchVerFile
Let>FTP_STATUS=0
FTPGetFile>ftp.mjtnet.com,anonymous,[email protected],21,%WIN_DIR%\_msver.txt,/pub/mscver.txt,a
If>%FTP_RESULT%=Success,CheckVerFileExists
Let>MSG_STAYONTOP=1
MessageModal>The result of FTPGetDirList is:%CRLF%%FTP_RESULT%%CRLF%Script terminated!
Goto>TheEnd

Label>CheckVerFileExists
Rem>-- Double check, does the file actually exist?
IfFileExists>%WIN_DIR%\_msver.txt,CompareVer
MessageModal>The file:%CRLF%"%WIN_DIR%\_msver.txt"%CRLF%does not exist. Script terminated!
Goto>End

Label>CompareVer
ReadLn>%WIN_DIR%\_msver.txt,1,line
DeleteFile>%WIN_DIR%\_msver.txt
MidStr>%line%,50,15,sLatest
If>%sLatest%=%MSCHED_VER%,Latest,NewAvail

Label>Latest
MessageModal>You have the latest version: %sLatest%
Goto>TheEnd

Label>NewAvail
Let>Line1=A new version of Macro Scheduler is available!
Let>Line2=New version available: %sLatest%
Let>Line3=You are running version %MSCHED_VER%
MessageModal>%Line1%%CRLF%%Line2%%CRLF%%Line3%
Goto>TheEnd
Rem>-- I just edited the above line in this forum post - it had spaces at the end

Label>TheEnd
Last edited by Captive on Tue Mar 11, 2003 4:12 pm, edited 1 time in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Mar 11, 2003 2:17 pm

Hi,

Only 'I' (upper case) will set the transfer type to binary. Anything else will default to ascii. So even lower case 'i' will make it ascii. I concede that this is a bit confusing and we'll make sure 'i' and 'I' are treated the same in the next version.

However, the transfer type setting does not affect conditional branching in the script, so I think your label name problem must have been the result of something else. Perhaps it affected FTP_RESULT which therefore had an affect on your subsequent If command which checks this variable.
MJT Net Support
[email protected]

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Tue Mar 11, 2003 4:06 pm

However, the transfer type setting does not affect conditional branching in the script, so I think your label name problem must have been the result of something else.
Bah, I double checked that there was no space after my "TheEnd", and there wasn't. Looking at the 'paste' above shows that there are 2 spaces after it. Regardless, I deleted the label name and typed it again - no more errors.
Perhaps it affected FTP_RESULT which therefore had an affect on your subsequent If command which checks this variable.
The same thing happens even when the mode is "A".
I *just* discovered that it seems to be this line:
Let>VAREXPLICIT=1
because when I rem it out - the FTP Status window does not show anymore.

For anyone who decides to use this script, I suggest you change all instances of %WIN_DIR% to %TEMP_DIR% :)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts