// AXEOPS is a subroutine to remove the Advanced Ops data from an AO layout. // it does not remove any cars, locations or track label data. // The modified file will be saved with the same name but without the original _ao suffix. // ENSURE OPS CENTRAL AND SCHEDULE ARE HIDDEN AT START call $view(hide,ops) call $view(hide,schedule) // DEFINE CR CHARACTER FOR USE IN DISPLAY NOTES. let cr=" " // SET UP THE NOTE WINDOW SIZE AND POSITION. call noteprops 53 894 20 71 1 L // SET NOTE COLOR note color=220,220,220 // DISPLAY OPENING NOTE note " AXEOPS SUBROUTINE > Layout = $layout > AxeOps will convert this layout to freestyle by removing the predefined Advanced Ops data. > This will enable you to use FixOps to build a completely new Ops scenario for the layout. > The original ops ready file will be preserved on disk with either an _ao or an _ops suffix. > A new non ops version [without the suffix] will be saved alongside the source file in the original folder. > On completion of the conversion the new non ops version will be retained in memory ready for use. > If the source layout does not contain any Advanced Ops data the conversion process will be aborted. Press the F1 key to continue. ....or press the ESC key twice to terminate the AxeOps process. " // WAIT FOR F1 KEY TO PROCEED // permit ESC ESC to clear note and cancel script while waiting for F1 key. // ESC1 closes the note and ESC2 cancels active script. set notedownonesc 1 on key 112 set notedownonesc 0 // ABORT THE PROCESS IF THE RRW FILE DOES NOT CONTAIN ANY ADVANCED OPS DATA if ($ops(find,sequence.startat,all)="") if ($ops(find,industries.location,all)="") set notewndtextpos C note @cr AXEOPS PROCESS ABORTED @cr @cr This copy of $layout has no ops data. @cr after 0:0:05 note exit endif endif // REMOVE ANY EXISTING, OR REMAINING, OPS DATA let message = "@cr@ AXEOPS IS REMOVING THE OPS DATA FROM $layout @cr" note @message // CHECK FOR AND FIX A MISSING _AO FILENAME SUFFIX let pathname = $layout(path) if ($string(@pathname,endswith,"_ao.rrw")=1) // do nothing, original filename is OK elseif ($string(@pathname,endswith,"_yo.rrw")=1) // do nothing, original filename is OK elseif ($string(@pathname,endswith,"_ops.rrw")=1) // do nothing, original filename is OK else // if this really is an _ao layout then add the _ao suffix if ($ops(find,sequence.startat,all)<>"") if ($ops(find,industries.location,all)<>"") // rename and resave the original file with an _ao suffix. let length = $string(@pathname,length)-4 let pathname = $substr(0,@length,@pathname) + "_ao.rrw" let message = @message + "> Added _ao suffix to original ops ready file.@cr" note @message file "save as" @pathname // shorten the pathname for the displayed message note let x = $findstr(layouts,@pathname) let tempname = $substr(@x,-1,@pathname) let message = @message + "> Saved recovery file @tempname." + @cr note @message endif endif endif // FIND ALL THE CLASS YARDS IN THE LOCATIONS GRID // LOOK UP THE VIAIN ENTRY FOR EACH ENTRY FROM THE INDUSTRIES GRID let classyards = $ops(find,locations.class,class yard) ; // row numbers if (classyards <> "") let locindrows = $ops(find,locations.class,industry) ; // row numbers let loccount = $set(@locindrows,count) let industries = $ops(find,locations.class,industry,industry) ; // ind name let temp = @locindrows while (temp <> "") let token = $string(@temp,nexttoken,",") let rowid = $string(@locindrows,nexttoken,",") // get the industry name from the location row let indname = $ops(get,locations.track,@rowid) // look up the viain label in the industries tab let foundvia = $ops(find,industries.industry,@indname,viain) // take the first token as this could be a multiple set let foundvia = $set(@foundvia,get,0) // write the data to the viaclassyard column of the locations grid call $ops(set,locations.viaclassyard,@rowid,@foundvia) endwhile endif // RETAIN ALL REMAINING TRACK LABEL AND LOCATION DATA (Location tab data retained) // (This enables a new Ops scenario to be recreated if required) let message = @message + "> Track Label and Location data retained for any future Ops conversions.@cr" // CLEAR ALL EXISTING AO VARIABLES WHICH HOLD DATA USED FOR SWITCHLIST GENERATION let message = @message + "> Existing Ops variables removed from layout.@cr" note @message let $ops(cpickuplist)="" let $ops(crouted)="" let $ops(tspotsvacant)="" let $ops(ncarsbridge)=0 let $ops(nminbridge)=0 let $ops(nmaxbridge)=0 let $ops(ncarstopull)=0 ;// still returns orig value when saved to file ? let $ops(nswitchlistno)=0 ;// still returns 1 when saved to file ? let $ops(ActiveTrainRow)=0 ;// always returns 1 when saved to file ? // CARS - REMOVE EXISTING OPS DATA FROM ALL CARS ON THE LAYOUT let message = @message + "> Ops data and routing information removed from all non XO cars.@cr" let message = @message + "> Load Names and Load Status retained on all cars.@cr" let message = @message + "> XO route data retained for rebuilding block trains and passenger trains.@cr" note @message let temp = $layout(idset,carlabels) while ($set(@temp,count)>0) let car = $string(@temp,nexttoken,",") // retain route, shipment and loadat data on xo cars only let xo = $car(@car,excludeops) if (xo <> "X") let $car(@car,route) = "" let $car(@car,shipment) = "" let $car(@car,loadat) = "" endif // remove ops info from car note fields let $car(@car,indid) = "" let $car(@car,note) = "" let $car(@car,dest) = "" // remove any obsolete car data from earlier versions of AO or Yardmaster. let $car(@car,loadhere)= "" let $car(@car,ret)= "" let $car(@car,indrow)= "" // remove the XO car flag to clear the XOcars grid. let $car(@car,excludeops)="" if (temp = "") break endif endwhile // Removing the XO flag from all cars will clear the XO cars grid automatically. let message = @message + "> XO Cars grid data removed from layout.@cr" note @message // REPLACE AO INTRO WITH LAYOUT DESCRIPTION OR USE DEFAULT TEXT if ($layout(description)<>"") let $ops(intro) = $layout(description) else let $ops(intro) = "This layout has Locations but is not currently set up for Advanced Ops." endif // REMOVE ALL EXISTING SEQUENCE GRID DATA let message = @message + "> Sequence grid data removed from layout.@cr" note @message if ($ops(find,sequence.startat,all)<>"") let remove = $ops(find,seq.engine,all) let temp = @remove while ($set(@temp,count)>0) let rowid = $string(@temp,nexttoken,",") call $ops (delete, seq, @rowid) endwhile endif // REMOVE ALL EXISTING INDUSTRY GRID DATA let message = @message + "> Industries grid data removed from layout.@cr" note @message if ($ops(find,industries.location,all)<>"") let remove = $ops(find,ind.location,all) let temp = @remove while ($set(@temp,count)>0) let rowid = $string(@temp,nexttoken,",") call $ops(delete, ind, @rowid) endwhile endif // REMOVE LATEST SWITCHLIST DATA let message = @message + "> Switchlist grid data removed from layout.@cr" note @message if ($ops(find,switchlist.id,all)<>"") let remove = $ops(find,switchlist.id,all) let temp = @remove while ($set(@temp,count)>0) let rowid = $string(@temp,nexttoken,",") call $ops(delete, switchlist, @rowid) endwhile endif // REFRESH LAYOUT VIEW view refresh // SAVE THE MODIFIED RRW FILE // get the current pathname and remove the _ao suffix from the filename, let pathname = $layout(path) // truncate the pathname to remove the .rrw extension. let length = $string(@pathname,length)-4 let pathname = $substr(0,@length,@pathname) if ($string(@pathname,endswith,"_ao")=1) let length = $string(@pathname,length)-3 let pathname = $substr(0,@length,@pathname) endif if ($string(@pathname,endswith,"_yo")=1) let length = $string(@pathname,length)-3 let pathname = $substr(0,@length,@pathname) endif if ($string(@pathname,endswith,"_ops")=1) let length = $string(@pathname,length)-4 let pathname = $substr(0,@length,@pathname) endif let pathname = @pathname + ".rrw" // save the modified layout back to the original folder. file "save as" @pathname // shorten the pathname for the displayed message note let x = $findstr(layouts,@pathname) let tempname = $substr(@x,-1,@pathname) // UPDATE THE NOTE FIELD let message = @message + "> The original Ops data has now been removed from this layout.@cr" let message = @message + "> Modified file saved as @tempname @cr" let message = @message + "> The original 'Ops ready' version of $layout is still available in the same folder.@cr" let message = @message + "> Your new non ops version of $layout is now loaded and ready to rebuild.@cr" note @message // PROMPT TO CLOSE NOTE call $msgbox("Click OK to close the progress notes and work with your modified layout.") note call $view(hide,"Ops Central") // end of axeops subroutine. RF230728, updated 240315