From: Jim Agnew [agnew@dragon.vcu.edu] Sent: Thursday, August 19, 1999 9:16 AM To: Info-VAX@Mvb.Saic.Com Subject: Re: How to write an optimal conditional script in OVMS? Arne, your solution was more elegant than mine!!! i'm saving this.. Jim p.s., ever make out ok with the random number generators i gave you? Arne Vajhøj wrote: > > Netsurfer wrote: > > > > Presently, I am writing a simple script to move incoming files to its > > respective subdirectories using IF/ELSE/ENDIF statements. > > > > But there are over 20 file types and file target locations and thus > > very lengthy if/else statements such as below: > > > $ file_name = F$PARSE("''fname'",,,"NAME") > > $ file_type = F$PARSE("''fname'",,,"TYPE") > > $! > > $ IF file_type .EQS. ".COM" > > $ THEN > > $ copy 'file_name''file_type' [.BIN] > > $ ELSE > > $ IF file_type .EQS. ".DAT" > > $ THEN > > $ copy 'file_name''file_type' [.DATA] > > > Is there any other DCL command to do it faster? > > I would consider it the most elegant solution to use "double > symbol-substitution". > > Example: > > $ com_dir = "[.SCRIPT]" > $ exe_dir = "[.BIN]" > $ file_type = f$parse(fname,,,"TYPE") - "." > $ if f$type('file_type'_dir) .nes. "" > $ then > $ dirname = file_type + "_DIR" > $ dir = &dirname > $ write sys$output "I will copy ''fname' to ''dir'" > $ else > $ write sys$output "oops unknown type" > $ endif > $ exit > > This way you only have to add one single line when adding a new type. > > Arne