home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pegasus 5
/
Pegasus_Vol_5_CD2.iso
/
lotus
/
lotus014.dsk
/
HPGALATM.LSS
next >
Wrap
Text File
|
1995-06-30
|
4KB
|
141 lines
'**********************************************************************
'
' HPGALATM.LSS
'
' This script automates the import of a series of HP Gallery files
' into Freelance.
'
' The script prompts the user for the name of an ascii text file
' containing a list of the file names to be imported. This text
' file must have been created before the script is run, and should
' contain one file name per line, including the full path where each
' file is located.
'
' Example input file:
'
' c:\lotus\work\flw\myfile.gal
' c:\lotus\work\flw\myfile2.gal
' ...etc.
'
' A new page is created for each file imported, and the page name is
' set to the name of the file imported to that page.
'
'**********************************************************************
%INCLUDE "LSERR.LSS" 'constants for error condition trapping
' Declares...
DIM TextFile AS STRING
DIM Length AS INTEGER
DIM DlgText(12) AS STRING
DIM Nameray(1 to 100) AS STRING * 1
DIM Count AS INTEGER
DIM OneLine AS STRING
DIM PageName AS STRING
DIM FileNmbr AS INTEGER
DIM DlgNum AS INTEGER
DIM PathCmp AS INTEGER
' Defines...
' the following strings are used in dialog box(es)
DlgText(1) = "Please Type in the name of the textfile containing the names" _
+ " of the Gallery files to be imported into Freelance."
DlgText(2) = "TEXT FILE NAME"
DlgText(3) = "*.txt, *.hpg"
DlgText(4) = "That file name and/or path was not found. " + DlgText(1)
DlgText(8) = "ERROR - PATH AND/OR FILENAME NOT FOUND"
DlgText(12) = DlgText(3)
DlgNum = 1
'*
'* SUB AskUser (FileName AS STRING, FNumber AS INTEGER)
'*
'* The following subprogram prompts the user for the name of a text file
'* containing the names of all the GALLERY files that will be
'* imported. If the text file entered cannot be opened, the user is
'* prompted for the file name again.
'*
SUB AskUser (FileName AS STRING, FNumber AS INTEGER)
GetFname:
' This is the actual command line for the dialogbox. Instead of plain
' strings, variable arguments were used so that the dialog would be
' different depending on the stage of the program.
TextFile = INPUTBOX$(DlgText(DlgNum), DlgText(DlgNum*2), DlgText(DlgNum*3))
IF TextFile = "" THEN ' user pressed cancel
EXIT SUB
ELSE
ON ERROR ErrOpenFailed GOTO ErrorDialog
OPEN FileName FOR INPUT AS FNumber LEN = 512
EXIT SUB
END IF
ErrorDialog:
DlgNum = 4
RESUME GetFname
END SUB
'*
'*
'* Main program...
'*
'*
FileNmbr = FREEFILE() 'get an unused file number
AskUser TextFile, FileNmbr 'prompt for input file name
IF TextFile <> "" THEN 'if user didn't press cancel...
'Process the file....
WHILE Not EOF (FileNmbr) 'while not at end of file
LINE INPUT #FileNmbr, OneLine 'get next line from file
Length = LEN(OneLine)
IF Length > 0 THEN 'if the line isn't blank
'Move the string to an array...
FOR Count = 1 to Length
Nameray(Count) = MID$ (OneLine, Count, 1)
NEXT
' Then get just the file name from the full path\name
' for use as the page name...
PageName = "" 'init pagename to empty
PathCmp = 1 'init PathCmp to be non-zero
WHILE (Length > 0) And (PathCmp <> 0)
PathCmp = STRCOMPARE(Nameray(Length), "\", 1)
IF PathCmp <> 0 THEN
PageName = Nameray(Length) + PageName
END IF
Length = Length -1
WEND
' create a new page...
set NewPg = [CurrentDocument].CreatePage( PageName , 0 )
' and import the file...
[CurrentDocument].Import( OneLine )
END IF
WEND
END IF
CLOSE #FileNmbr 'release the file number