PROGRAM LOV_AutoSizer; {-- *************************************************************************** -- ** Descr. : This script will resize an existing LOV so that it shows nicely -- ** when deployed over the internet. Web-Forms tend to need somewhat -- ** more space than client server LOV's. -- *************************************************************************** -- ** 17/11/01 1.001.00 Initial Creation, muellers@orcl-toolbox.com -- ***************************************************************************} {*Global Variable Declaration*} VAR v_filename : string; i,j : integer; frm : integer; files,lovlist : TStringList; ps : TParamScreen; pb : TParamBoard; v_width : integer; v_maxsize : integer; v_upscalefactor : real; {*Main Program Block*} BEGIN //build together a nice parameter screen ... ps := TParamScreen.create; pb := ps.AddBoard('Modules',picModules); pb.addparam(parLabel,'MYLABEL','This script will resize all LOVs specified by the %Factor.','',''); pb.addparam(parPathname,'SRCPATH','Source Path','',''); pb.addparam(parPathname,'TRGPATH','Target Path','',''); pb := ps.AddBoard('Options',picOptions); pb.addparam(parInteger,'RESLOV','Width %Factor','110','1-300'); pb.addparam(parInteger,'MAXSIZE','Max Width','800','100-3000'); pb.addparam(parCheckBox,'AUTOPOS','Enable Auto Positioning','Y',''); pb.addparam(parCheckBox,'COMPILEYN','Generate *.fmx','Y',''); ps.parambyname('COMPILEYN').isNewGroup := true; pb.addparam(parDatabaseLogon,'MYDATABASE','DB Connection','scott/tiger',''); pb.addparam(parSaveFilename,'LOGSAVE','Logfile','C:\lovautosizer.log','*.log'); ps.parambyname('LOGSAVE').isNewGroup := true; //show the parameter screen and wait for inputs if ps.ShowParamScreen('LOV Sizer ...') then begin //because it is nice in the log to see what parameters we have specified //we just write them out LogParamScreen(ps); // basic parametercheck ... if ps.ParamByName('SRCPATH').value ='' then raiseException('Missing Source Path!'); if ps.ParamByName('TRGPATH').value ='' then raiseException('Missing Target Path!'); // try to connect but ignore any errors ... try api_Connect(ps.ParamByName('MYDATABASE').value); except end; //get the upscale factor ... v_upscalefactor := to_Number(ps.ParamByName('RESLOV').value) / 100; v_maxsize := round(to_Number(ps.ParamByName('MAXSIZE').value)); //get the list of fmb-modules to process (with all subdirectories) files := GetFileList(ps.ParamByName('SRCPATH').value,'*.fmb', true); for j := 0 to files.count-1 do begin v_filename := files.strings[j]; logadd('Checking ('+to_char(j+1)+'/'+to_char(files.count)+' '+v_filename); try frm := API_LoadModule(files.strings[j]); //get all LOVs lovlist := API_getsubobjects(frm, D2FP_LOV); for i := 0 to lovlist.count-1 do begin //report which lov we are working on logadd(' '+API_GetObjectName(lovlist.objects[i]) ); //get width, multiply with factor but limit to maxsize specified //on parameterscreen and then set the new width v_width := generic_getnumprop(lovlist.objects[i], D2FP_WIDTH); v_width := round(v_width*v_upscalefactor); v_width := min(v_width, v_maxsize); generic_setnumprop(lovlist.objects[i], D2FP_WIDTH, v_width); //set autopositioning if wanted if ps.ParamByName('AUTOPOS').value = 'Y' then begin generic_setboolprop(lovlist.objects[i], D2FP_AUTO_POS, TRUE); end; end; //free memory of the lov object list lovlist.free; //now modify the filename to point to the new location v_filename := PathReplace(v_filename,ps.ParamByName('SRCPATH').value, ps.ParamByName('TRGPATH').value); //and save it to the new location API_SaveModule(frm,v_filename); //Compile the module if user said so on parameter screen if ps.ParamByName('COMPILEYN').value = 'Y' then if API_GenerateModule(frm) = false then logadd(' => Compilation failed!', LogWarning); //... and finally release the module from memory API_DestroyModule(frm); except // ups! an error happened, so just log it and proceed to the next module logadd(' =>'+GetError,LogError); end; end; //save the log file of our script run to this file logsave(ps.ParamValue('LOGSAVE')); end else begin //user must have pressed cancel on parameterscreen logadd('Canceled on parameterscreen!'); end; // free the parameter screen ps.free; END.