Category : Miscellaneous Language Source Code
Archive   : OPAL140.ZIP
Filename : MAKEIT.OPL

 
Output of file : MAKEIT.OPL contained in archive : OPAL140.ZIP

{
MAKEIT.OPL, TSF, 11/25/86
OPAL - Batch File Generation Utility
Copyright (c) 1986, The Software Factory, Inc.
}
{&include chkterm}

{ set up editor }
Let editor_name = '\pe2\pe2.exe'
Let editor_opts = '/p\pe2\pe2.pro /q'

Let file_name='foo'
Let file_spec='*.*'
Let prefix=''
Let suffix=''
Let do_sort=FALSE
Let do_exec=FALSE
Let do_term=FALSE
If Fiexist(editor_name)
Then Let do_edit = TRUE
Else Let do_edit = FALSE

Let fldbar_ = '1;33;41m'
Let flddsp_ = '36;44m'

Define form1 Form
Border(LJUST_, Strfmt("%a MAKEIT ver 2.0 %a [Esc to begin processing] ",'1m','0m'), SINGLE_, 55, 13)
Label(1, 42, "%time")
Label(2, 42, "%date")
Label(2, 03, "Batch Filename:")
Label(4, 03, "Global File Specification:")
Label(6, 03, "Command Prefix:")
Label(7, 03, " Suffix:")
Label(8, 01, "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿")
Label(9, 01, "³ ³ ³")
Label(10,01, "³ ³ ³")
Label(11,01, "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ")
Label(09,03, "Sort Batch File.....")
Label(10,03, "Edit Batch File.....")
Label(09,30, "Execute Batch File..")
Label(10,30, "Exit to DOS (Abort).")
Field(1, 02, 19, STRING_, 08, EDDFLT_+EDUPR_, @file_name,'\opal\eval.c')
Field(2, 04, 30, STRING_, 08, EDDFLT_+EDUPR_, @file_spec)
Field(3, 06, 19, STRING_, 34, EDDFLT_, @prefix)
Field(4, 07, 19, STRING_, 34, EDDFLT_, @suffix)
Field(5, 09, 24, YESNO_, 01, EDDFLT_+EDINSTA_, @do_sort)
Field(6, 10, 24, YESNO_, 01, EDDFLT_+EDINSTA_, @do_edit)
Field(7, 09, 50, YESNO_, 01, EDDFLT_+EDINSTA_, @do_exec)
Field(8, 10, 50, YESNO_, 01, EDDFLT_+EDINSTA_, EDAFT_, 'chkterm', @do_term)
End
Let stat = Defsave(form1, 'makeit.frm')
{ Let form1= Defload('makeit.frm') }

{
Note: We are turning on the keyfile and learning when the mode
parameter is 'w'. To play back what you have done just
change the 'w' (learn) to an 'r' (play). Use Ctrl-B anytime
to imbed pauses into the keyfile.
}

If !Kfopen('makeit.key', 'w') Then
Return("%n%nCould not open keyfile...%n%n")

{ Global System Variable used when we play back keyfiles }
Let pause_ = 50 { set for 10 tics }

Let formexit_ = ESC_ { set to Esc, which is the default }

Let option = Defdisp(form1, 5, 8, STPOPUP_, ACWAIT_)

{ turn off the key file }
Let stat = Kfclose

If do_term Then Return
Let file_name = file_name:".bat"

If Strlen(prefix) > 0 Then Let prefix = prefix:' '
If Strlen(suffix) > 0 Then Let suffix = ' ':suffix

Let l = Lirddir(file_spec,0)
If Lisize(l) > 0 Then Do
Do fp = file_name Data
Do Until Ishead(l)
Data Strfmt('%s%-12s%s', prefix, Elfetch(l, 1, POS_CURR_), suffix)
End
End

{ sort the batch file before editing if necessary }

If do_sort Then Do
Call System('sort <':file_name:' >temp.txt')
Let stat = Fierase(file_name)
Let stat = Firename('temp.txt',file_name)
End

{
Note: Now its time to call your favorite editor, I use the
IBM Personal Editor. You can change this to work with
your favorite.
}

If do_edit & Fiexist(editor_name) Then
Call Exec(editor_name, editor_opts, file_name)

{ if do_exec is true we will execute the new bacth file }

If do_exec Then Call System(file_name)

End Else
Print("%n%n%nNo files in set [%s]%n%n", file_spec)

End