61
NewandlessknownfeaturesofMosel
• Selectednewfeatures
– Addingafiletoatararchive(newinRel7.3)
– Addingatimestampintoafilename(newinRel7.3)
– Texthandling:Howandwheretousethetype
text
(modulemmsystem)
• Structuringmodels
– Usingincludeandpackages
– Paths:getcwd,runtimeparameters,DSOsearchpath
– Advanceddatastructures:records,lists
• Andalso:
– Modelingtricks:Counters,indicatorsandlogicalconstraints,dotnotation,dates
andtimes
– DeploymentviaanExcelVBmacro
– Outputredirection
WorkingwithTARarchives
Tip1:AddingafiletoacompressedTARarchive
declarations
lsf: list of text
origfname: text
end-declarations
makedir(gettmpdir+"/tartemp")
! Create temporary directory
if getfstat(archivename)<>0 then
! Untar if archive exists
untar("zlib.gzip:"+archivename, gettmpdir+"/tartemp")
end-if
! Copy file to temporary y directory
origfname:=pathsplit(SYS_FNAME,filetoadd)
fcopy(filetoadd, ":"+ gettmpdir+"/tartemp/"+origfname)
! Rebuild the archive
findfiles(SYS_RECURS, lsf, gettmpdir+"/tartemp", , "*")
newtar(0, "zlib.gzip:"+archivename, gettmpdir+"/tartemp", lsf)
removefiles(SYS_RECURS, gettmpdir+"/tartemp", "*")
removedir(gettmpdir+"/tartemp")
! Delete temporary files
Timestamp
Tip2:Insertingatimestampintoafilename
public procedure addtimestamp(filestochange: set of string)
declarations
origdir, origfname, , origextn, timestmp: : text
end-declarations
! Create a time stamp - redefining datetime e format as s to avoid d use
! of ’:’ to prevent interpretation as I/O driver
usedfmt:=getparam("datetimefmt")
! Save present t format
setparam("datetimefmt", "%0d%0m%0yT%0H.%0M.%0S")
timestmp:= text(datetime(SYS_NOW))
setparam("datetimefmt", usedfmt)
! Reset to previous format
! Rename all l files s to include the time stamp in their name
forall(f in filestochange) do
origdir:=pathsplit(SYS_DIR,f)
origfname:=pathsplit(SYS_FNAME,f)
origextn:=pathsplit(SYS_EXTN,origfname,origfname)
fmove(f, origdir r + "/" + origfname + "-"+timestmp +"." +origextn)
end-do
end-procedure
cCopyright2001–2013FairIsaacCorporation.Allrightsreserved.
page1