PROGRAM NumberFormats; {-- *************************************************************************** -- ** Descr. : Script which adds FM as as prefix to the format mask of numeric -- ** items, but only if the format mask has been changed in the form. -- ** The format mask will not be changed if it is the original subclassed -- ** value or if it is the default value. -- ** -- ** If a format mask doesn't have FM, the user has to delete the leading -- ** blanks in the field to enter a longer value. -- ** -- ** MinVers: -- *************************************************************************** -- ** 29/01/02 1.001.00 Initial Creation - Patrick Wolf, wolf@scigames.at -- ** 01/02/02 1.002.00 Changed script so that its saving the changed -- ** modules to a target, muellers@orcl-toolbox.com -- ***************************************************************************} VAR v_ps : TParamScreen; v_pb : TParamBoard; v_ii, v_jj : NUMBER; v_frm : NUMBER; v_files : tstringlist; v_filename : VARCHAR2; v_format_mask : VARCHAR2; v_itmlist : tstringlist; v_items_changed : BOOLEAN; BEGIN v_ps := TParamScreen.create; v_pb := v_ps.AddBoard ( 'Modules', picModules ); v_pb.addparam ( parLabel, 'MYLABEL', 'This script adds FM as prefix to the format mask.', '', '' ); v_pb.addparam ( parFiles, 'SRC', 'Source Files', '', 'Forms Modules (*.fmb)|*.fmb' ); v_pb.addparam ( parPathname, 'TRGPATH', 'Target Path', '', '' ); v_pb.addparam ( parLabel, 'MYDBLAB', 'Connection to use:', '', '' ); v_pb.addparam ( parDatabaseLogon, 'MYDB', 'Database', '', '' ); { -- -- show the parameter screen and wait for inputs -- } IF v_ps.ShowParamScreen('Add FM as format mask prefix...') THEN BEGIN //sanity parameter check if v_ps.ParamValue('TRGPATH') ='' then raiseException('Missing Target Path!'); { -- -- get the list of fmb-modules to process -- } v_files := tstringlist.create; v_files.text := v_ps.ParamValue('SRC'); { -- -- connect to database if specified -- } IF ( v_ps.paramvalue ( 'MYDB' ) <> '' ) THEN BEGIN Api_Connect( v_ps.paramvalue ( 'MYDB' ) ); END; FOR v_ii := 0 TO v_files.count - 1 DO BEGIN TRY v_items_changed := FALSE; v_filename := v_files.strings[v_ii]; v_frm := Api_LoadModule ( v_filename ); LogAdd( 'Processing: '+to_char(v_ii+1)+'/'+to_char(v_files.count)+' '+ v_filename); v_itmlist := Api_GetAllItemObjects ( v_frm ); FOR v_jj := 0 TO v_itmlist.count-1 DO BEGIN { -- -- is the item a display or text item and is the data type number -- } IF ( ( Generic_GetNumProp ( v_itmlist.objects[v_jj], D2FP_ITM_TYP ) = D2FC_ITTY_TI ) OR ( Generic_GetNumProp ( v_itmlist.objects[v_jj], D2FP_ITM_TYP ) = D2FC_ITTY_DI ) ) AND ( Generic_GetNumProp ( v_itmlist.objects[v_jj], D2FP_DAT_TYP ) = D2FC_DATY_NUMBER ) THEN BEGIN { -- -- only if the format mask has been changed -- } IF ( NOT Generic_IspropInherited ( v_itmlist.objects[v_jj], D2FP_FMT_MSK ) ) AND ( NOT Generic_IspropDefault ( v_itmlist.objects[v_jj], D2FP_FMT_MSK ) ) THEN BEGIN v_format_mask := Generic_GetTextProp ( v_itmlist.objects[v_jj], D2FP_FMT_MSK); { -- -- only if the item has a format mask and if it doesnt already have a FM, -- we have to correct it -- } IF ( v_format_mask <> '' ) AND ( SUBSTR ( v_format_mask, 1, 2 ) <> 'FM' ) THEN BEGIN v_format_mask := 'FM' + v_format_mask; v_items_changed := TRUE; Generic_SetTextProp ( v_itmlist.objects[v_jj], D2FP_FMT_MSK, v_format_mask ); LogAdd ( ' => updated ' + API_GetObjectPath ( v_itmlist.objects[v_jj] )); END; END; { if not inherited and not default } END; { if display or text item } END; { for loop } EXCEPT LogAdd ( 'Error loading ' + v_filename + ' error: ' + GetError, LogError ); END; { -- -- save form if we have done some changes -- } IF v_items_changed THEN API_SaveModule ( v_frm, v_ps.ParamValue('TRGPATH')+'\'+extractFilename(v_filename) ); { -- -- -- free item list and form -- } v_itmlist.free; Api_DestroyModule ( v_frm ); END; { for loop v_files.count } Api_Disconnect; v_files.free; END ELSE BEGIN LogAdd('pressed cancelbutton on parameterscreen!'); END; v_ps.free; END.