/*************************************************************************** IconAlign.rexx 1.0 (03.11.2002) by Olivier Fabre This script aligns selected icons to the nearest grid position. This script needs rexxdossupport.library and Workbench 3.5+. Template: SPACEX/N,SPACEY/N SPACEX = number of horizontal pixels between the center of icons. SPACEY = number of vertical pixels between the center of icons. Example: IconAlign.rexx 30 20 ***************************************************************************/ /* default spacing. change if you want */ spacex = 32 spacey = 32 /* Please do not change anything under this line */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ OPTIONS RESULTS PARSE ARG input IF ~SHOW('LIBRARIES','rexxdossupport.library') THEN IF ~ADDLIB('rexxdossupport.library',9,-30,0) THEN QUIT( 'Cannot open rexxdossupport.library!', 10 ) IF input ~= "" THEN DO CALL ReadArgs( input, "SPACEX/N,SPACEY/N" ) END ADDRESS workbench "GETATTR" OBJECT windows.active activeWin = result "GETATTR" OBJECT WINDOW.ICONS.SELECTED.COUNT NAME '"'activeWin'"' numOfIcons = RESULT If numOfIcons = 0 THEN EXIT DO i=0 TO numOfIcons-1 "GETATTR" OBJECT WINDOW.ICONS.SELECTED.i NAME '"'activeWin'"' STEM iconInfo newx = TRUNC(((iconInfo.left+iconInfo.width/2+spacex/2)%spacex)*spacex-iconInfo.width/2,0) /* argh, % doesn't mean modulo in ARexx, but integer division */ newy = TRUNC(((iconInfo.top+iconInfo.height/2+spacey/2)%spacey)*spacey-iconInfo.height/2,0) 'ICON "'activeWin'" "'iconInfo.name'" X 'newx' Y 'newy END