' **************************************************************************** ' Description: Tutorial 11, File Manipulation. This script looks for a file ' in a PC directory, and creates a message with the file as the ' message content. ' NOTE: See the FindFile, NextFile, GetFileName, EXISTS, and ' MoveFile statements for more details. ' Author: Jim KN6PE ' Revision: 09/18/08: Original ' **************************************************************************** SCRIPT VAR FNAME as string VAR NAMEONLY as string BEGIN ' Set up the mask to look for any file that matches this pattern. FindFile("c:\data\wx*.txt") ' Get the first file if one is there. FNAME = NextFile(1) ' The best check is to see if the file exists is with the EXISTS function WHILE Exists(FNAME) = TRUE ' if the file exists, create a message and post it BBS="K6FB-2"; FROM="KN6PE"; TO="ALLCTY"; MTYPE = "BULLETIN" ' Put the file name (not entire path) in the subject line as well NAMEONLY = GetFileName(FNAME) SUBJECT="WX Bulletin: " & NAMEONLY MESSAGE=READFILE(FNAME) CREATEMESSAGE ' We could either delete the file or move it. For this example, ' we will move it so we don't detect it again MOVEFILE(FNAME, "c:\data\sent") ' Finally, get the next file name and repeat this all over again FNAME = NextFile(1) ' Add a line separator to the output for readability Print("----------------------") ENDWHILE END