&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v7r10 GUI &ANALYZE-RESUME &Scoped-define WINDOW-NAME w-code-chg &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS w-code-chg /*------------------------------------------------------------------------ File: code-chg.w Description: Code-changing utility Input Parameters: Output Parameters: Author: David K. James (david_james@swbell.net) Created: April, 1994; last update September 6, 2000 NOTE: User feedback is critical to the improvement process. ------------------------------------------------------------------------*/ /* This .W file is maintainable with the Progress UIB. */ /*----------------------------------------------------------------------*/ /* *************************** Definitions ************************** */ /* Parameters Definitions --- */ /* Local Variable Definitions --- */ define stream intext. define stream newtext. define stream outtext. define stream infiles. define variable addfile as character format "x(128)":U no-undo. define variable beautify-line-length as integer no-undo format ">>9":U initial 110. define variable begin-text as character not case-sensitive format "x(128)":U no-undo. define variable begin-text-sensitive like begin-text case-sensitive. define variable block-head-terminator as character format "x":U no-undo initial ".". define variable cancel-chosen as logical no-undo. define variable changes-made as logical no-undo. define variable continuation-character as character format "x":U no-undo. continuation-character = chr(126). define variable crlf as character format "xx":U no-undo. crlf = (chr(13) + chr(10)). define variable curpos as integer no-undo. /*used in break-codeline*/ define variable cycling-through-files as logical no-undo initial false. define variable l-def-var as logical no-undo. define variable l-drop-comments as logical no-undo. define variable editor-widget as widget-handle no-undo. define variable end-text like begin-text. define variable end-text-sensitive like begin-text-sensitive. define variable ending-suspension as logical no-undo. define variable ext-max as integer no-undo. define variable file-info_file-name as character no-undo. define variable file-number as integer no-undo. define variable l-format-def-var as logical initial yes no-undo. define variable i as integer no-undo. define variable ii as integer no-undo. define variable indent-level as integer no-undo initial 0. define variable indent-spaces as character format "x(300)":U no-undo initial "". define variable infile like addfile. define variable infile-directory like infile. define variable infile-ext-pattern as character format "x(5)":U no-undo. define variable infile-ext-portion as character format "X(3)":U no-undo. define variable infile-name-pattern as character format "x(10)":U no-undo. define variable infile-name-portion as character no-undo. define variable remaining-codeline as character no-undo format "x(900)":U. define variable line-number as integer no-undo. define variable l-longline as logical no-undo. define variable maximum-line-length as integer no-undo format ">>9":U initial 319. define variable midquote as logical no-undo. /*used in break-codeline*/ define variable name-max as integer no-undo. define variable nocomment-codeline like remaining-codeline no-undo. define variable outfile like infile. define variable outfile-directory like infile-directory. define variable outfile-ext-pattern like infile-ext-pattern. define variable outfile-ext-portion like infile-ext-portion. define variable outfile-name-pattern like infile-name-pattern. define variable outfile-name-portion like infile-name-portion. define variable overwrite-outfile as logical no-undo initial false. define variable params-ok as logical no-undo initial false. define variable partial-indents as logical no-undo initial true. define variable partial-indents-active as logical initial false no-undo. define variable partial-indent-spaces as integer no-undo. define variable pattern-matched as logical no-undo. define variable l-possible-comment as logical no-undo. define variable saved-comment as character no-undo. define variable saved-indent-level as integer extent 5 no-undo. define variable single-cycle as logical no-undo initial false. define variable skipping as logical no-undo. define variable skipto-text like begin-text. define variable skipto-text-sensitive like begin-text-sensitive. define variable slash as character format "x" no-undo. define variable spaces-per-indent as integer no-undo initial 4. define variable sub-slashstar as character no-undo. sub-slashstar = chr(06). define variable sub-starslash as character no-undo. sub-starslash = chr(07). define variable suspended-for-comment as logical no-undo initial false. define variable suspended-for-quote as logical no-undo initial false. define variable suspend-for-quote like suspended-for-quote. define variable update-interval as integer no-undo format ">>9":U initial 50. define variable use-continuation-character as logical no-undo. define variable work-character like infile. define variable work-codeline like remaining-codeline. define variable work-handle as widget-handle no-undo. define variable work-logical as logical no-undo. define variable working-infile-name like infile. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ******************** Preprocessor Definitions ******************** */ /* Name of first Frame and/or Browse (alphabetically) */ &Scoped-define FRAME-NAME f-codeline /* Custom List Definitions */ &Scoped-define LIST-1 &Scoped-define LIST-2 &Scoped-define LIST-3 /* Definitions for FRAME f-codeline */ &Scoped-define FIELDS-IN-QUERY-f-codeline /* Definitions for FRAME f-editor-widget */ &Scoped-define FIELDS-IN-QUERY-f-editor-widget /* Definitions for FRAME f-filespecs */ &Scoped-define FIELDS-IN-QUERY-f-filespecs /* Definitions for FRAME f-new-codeline */ &Scoped-define FIELDS-IN-QUERY-f-new-codeline /* Definitions for FRAME f-processing */ &Scoped-define FIELDS-IN-QUERY-f-processing /* *********************** Control Definitions ********************** */ /* Define the widget handle for the window */ DEFINE VAR w-code-chg AS WIDGET-HANDLE NO-UNDO. /* Menu Definitions */ DEFINE SUB-MENU m_File MENU-ITEM m_Exit LABEL "Exit" ACCELERATOR "ALT-F4". DEFINE SUB-MENU m_Preferences MENU-ITEM m_Beautify_code LABEL "Beautify code" MENU-ITEM m_Check_for_long_lines LABEL "Check for long lines" MENU-ITEM m_Update_interval LABEL "Update interval". DEFINE SUB-MENU m_Help MENU-ITEM m_About LABEL "About" . DEFINE MENU MENU-BAR-w-code-chg MENUBAR SUB-MENU m_File LABEL "File" SUB-MENU m_Preferences LABEL "Preferences" SUB-MENU m_Help LABEL "Help" . /* Definitions of the field level widgets */ DEFINE BUTTON b-dup-input-filespec LABEL "Copy to out filespec.":L SIZE 22 BY 1. DEFINE BUTTON b-exit AUTO-END-KEY LABEL "Exit":L SIZE 10 BY 1. DEFINE BUTTON b-start LABEL "START":L SIZE 15 BY 1. DEFINE VARIABLE begin-line AS CHARACTER FORMAT "X(128)":U LABEL "Begin ln/text to repl" VIEW-AS FILL-IN SIZE 51 BY 1 NO-UNDO. DEFINE VARIABLE end-line AS CHARACTER FORMAT "X(128)":U LABEL "End line" VIEW-AS FILL-IN SIZE 51 BY 1 NO-UNDO. DEFINE VARIABLE input-filespec AS CHARACTER FORMAT "X(128)":U LABEL "Input filespec" VIEW-AS FILL-IN SIZE 51 BY 1 NO-UNDO. DEFINE VARIABLE new-code AS CHARACTER FORMAT "X(128)":U LABEL "New code" VIEW-AS FILL-IN SIZE 51 BY 1 NO-UNDO. DEFINE VARIABLE output-filespec AS CHARACTER FORMAT "X(128)":U LABEL "Output filespec" VIEW-AS FILL-IN SIZE 51 BY 1 NO-UNDO. DEFINE VARIABLE r-function AS INTEGER VIEW-AS RADIO-SET HORIZONTAL RADIO-BUTTONS "Replace words/phrases",0, "Replace lines",1, "Insert lines",2, "Beautify code",3, "Check for long lines",4 SIZE 98 BY 1 FGCOLOR 9 NO-UNDO. DEFINE RECTANGLE RECT-1 EDGE-PIXELS 2 GRAPHIC-EDGE SIZE 101 BY 3. DEFINE RECTANGLE RECT-2 EDGE-PIXELS 2 GRAPHIC-EDGE SIZE 101 BY 4. DEFINE RECTANGLE RECT-3 EDGE-PIXELS 3 GRAPHIC-EDGE SIZE 101 BY 2. DEFINE RECTANGLE RECT-4 EDGE-PIXELS 2 GRAPHIC-EDGE SIZE 101 BY 3. DEFINE VARIABLE skipto-line AS CHARACTER FORMAT "X(128)":U LABEL "Skip to line" VIEW-AS FILL-IN SIZE 51 BY 1 NO-UNDO. DEFINE VARIABLE source-input-file AS CHARACTER FORMAT "X(128)":U VIEW-AS FILL-IN SIZE 51 BY 1 NO-UNDO. DEFINE VARIABLE t-case-sensitive-begin AS LOGICAL INITIAL no LABEL "Case-sensitive":L VIEW-AS TOGGLE-BOX SIZE 17 BY .6 NO-UNDO. DEFINE VARIABLE t-case-sensitive-end AS LOGICAL INITIAL no LABEL "Case-sensitive":L VIEW-AS TOGGLE-BOX SIZE 17 BY .6 NO-UNDO. DEFINE VARIABLE t-case-sensitive-skipto AS LOGICAL INITIAL no LABEL "Case-sensitive":L VIEW-AS TOGGLE-BOX SIZE 17 BY .7 NO-UNDO. DEFINE VARIABLE t-exact-match-end AS LOGICAL INITIAL no LABEL "Exact match":L VIEW-AS TOGGLE-BOX SIZE 17 BY .6 NO-UNDO. DEFINE VARIABLE t-input-from-file AS LOGICAL INITIAL no LABEL "Input from file:":L VIEW-AS TOGGLE-BOX SIZE 16 BY 1 NO-UNDO. DEFINE VARIABLE t-insert-before AS LOGICAL INITIAL no LABEL "Apply before target line":L VIEW-AS TOGGLE-BOX SIZE 22.5 BY .8 NO-UNDO. DEFINE VARIABLE t-multiple-occurrences AS LOGICAL INITIAL no LABEL "Multiple occurrences":L VIEW-AS TOGGLE-BOX SIZE 21 BY .7 NO-UNDO. DEFINE VARIABLE t-overwrite-duplicates AS LOGICAL INITIAL no LABEL "Overwrite duplicates":L VIEW-AS TOGGLE-BOX SIZE 22 BY 1 NO-UNDO. DEFINE VARIABLE new-codeline AS CHARACTER FORMAT "X(320)":U VIEW-AS FILL-IN SIZE 150 BY 1 NO-UNDO. DEFINE BUTTON b-cancel-all LABEL "Cancel all":L SIZE 10 BY .9. DEFINE BUTTON b-cancel-file LABEL "Cancel file":L SIZE 10 BY .9. DEFINE VARIABLE infile-name AS CHARACTER FORMAT "X(50)":U LABEL "Reading from" VIEW-AS FILL-IN SIZE 50.5 BY 1 NO-UNDO. DEFINE VARIABLE outfile-name AS CHARACTER FORMAT "X(50)":U LABEL "Sending to" VIEW-AS FILL-IN SIZE 50.5 BY 1 NO-UNDO. DEFINE VARIABLE processing-file AS CHARACTER FORMAT ">>,>>9":U LABEL "File #" VIEW-AS FILL-IN SIZE 10 BY 1 NO-UNDO. DEFINE VARIABLE processing-line AS CHARACTER FORMAT ">>,>>9":U LABEL "Line #" VIEW-AS FILL-IN SIZE 10 BY 1 NO-UNDO. DEFINE VARIABLE codeline AS CHARACTER FORMAT "X(320)":U VIEW-AS FILL-IN SIZE 150 BY 1 NO-UNDO. /* ************************ Frame Definitions *********************** */ DEFINE FRAME f-editor-widget WITH 1 DOWN NO-BOX OVERLAY NO-LABELS AT COL 1 ROW 1 SCROLLABLE SIZE 320 BY 18. DEFINE FRAME f-codeline codeline AT ROW 1 COL 1 NO-LABEL WITH DOWN NO-BOX NO-LABELS AT COL 1 ROW 1 SIZE 320 BY 1. DEFINE FRAME f-new-codeline new-codeline AT ROW 1 COL 1 NO-LABEL WITH DOWN NO-BOX OVERLAY NO-LABELS AT COL 1 ROW 5 SIZE 320 BY 1. DEFINE FRAME f-processing b-cancel-file AT ROW 1.1 COL 1.5 infile-name AT ROW 1.2 COL 23.63 COLON-ALIGNED processing-file AT ROW 1.2 COL 86 COLON-ALIGNED b-cancel-all AT ROW 2.2 COL 1.5 outfile-name AT ROW 2.2 COL 23.63 COLON-ALIGNED processing-line AT ROW 2.2 COL 86 COLON-ALIGNED WITH 1 DOWN OVERLAY SIDE-LABELS TOP-ONLY AT COL 1.5 ROW 3 SIZE 101 BY 4 BGCOLOR 8 TITLE BGCOLOR 8 "Processing Files":L. DEFINE FRAME f-filespecs r-function AT ROW 1.8 COL 2 NO-LABEL input-filespec AT ROW 4.4 COL 23.5 COLON-ALIGNED HELP "(Wildcards ok), ALT-S=Selection List" b-dup-input-filespec AT ROW 4.4 COL 77.5 output-filespec AT ROW 5.4 COL 23.5 COLON-ALIGNED HELP "(Wildcards ok), ALT-S=Selection List" t-overwrite-duplicates AT ROW 5.4 COL 77.5 t-case-sensitive-skipto AT ROW 7.1 COL 77.5 skipto-line AT ROW 7.2 COL 23.5 COLON-ALIGNED HELP "Skip to this line to start looking for 'Begin line'" t-case-sensitive-begin AT ROW 8 COL 77.5 begin-line AT ROW 8.2 COL 23.5 COLON-ALIGNED HELP "NOTE: Specify ~"interlace~" to interlace old/new text." t-multiple-occurrences AT ROW 8.6 COL 77.5 t-case-sensitive-end AT ROW 9.6 COL 77.5 end-line AT ROW 9.7 COL 23.5 COLON-ALIGNED t-exact-match-end AT ROW 10.2 COL 77.5 new-code AT ROW 11.5 COL 23.5 COLON-ALIGNED t-insert-before AT ROW 12.1 COL 77.5 t-input-from-file AT ROW 12.5 COL 8.5 source-input-file AT ROW 12.5 COL 23.5 COLON-ALIGNED HELP "ALT-S=Selection List" NO-LABEL b-start AT ROW 15 COL 6 HELP "Press spacebar / ENTER / F2 to start." b-exit AT ROW 15 COL 86 HELP "Press spacebar or ENTER to exit program." "FUNCTION":U VIEW-AS TEXT SIZE 13 BY 1 AT ROW 1 COL 43 RECT-3 AT ROW 1.4 COL 1.5 RECT-4 AT ROW 4 COL 1.5 RECT-2 AT ROW 7 COL 1.5 RECT-1 AT ROW 11 COL 1.5 WITH 1 DOWN NO-BOX OVERLAY SIDE-LABELS AT COL 1 ROW 1 SIZE 128 BY 22.43. /* ************************* Create Window ************************** */ &ANALYZE-SUSPEND _CREATE-WINDOW IF SESSION:DISPLAY-TYPE = "GUI":U THEN CREATE WINDOW w-code-chg ASSIGN HIDDEN = YES TITLE = "Code Changer" COLUMN = 1 ROW = 1 HEIGHT = 16.67 WIDTH = 128 MAX-HEIGHT = 16.67 MAX-WIDTH = 320 VIRTUAL-HEIGHT = 16.67 VIRTUAL-WIDTH = 320 RESIZE = no SCROLL-BARS = no STATUS-AREA = yes BGCOLOR = ? FGCOLOR = ? MESSAGE-AREA = no THREE-D = no SENSITIVE = yes. ELSE {&WINDOW-NAME} = CURRENT-WINDOW. ASSIGN {&WINDOW-NAME}:MENUBAR = MENU MENU-BAR-w-code-chg:HANDLE. &ANALYZE-RESUME /* *************** Runtime Attributes and UIB Settings ************** */ &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES /* SETTINGS FOR FRAME f-codeline NOT-VISIBLE UNDERLINE */ ASSIGN FRAME f-codeline:SCROLLABLE = FALSE FRAME f-codeline:SENSITIVE = FALSE. /* SETTINGS FOR FILL-IN codeline IN FRAME f-codeline NO-DISPLAY NO-ENABLE ALIGN-L */ /* SETTINGS FOR FRAME f-editor-widget NOT-VISIBLE UNDERLINE */ ASSIGN FRAME f-editor-widget:HEIGHT = 14 FRAME f-editor-widget:WIDTH = 100.125 FRAME f-editor-widget:SENSITIVE = FALSE. /* SETTINGS FOR FRAME f-filespecs UNDERLINE */ /* SETTINGS FOR BUTTON b-dup-input-filespec IN FRAME f-filespecs NO-DISPLAY */ /* SETTINGS FOR BUTTON b-exit IN FRAME f-filespecs NO-DISPLAY */ /* SETTINGS FOR BUTTON b-start IN FRAME f-filespecs NO-DISPLAY */ /* SETTINGS FOR FILL-IN begin-line IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FILL-IN end-line IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FILL-IN input-filespec IN FRAME f-filespecs NO-DISPLAY */ /* SETTINGS FOR FILL-IN new-code IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FILL-IN output-filespec IN FRAME f-filespecs NO-DISPLAY */ /* SETTINGS FOR RADIO-SET r-function IN FRAME f-filespecs NO-DISPLAY */ /* SETTINGS FOR RECTANGLE RECT-1 IN FRAME f-filespecs NO-ENABLE */ /* SETTINGS FOR RECTANGLE RECT-2 IN FRAME f-filespecs NO-ENABLE */ /* SETTINGS FOR RECTANGLE RECT-3 IN FRAME f-filespecs NO-ENABLE */ /* SETTINGS FOR RECTANGLE RECT-4 IN FRAME f-filespecs NO-ENABLE */ /* SETTINGS FOR FILL-IN skipto-line IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FILL-IN source-input-file IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-case-sensitive-begin IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-case-sensitive-end IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-case-sensitive-skipto IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-exact-match-end IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-input-from-file IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-insert-before IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-multiple-occurrences IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR TOGGLE-BOX t-overwrite-duplicates IN FRAME f-filespecs NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FRAME f-new-codeline NOT-VISIBLE UNDERLINE */ ASSIGN FRAME f-new-codeline:SCROLLABLE = FALSE FRAME f-new-codeline:SENSITIVE = FALSE. /* SETTINGS FOR FILL-IN new-codeline IN FRAME f-new-codeline NO-DISPLAY NO-ENABLE ALIGN-L */ /* SETTINGS FOR FRAME f-processing NOT-VISIBLE UNDERLINE */ /* SETTINGS FOR BUTTON b-cancel-all IN FRAME f-processing NO-DISPLAY */ /* SETTINGS FOR BUTTON b-cancel-file IN FRAME f-processing NO-DISPLAY */ /* SETTINGS FOR FILL-IN infile-name IN FRAME f-processing NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FILL-IN outfile-name IN FRAME f-processing NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FILL-IN processing-file IN FRAME f-processing NO-DISPLAY NO-ENABLE */ /* SETTINGS FOR FILL-IN processing-line IN FRAME f-processing NO-DISPLAY NO-ENABLE */ IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(w-code-chg) THEN w-code-chg:HIDDEN = no. /* _RUN-TIME-ATTRIBUTES-END */ &ANALYZE-RESUME /* Setting information for Queries and Browse Widgets fields */ &ANALYZE-SUSPEND _QUERY-BLOCK FRAME f-codeline /* Query rebuild information for FRAME f-codeline _TblList = "" _Options = "" _OrdList = "" _Query is NOT OPENED */ /* FRAME f-codeline */ &ANALYZE-RESUME &ANALYZE-SUSPEND _QUERY-BLOCK FRAME f-editor-widget /* Query rebuild information for FRAME f-editor-widget _TblList = "" _Options = "" _OrdList = "" _Query is NOT OPENED */ /* FRAME f-editor-widget */ &ANALYZE-RESUME &ANALYZE-SUSPEND _QUERY-BLOCK FRAME f-filespecs /* Query rebuild information for FRAME f-filespecs _TblList = "" _Options = "SHARE-LOCK" _OrdList = "" _Query is NOT OPENED */ /* FRAME f-filespecs */ &ANALYZE-RESUME &ANALYZE-SUSPEND _QUERY-BLOCK FRAME f-new-codeline /* Query rebuild information for FRAME f-new-codeline _TblList = "" _Options = "" _OrdList = "" _Query is NOT OPENED */ /* FRAME f-new-codeline */ &ANALYZE-RESUME &ANALYZE-SUSPEND _QUERY-BLOCK FRAME f-processing /* Query rebuild information for FRAME f-processing _TblList = "" _Options = "" _OrdList = "" _Query is NOT OPENED */ /* FRAME f-processing */ &ANALYZE-RESUME /* ************************ Control Triggers ************************ */ &Scoped-define SELF-NAME m_Exit &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Exit w-code-chg ON CHOOSE OF MENU-ITEM m_Exit /* Exit */ DO: apply "WINDOW-CLOSE":U to {&WINDOW-NAME}. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME m_Beautify_code &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Beautify_code w-code-chg ON CHOOSE OF MENU-ITEM m_Beautify_code /* Beautify code */ DO: i = beautify-line-length. update beautify-line-length label "Line length" format ">>9 ":U l-format-def-var label "Format DEFINE VARIABLE":U partial-indents label "Use partial indents for FORM, etc.":U spaces-per-indent label "Spaces per indent" format ">9 ":U l-drop-comments label "Drop (delete) comments":U go-on(MOUSE-SELECT-DBLCLICK) with frame f-beautify-line-length side-labels view-as dialog-box title "Preferences: Beautify code". if beautify-line-length = 0 or beautify-line-length > 319 then do: message "Allowable values for line length range from 1 to 319." view-as alert-box information. beautify-line-length = i. end. if not beautify-line-length = i then do: delete widget editor-widget. run create-editor-widget. end. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME m_Check_for_long_lines &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Check_for_long_lines w-code-chg ON CHOOSE OF MENU-ITEM m_Check_for_long_lines /* Check for long lines */ DO: i = maximum-line-length. update maximum-line-length label "Line length" format ">>>9":U go-on(MOUSE-SELECT-DBLCLICK) with frame f-maximum-line-length side-labels view-as dialog-box title "Preferences: Check for long lines". if maximum-line-length = 0 or maximum-line-length > 319 then do: message "Allowable values for line length range from 1 to 319." view-as alert-box information. maximum-line-length = i. end. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME m_Update_interval &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_Update_interval w-code-chg ON CHOOSE OF MENU-ITEM m_Update_interval /* Update interval */ DO: i = update-interval. update update-interval label "Update interval (lines)" format " >>9":U go-on(MOUSE-SELECT-DBLCLICK) with frame f-update-interval side-labels view-as dialog-box title "Preferences: Update interval". if update-interval = 0 or update-interval > 500 then do: message "Allowable values for update interval range from 1 to 500." view-as alert-box information. update-interval = i. end. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME m_About &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL m_About w-code-chg ON CHOOSE OF MENU-ITEM m_About /* About */ DO: message "Code Changer is designed primarily for PROGRESS source code files," + crlf + "but can be used for any ASCII text file as well." + crlf + "User feedback is solicited -- contact David James." view-as alert-box information title "About Code Changer". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME f-filespecs &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL f-filespecs w-code-chg ON ENDKEY OF FRAME f-filespecs DO: quit. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL f-filespecs w-code-chg ON GO OF FRAME f-filespecs DO: apply "CHOOSE":U to b-start. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME w-code-chg &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL w-code-chg w-code-chg ON WINDOW-CLOSE OF w-code-chg /* Code Changer */ DO: quit. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define FRAME-NAME f-processing &Scoped-define SELF-NAME b-cancel-all &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL b-cancel-all w-code-chg ON CHOOSE OF b-cancel-all IN FRAME f-processing /* Cancel all */ DO: apply "CHOOSE":U to b-cancel-file. /*cancel processing of current file*/ single-cycle = true. /*and don't bother to process another one*/ END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME b-cancel-file &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL b-cancel-file w-code-chg ON CHOOSE OF b-cancel-file IN FRAME f-processing /* Cancel file */ DO: cancel-chosen = true. /*stop processing this file*/ END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define FRAME-NAME f-filespecs &Scoped-define SELF-NAME b-dup-input-filespec &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL b-dup-input-filespec w-code-chg ON CHOOSE OF b-dup-input-filespec IN FRAME f-filespecs /* Copy to out filespec. */ DO: output-filespec:screen-value = input-filespec:screen-value + "1". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME b-start &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL b-start w-code-chg ON CHOOSE OF b-start IN FRAME f-filespecs /* START */ DO: assign input-filespec output-filespec t-overwrite-duplicates skipto-line begin-line t-case-sensitive-begin t-multiple-occurrences t-insert-before end-line t-case-sensitive-end t-exact-match-end new-code t-input-from-file source-input-file . if not r-function = 4 then do: if (index(input-filespec,"*") > 0 and index(output-filespec,"*") = 0) or (index(input-filespec,"?") > 0 and index(output-filespec,"?") = 0) then do: message "If wild cards are used in the input file specification, they must also be used in the output file specification." view-as alert-box warning. leave. end. if t-input-from-file:sensitive and t-input-from-file:checked and search(source-input-file) = ? then do: message "Input from file is checked, but file cannot be found" view-as alert-box warning. leave. end. end. case r-function: when 0 then do: /*replace with words/phrases*/ if not (length(input-filespec) > 0 and length(output-filespec) > 0 and length(begin-line) > 0) then run z-missing-message. else params-ok = true. end. when 1 then do: /*replace lines*/ if not (length(input-filespec) > 0 and length(output-filespec) > 0 and length(begin-line) > 0) then run z-missing-message. else params-ok = true. end. when 2 then do: /*insert lines*/ if not ((length(input-filespec) > 0 and length(output-filespec) > 0 and length(begin-line) > 0) or begin-line = "interlace") then run z-missing-message. else params-ok = true. end. when 3 then do: /*beautify code*/ if not length(input-filespec) > 0 then run z-missing-message. else params-ok = true. end. when 4 then do: /*check for long lines*/ if not length(input-filespec) > 0 then run z-missing-message. else params-ok = true. end. end case. if params-ok then run parse-filespec ( input-output input-filespec, output infile-directory, output infile-name-pattern, output infile-ext-pattern). if search(input-filespec) = ? then do: if search ("." + slash + input-filespec) ne ? then input-filespec = "." + slash + input-filespec. else do: message "No matching files can be found." view-as alert-box error. params-ok = false. end. end. if output-filespec begins "*" then output-filespec = infile-directory + output-filespec. if substring(output-filespec,2,2) = ":*" then output-filespec = substring(output-filespec,1,2) + substring(infile-directory,3,length(infile-directory) - 2) + substring(output-filespec,3,length(output-filespec) - 2). run parse-filespec ( input-output output-filespec, output outfile-directory, output outfile-name-pattern, output outfile-ext-pattern). if params-ok then do: if index(output-filespec,"*") > 0 or index(output-filespec,"?") > 0 then do: if (index(outfile-name-pattern,"*") > 0 and index(outfile-name-pattern,"?") > 0) or (index(outfile-ext-pattern,"*") > 0 and index(outfile-ext-pattern,"?") > 0) then do: message "Illegal output file specification -- * and ? cannot co-exist in name or extension portion of file specification." view-as alert-box warning. params-ok = false. end. end. end. if params-ok then do: if not end-line > " " then end-line = begin-line. file-number = 0. display file-number @ processing-file line-number @ processing-line with frame f-processing. /*view frame f-processing.*/ wait-for end-error of frame f-processing focus b-cancel-file in frame f-processing pause .1. assign skipto-text = skipto-line skipto-text-sensitive = skipto-line begin-text = begin-line begin-text-sensitive = begin-line end-text = end-line end-text-sensitive = end-line . case r-function: when 0 then do: /*replace with words/phrases*/ if t-input-from-file:checked in frame f-filespecs then do: input stream newtext from value(source-input-file) no-echo. import stream intext unformatted new-code. input stream newtext close. end. repeat while not single-cycle: run establish-next-filenames. if length(infile) > 0 then run replace-words. else if not params-ok then leave. end. end. when 1 then repeat while not single-cycle: /*replace lines*/ run establish-next-filenames. if length(infile) > 0 then run replace-or-insert-lines. else if not params-ok then leave. end. when 2 then repeat while not single-cycle: /*insert lines*/ run establish-next-filenames. if length(infile) > 0 then run replace-or-insert-lines. else if not params-ok then leave. end. when 3 then repeat while not single-cycle: /*beautify code*/ run establish-next-filenames. if length(infile) > 0 then run beautify-code. else if not params-ok then leave. end. when 4 then do: linecheck-loop: repeat while not single-cycle: /*check for long lines*/ run establish-next-filenames. if length(infile) > 0 then do: run check-for-long-lines. if not params-ok then leave linecheck-loop. end. else if not params-ok then leave. end. end. end case. cycling-through-files = false. single-cycle = false. if not changes-made then message "No changes were made.". changes-made = false. end. apply "entry":U to input-filespec in frame f-filespecs. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME begin-line &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL begin-line w-code-chg ON HELP OF begin-line IN FRAME f-filespecs /* Begin ln/text to repl */ DO: message "If 'replace words/phrases' this is the text to be replaced; if 'replace lines' this text exists in the first line to be replaced.". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME end-line &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL end-line w-code-chg ON HELP OF end-line IN FRAME f-filespecs /* End line */ DO: message "This text exists in the last line to be replaced. If this is identical to the 'replace/begin replace' text then the new code will be inserted BEFORE the line containing this text". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME input-filespec &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL input-filespec w-code-chg ON ALT-S OF input-filespec IN FRAME f-filespecs /* Input filespec */ DO: apply "MOUSE-SELECT-DBLCLICK":U to self. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL input-filespec w-code-chg ON HELP OF input-filespec IN FRAME f-filespecs /* Input filespec */ DO: message ("Valid wild card patterns for " + crlf + "'name' and 'ext' portions of file name include:" + crlf + "x x* *x *x* x? x?? ?x ?xx ??x ?x?") view-as alert-box information title "Input file specification". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL input-filespec w-code-chg ON MOUSE-SELECT-DBLCLICK OF input-filespec IN FRAME f-filespecs /* Input filespec */ DO: system-dialog get-file input-filespec title "Input file". display input-filespec with frame f-filespecs. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME output-filespec &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL output-filespec w-code-chg ON ALT-S OF output-filespec IN FRAME f-filespecs /* Output filespec */ DO: apply "MOUSE-SELECT-DBLCLICK":U to self. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL output-filespec w-code-chg ON HELP OF output-filespec IN FRAME f-filespecs /* Output filespec */ DO: message "Valid wild card patterns for " + crlf + "'name' and 'ext' portions of file name include:" + crlf + "x x* *x x? x?? ?x ?xx ??x ?x?" + crlf + "(Drive letter and colon may be used prior to *x.)" view-as alert-box information title "Output file specification". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL output-filespec w-code-chg ON MOUSE-SELECT-DBLCLICK OF output-filespec IN FRAME f-filespecs /* Output filespec */ DO: system-dialog get-file output-filespec title "Output file" save-as ask-overwrite. display output-filespec with frame f-filespecs. overwrite-outfile = false. if search(output-filespec) <> ? then overwrite-outfile = true. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME r-function &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL r-function w-code-chg ON VALUE-CHANGED OF r-function IN FRAME f-filespecs DO: assign r-function. case r-function: when 0 then do: /*replace with words/phrases*/ output-filespec:sensitive = true. t-overwrite-duplicates:sensitive = true. skipto-line:sensitive = true. t-case-sensitive-skipto:sensitive = skipto-line:sensitive. t-multiple-occurrences:checked = true. t-multiple-occurrences:sensitive = false. begin-line:sensitive = true. t-case-sensitive-begin:sensitive = true. t-multiple-occurrences:sensitive = true. t-case-sensitive-end:sensitive = false. t-exact-match-end:sensitive = false. end-line:sensitive = false. new-code:sensitive = true. t-insert-before:sensitive = false. t-input-from-file:sensitive = true. apply "VALUE-CHANGED":U to t-input-from-file. end. when 1 then do: /*replace lines*/ output-filespec:sensitive = true. t-overwrite-duplicates:sensitive = true. skipto-line:sensitive = true. t-case-sensitive-skipto:sensitive = skipto-line:sensitive. begin-line:sensitive = true. t-case-sensitive-begin:sensitive = true. t-multiple-occurrences:sensitive = true. end-line:sensitive = true. t-case-sensitive-end:sensitive = true. t-exact-match-end:sensitive = true. new-code:sensitive = true. t-insert-before:sensitive = true. t-input-from-file:sensitive = true. apply "VALUE-CHANGED":U to t-input-from-file. end. when 2 then do: /*insert lines*/ output-filespec:sensitive = true. t-overwrite-duplicates:sensitive = true. skipto-line:sensitive = true. t-case-sensitive-skipto:sensitive = skipto-line:sensitive. t-multiple-occurrences:sensitive = true. begin-line:sensitive = true. t-case-sensitive-begin:sensitive = true. t-multiple-occurrences:sensitive = true. end-line:sensitive = false. t-case-sensitive-end:sensitive = false. t-exact-match-end:sensitive = false. new-code:sensitive = true. t-insert-before:sensitive = true. t-input-from-file:sensitive = true. apply "VALUE-CHANGED":U to t-input-from-file. end. when 3 then do: /*beautify code*/ output-filespec:sensitive = true. t-overwrite-duplicates:sensitive = true. skipto-line:sensitive = false. t-case-sensitive-skipto:sensitive = skipto-line:sensitive. t-multiple-occurrences:sensitive = false. begin-line:sensitive = false. t-case-sensitive-begin:sensitive = false. t-multiple-occurrences:sensitive = false. t-case-sensitive-end:sensitive = false. t-exact-match-end:sensitive = false. end-line:sensitive = false. new-code:sensitive = false. t-insert-before:sensitive = false. t-input-from-file:sensitive = false. source-input-file:sensitive = false. end. when 4 then do: /*check for long lines*/ output-filespec:sensitive = false. t-overwrite-duplicates:sensitive = false. skipto-line:sensitive = false. t-case-sensitive-skipto:sensitive = skipto-line:sensitive. t-multiple-occurrences:sensitive = false. begin-line:sensitive = false. t-case-sensitive-begin:sensitive = false. t-multiple-occurrences:sensitive = false. t-case-sensitive-end:sensitive = false. t-exact-match-end:sensitive = false. end-line:sensitive = false. new-code:sensitive = false. t-insert-before:sensitive = false. t-input-from-file:sensitive = false. source-input-file:sensitive = false. end. end case. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME skipto-line &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL skipto-line w-code-chg ON HELP OF skipto-line IN FRAME f-filespecs /* Skip to line */ DO: message "If 'replace words/phrases' this is the text to be replaced; if 'replace lines' this text exists in the first line to be replaced.". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME source-input-file &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL source-input-file w-code-chg ON MOUSE-SELECT-DBLCLICK OF source-input-file IN FRAME f-filespecs DO: system-dialog get-file source-input-file title "Source code input file" must-exist. display source-input-file with frame f-filespecs. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL source-input-file w-code-chg ON ALT-S OF source-input-file IN FRAME f-filespecs DO: apply "MOUSE-SELECT-DBLCLICK":U to self. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME t-input-from-file &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL t-input-from-file w-code-chg ON VALUE-CHANGED OF t-input-from-file IN FRAME f-filespecs /* Input from file: */ DO: if t-input-from-file:checked then do: source-input-file:sensitive = true. new-code:sensitive = false. end. else do: source-input-file:sensitive = false. new-code:sensitive = true. end. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME t-insert-before &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL t-insert-before w-code-chg ON HELP OF t-insert-before IN FRAME f-filespecs /* Apply before target line */ DO: message "Choose this option if you wish to insert or replace the new code BEFORE instead of after the specified line(s)." view-as alert-box information. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME t-multiple-occurrences &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL t-multiple-occurrences w-code-chg ON HELP OF t-multiple-occurrences IN FRAME f-filespecs /* Multiple occurrences */ DO: message "Don't check this option unless you really need it." view-as alert-box information title "Multiple occurrences". END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define FRAME-NAME f-codeline &UNDEFINE SELF-NAME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK w-code-chg /* *************************** Main Block *************************** */ /* Send messages to alert boxes because there is no message area. */ ASSIGN CURRENT-WINDOW = {&WINDOW-NAME} SESSION:SYSTEM-ALERT-BOXES = (CURRENT-WINDOW:MESSAGE-AREA = NO). /* Best default for GUI applications is... */ PAUSE 0 BEFORE-HIDE. session:data-entry-return = true. if opsys = "UNIX" then assign ext-max = 32 name-max = 32 slash = chr(47) . else assign ext-max = 3 name-max = 8 slash = chr(92) . /* Now enable the interface and wait for the exit condition. */ RUN enable_UI. run create-editor-widget. work-handle = r-function:parent. work-handle:first-tab-item = r-function:handle. r-function:screen-value = "3". apply "VALUE-CHANGED":U to r-function. WAIT-FOR WINDOW-CLOSE OF {&WINDOW-NAME} focus input-filespec. RUN disable_UI. quit. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ********************** Internal Procedures *********************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE beautify-code w-code-chg PROCEDURE beautify-code : define variable current-indent-level like indent-level. define variable partial-indents-pending as logical initial false no-undo. define variable preprocessor-level as integer no-undo. define variable sandwiched-doublequote as character no-undo. define variable sandwiched-singlequote as character no-undo. define variable saved-codeline as character no-undo format "x(320)":U . define variable codeline-segment like saved-codeline. define variable suspend-for-comment like suspended-for-comment. assign indent-level = 0 sandwiched-doublequote = "'" + '"' + "'" sandwiched-singlequote = '"' + "'" + '"' no-error. delete widget editor-widget. run create-editor-widget. partial-indent-spaces = integer(spaces-per-indent / 2). input stream intext from value(working-infile-name) no-echo. output stream outtext to value(outfile-name) no-echo. suspended-for-comment = false. suspended-for-quote = false. repeat: suspend-for-comment = suspended-for-comment. suspend-for-quote = suspended-for-quote. ending-suspension = false. import stream intext unformatted codeline. run update-processing-display. /*increments line-number*/ if cancel-chosen then leave. assign remaining-codeline = codeline nocomment-codeline = codeline codeline-segment = codeline . if suspended-for-comment then do: if l-drop-comments eq yes then nocomment-codeline = "". i = index(remaining-codeline,"*/"). if i > 0 then do: codeline-segment = substring(remaining-codeline,(i + 2),(length(remaining-codeline) - (i + 2))). suspended-for-comment = false. suspend-for-comment = false. ending-suspension = true. if l-drop-comments eq yes then nocomment-codeline = codeline-segment. end. end. if suspended-for-quote then do: i = index(remaining-codeline,'"'). if not i > 0 then i = index(remaining-codeline,"'"). if i > 0 then do: codeline-segment = substring(remaining-codeline,i + 1,length(remaining-codeline) - 1). suspended-for-quote = false. suspend-for-quote = false. ending-suspension = true. end. end. if not (suspended-for-comment or suspended-for-quote) then repeat while index(codeline-segment,"/*") > 0 or index(codeline-segment,'"') > 0: repeat while index(codeline-segment,'""') > 0: codeline-segment = replace(codeline-segment,'""',''). end. repeat while index(codeline-segment,sandwiched-doublequote) > 0: codeline-segment = replace(codeline-segment,sandwiched-doublequote,''). end. repeat while index(codeline-segment,sandwiched-singlequote) > 0: codeline-segment = replace(codeline-segment,sandwiched-singlequote,''). end. if index(codeline-segment,"/*") > 0 then do: if index(codeline-segment,'"') > 0 and index(codeline-segment,'"') < index(codeline-segment,"/*") then leave. i = index(codeline-segment,"*/"). if i > 0 then do: codeline-segment = substring(codeline-segment,1,index(codeline-segment,"/*") - 1) + substring(codeline-segment,i + 2,length(codeline-segment) - i - 1). if l-drop-comments eq yes then do: ii = index(nocomment-codeline,"*/"). nocomment-codeline = substring(nocomment-codeline,1,index(nocomment-codeline,"/*") - 1) + substring(nocomment-codeline,ii + 2,length(nocomment-codeline) - ii - 1). end. end. else do: suspend-for-comment = true. codeline-segment = substring(codeline-segment,1,index(codeline-segment,"/*") - 1). if l-drop-comments eq yes then nocomment-codeline = substring(nocomment-codeline,1,index(nocomment-codeline,"/*") - 1). end. end. if index(codeline-segment,'"') > 0 then do: if index(codeline-segment,"/*") > 0 and index(codeline-segment,"/*") < index(codeline-segment,'"') then leave. i = index(codeline-segment,'"'). if index(codeline-segment,'"',i + 1) > 0 then do: ii = index(codeline-segment,'"',i + 1). codeline-segment = substring(codeline-segment,1,i - 1) + substring(codeline-segment,ii + 1,length(codeline-segment) - ((ii - i) + 1)). end. else do: suspend-for-quote = true. codeline-segment = substring(codeline-segment,1,index(codeline-segment,'"') - 1). end. end. end. if (suspended-for-comment or suspended-for-quote) and left-trim(codeline-segment) begins "end procedure" then message "END PROCEDURE found within comment block". if not (suspended-for-comment or suspended-for-quote) then do: codeline-segment = left-trim(codeline-segment). if (codeline-segment begins "end." or codeline-segment begins "end:" or codeline-segment begins "end ") then do: /*covers end case, end triggers, end procedure*/ indent-level = indent-level - 1. if indent-level = -1 then do: message "Line " + string(line-number) + " has caused the indentation level to go negative." view-as alert-box warning buttons ok-cancel update cancel-chosen. cancel-chosen = not cancel-chosen. indent-level = 0. end. run set-indent-spaces. end. end. saved-codeline = remaining-codeline. current-indent-level = 0. /*flag = no preprocessor conditionals*/ if not (suspended-for-comment or suspended-for-quote) then do: if saved-codeline begins "&if" or saved-codeline begins "&else" /*includes &elseif*/ or saved-codeline begins "&endif" then do: current-indent-level = indent-level. if saved-codeline begins "&if" then do: preprocessor-level = preprocessor-level + 1. saved-indent-level[preprocessor-level] = indent-level. end. else if saved-codeline begins "&else" then do: /*includes &elsif*/ indent-level = saved-indent-level[preprocessor-level]. current-indent-level = indent-level. end. else if saved-codeline begins "&endif" then do: indent-level = saved-indent-level[preprocessor-level]. preprocessor-level = preprocessor-level - 1. if preprocessor-level = -1 then do: message "Line " + string(line-number) + " has caused the preprocessor level to go negative." view-as alert-box warning. preprocessor-level = 0. end. end. run set-indent-spaces. indent-level = current-indent-level. end. end. if not (suspended-for-comment or suspended-for-quote or left-trim(remaining-codeline) begins "/*" or ending-suspension) then do: remaining-codeline = left-trim(remaining-codeline). if partial-indents and length(trim(codeline-segment)) > 0 then do: if not substring(trim(codeline-segment),length(trim(codeline-segment))) = "." and (codeline-segment begins "accumulate" or codeline-segment begins "define frame" or codeline-segment begins "form" or codeline-segment begins "assign" or codeline-segment begins "update" or (length(trim(codeline-segment)) > length("assign") and substring(codeline-segment,(length(codeline-segment) - length("assign") + 1)) = "assign") or codeline-segment begins "display") then partial-indents-pending = true. end. l-def-var = no. if l-format-def-var and remaining-codeline begins "def" and index(remaining-codeline,"var") > 4 then do: assign l-def-var = yes saved-comment = "" i = index(remaining-codeline," /*") ii = index(remaining-codeline,"*/") no-error. if i > 8 and ii > i then do: saved-comment = substring(remaining-codeline,i,ii - i + 2). remaining-codeline = replace(remaining-codeline,saved-comment,""). end. remaining-codeline = substring(remaining-codeline,index(remaining-codeline," ") + 1). /*strip def/define*/ remaining-codeline = replace(remaining-codeline,"variable ","var "). remaining-codeline = replace(remaining-codeline,"as character ","as char "). remaining-codeline = replace(remaining-codeline,"as decimal ","as dec "). remaining-codeline = replace(remaining-codeline,"as logical ","as log "). remaining-codeline = replace(remaining-codeline,"as integer ","as int "). work-character = substring(remaining-codeline,1,index(remaining-codeline,"var ")). /*shared / new shared*/ remaining-codeline = substring(remaining-codeline,index(remaining-codeline,"var ") + length("var ")). remaining-codeline = "def " + (if index(work-character,"new ") > 0 then "new " else " ") + (if index(work-character,"shared ") > 0 then "shared " else " ") + "var " + remaining-codeline. if index(remaining-codeline," no-undo") > 0 then do: remaining-codeline = trim(replace(remaining-codeline," no-undo","")). work-logical = (substring(remaining-codeline,length(remaining-codeline),1) = "."). if work-logical eq yes then remaining-codeline = trim(substring(remaining-codeline,1,length(remaining-codeline) - 1)). i = beautify-line-length - (length(remaining-codeline) + length(" no-undo.") + (indent-level * spaces-per-indent)). if i > 0 then work-character = fill(" ", i) + " no-undo.". else work-character = " no-undo.". remaining-codeline = remaining-codeline + work-character. end. end. else do: if remaining-codeline begins "break by" then remaining-codeline = " " + remaining-codeline. if remaining-codeline begins "where" then remaining-codeline = " " + remaining-codeline. if remaining-codeline begins "each" then remaining-codeline = " " + remaining-codeline. if remaining-codeline begins "and" then remaining-codeline = " " + remaining-codeline. if remaining-codeline begins "or" then remaining-codeline = " " + remaining-codeline. if remaining-codeline begins "by" then remaining-codeline = " " + remaining-codeline. end. remaining-codeline = indent-spaces + remaining-codeline. if l-drop-comments eq yes then nocomment-codeline = indent-spaces + nocomment-codeline. end. l-longline = no. if length(remaining-codeline) > beautify-line-length then do: if codeline-segment begins "&scoped-define" or codeline-segment begins "&message" or codeline-segment begins "&analyze" then use-continuation-character = true. else use-continuation-character = false. curpos = 0. midquote = false. run break-codeline. end. if l-longline eq no then do: if not length(remaining-codeline) > beautify-line-length then do: if not l-drop-comments eq yes then do: if l-def-var eq yes then remaining-codeline = remaining-codeline + saved-comment. display stream outtext remaining-codeline @ codeline with frame f-codeline. down stream outtext with frame f-codeline. end. else do: if length(nocomment-codeline) > 0 then do: display stream outtext nocomment-codeline @ codeline with frame f-codeline. down stream outtext with frame f-codeline. end. end. end. end. if not partial-indents-active then partial-indents-active = partial-indents-pending. partial-indents-pending = false. run set-indent-spaces. if not (suspended-for-comment or suspended-for-quote) then do: if length(codeline-segment) > 0 then do: if partial-indents-active and substring(codeline-segment,length(codeline-segment)) = "." then do: partial-indents-active = false. run set-indent-spaces. end. codeline-segment = "%" + replace(codeline-segment," ","%"). codeline-segment = replace(codeline-segment,":","%"). codeline-segment = replace(codeline-segment,".","%"). if (index(codeline-segment,"%case%") > 0 and not index(codeline-segment,"end%case%") > 0) or index(codeline-segment,"%do%") > 0 or index(codeline-segment,"%editing%") > 0 or index(codeline-segment,"%repeat%") > 0 or codeline-segment begins "%triggers%" or codeline-segment begins "%procedure%" or codeline-segment begins "%for%each%" or codeline-segment begins "%editing%" then do: indent-level = indent-level + 1. if indent-level > 20 then do: message codeline-segment " caused indent-level to go over 20". leave. end. run set-indent-spaces. end. end. if not suspended-for-comment then suspended-for-comment = suspend-for-comment. if not suspended-for-quote then suspended-for-quote = suspend-for-quote. end. end. run housekeeping. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE break-codeline w-code-chg PROCEDURE break-codeline : /*NOTE: This procedure calls itself recursively if necessary*/ assign l-longline = no l-possible-comment = no no-error. if l-drop-comments eq no and index(remaining-codeline,"*") gt 0 then assign l-possible-comment = yes remaining-codeline = replace(remaining-codeline,"/*",sub-slashstar) remaining-codeline = replace(remaining-codeline,"*/",sub-starslash) no-error. editor-widget:screen-value = remaining-codeline. i = editor-widget:convert-to-offset(2,1). if i > 1 then do: work-logical = editor-widget:set-selection(1,i). work-codeline = editor-widget:selection-text. if midquote then do: midquote = false. curpos = index(work-codeline,'"',curpos + 1). end. if index(work-codeline,'"',curpos + 1) > 0 then work-logical = true. repeat while work-logical eq yes: work-logical = false. /*no unmatched quote*/ curpos = index(work-codeline,'"',curpos + 1). if curpos > 0 then work-logical = true. /*unmatched quote*/ curpos = index(work-codeline,'"',curpos + 1). if not curpos > 0 then leave. end. if work-logical eq yes then do: if not (suspended-for-quote or ending-suspension) then midquote = true. else suspended-for-quote = false. end. remaining-codeline = substring(remaining-codeline,i,(length(remaining-codeline) - i + 1)). end. else do: assign work-codeline = remaining-codeline l-longline = yes remaining-codeline = "" no-error. end. if l-possible-comment = yes then assign l-possible-comment = no remaining-codeline = replace(remaining-codeline,sub-slashstar,"/*") remaining-codeline = replace(remaining-codeline,sub-starslash,"*/") work-codeline = replace(work-codeline,sub-slashstar,"/*") work-codeline = replace(work-codeline,sub-starslash,"*/") no-error. if l-longline eq no and use-continuation-character eq yes then work-codeline = work-codeline + continuation-character. display stream outtext work-codeline @ codeline with frame f-codeline. down 1 stream outtext with frame f-codeline. if l-longline eq no and (not (suspended-for-comment or suspended-for-quote or midquote)) then remaining-codeline = indent-spaces + " " + remaining-codeline. if midquote then remaining-codeline = " " + remaining-codeline. ending-suspension = false. if l-longline eq no and length(remaining-codeline) > beautify-line-length then run break-codeline. else do: /* Settle question of quote ending in remaining portion */ if midquote then do: /* 2do: handle sandwiched quotes/doublequotes later */ curpos = index(remaining-codeline,'"',curpos + 1). repeat while curpos > 0: midquote = not midquote. curpos = index(remaining-codeline,'"',curpos + 1). end. end. suspend-for-quote = midquote. end. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE check-for-long-lines w-code-chg PROCEDURE check-for-long-lines : input stream intext from value(working-infile-name) no-echo. work-logical = yes. repeat with frame f-codeline: import stream intext unformatted codeline. run update-processing-display. /*increments line-number*/ if cancel-chosen then leave. if length(codeline) > maximum-line-length then message (working-infile-name + " line number " + string(line-number) + " is too long (" + string(length(codeline)) + " characters)." + crlf + "Do you wish to continue examining this file?") view-as alert-box warning buttons yes-no-cancel update work-logical. if work-logical eq ? then params-ok = false. if not work-logical = yes then leave. end. run housekeeping. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-editor-widget w-code-chg PROCEDURE create-editor-widget : create editor editor-widget assign frame = frame f-editor-widget:handle row=1 column=1 inner-chars = beautify-line-length inner-lines = 18 max-chars = (beautify-line-length * 18). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI w-code-chg _DEFAULT-DISABLE PROCEDURE disable_UI : /* -------------------------------------------------------------------- Purpose: DISABLE the User Interface Parameters: Notes: Here we clean-up the user-interface by deleting dynamic widgets we have created and/or hide frames. This procedure is usually called when we are ready to "clean-up" after running. -------------------------------------------------------------------- */ /* Delete the WINDOW we created */ IF SESSION:DISPLAY-TYPE = "GUI":U THEN DELETE WIDGET w-code-chg. IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI w-code-chg _DEFAULT-ENABLE PROCEDURE enable_UI : /* -------------------------------------------------------------------- Purpose: ENABLE the User Interface Parameters: Notes: Here we display/view/enable the widgets in the user-interface. In addition, OPEN all queries associated with each FRAME and BROWSE. These statements here are based on the "Other Settings" section of the widget Property Sheets. -------------------------------------------------------------------- */ ENABLE r-function input-filespec b-dup-input-filespec output-filespec b-start b-exit WITH FRAME f-filespecs IN WINDOW w-code-chg. {&OPEN-BROWSERS-IN-QUERY-f-filespecs} {&OPEN-BROWSERS-IN-QUERY-f-codeline} {&OPEN-BROWSERS-IN-QUERY-f-editor-widget} ENABLE b-cancel-file b-cancel-all WITH FRAME f-processing IN WINDOW w-code-chg. {&OPEN-BROWSERS-IN-QUERY-f-processing} {&OPEN-BROWSERS-IN-QUERY-f-new-codeline} VIEW w-code-chg. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE establish-next-filenames w-code-chg PROCEDURE establish-next-filenames : cancel-chosen = false. define variable infile-determined as logical no-undo. define variable infilepath as character format "X(127)":U. define variable infileattrib as character format "X(4)":U. infile-determined = false. if not cycling-through-files then do: cycling-through-files = true. if index(input-filespec,"*") > 0 or index(input-filespec,"?") > 0 then input stream infiles from os-dir(infile-directory). else do: if params-ok then run parse-filespec ( input-output input-filespec, output infile-directory, output infile-name-portion, output infile-ext-portion). infile = input-filespec. infile-name = infile. infile-determined = true. single-cycle = true. end. end. else do: /*cycling-through-files*/ if not index(input-filespec,"*") > 0 or index(input-filespec,"?") > 0 then infile = "". end. infile-loop: repeat while not infile-determined: import stream infiles infile infilepath infileattrib no-error. if error-status:error then do: infile = "". params-ok = false. leave infile-loop. end. if infileattrib begins "F" then do: if index(infile,".") = 0 then infile = infile + ".". infile-name-portion = substring(infile ,1 ,(index(infile,".") - 1)). if length(infile) > index(infile,".") then infile-ext-portion = substring(infile ,(index(infile,".") + 1) ,(length(infile) - index(infile,"."))). else infile-ext-portion = "". if not length(infile-name-portion) < length(replace(infile-name-pattern,"*","")) /*name portion is long enough for further analysis*/ then run portion-examine (infile-name-pattern,infile-name-portion). else pattern-matched = false. if not pattern-matched then next infile-loop. if not length(infile-ext-portion) < length(replace(infile-ext-pattern,"*","")) /*ext portion is long enough for further analysis*/ then run portion-examine (infile-ext-pattern,infile-ext-portion). else pattern-matched = false. if not pattern-matched then next infile-loop. else infile-determined = true. infile-name = infile-directory + infile. end. end. if not infile-determined then infile = "". if length(infile) > 0 then do: outfile-name-portion = infile-name-portion. run portion-create (outfile-name-pattern,INPUT-OUTPUT outfile-name-portion). outfile = outfile-name-portion. if length(outfile-ext-pattern) > 0 then do: outfile-ext-portion = infile-ext-portion. run portion-create (outfile-ext-pattern,INPUT-OUTPUT outfile-ext-portion). outfile = outfile-name-portion + "." + outfile-ext-portion. end. outfile-name = outfile-directory + outfile. if r-function = 4 then outfile-name = "". display infile-name outfile-name with frame f-processing. work-logical = true. if not overwrite-outfile and not t-overwrite-duplicates:checked in frame f-filespecs then do: if search(outfile-name) <> ? then message (search(outfile-name) + crlf + " This file already exists." + crlf + crlf + "Replace existing file?") view-as alert-box warning buttons yes-no-cancel title "Output file" update work-logical. if not work-logical then infile = "". if work-logical eq ? then apply "CHOOSE":U to b-cancel-all. end. if work-logical eq yes and outfile-name = infile-name then do: os-copy value(infile-name) "code-chg.inp". if not os-error = 0 then do: message ("Error " + string(os-error) + " during copy to code-chg.inp.") view-as alert-box error. infile = "". end. working-infile-name = "code-chg.inp". end. else working-infile-name = infile-name. if params-ok and length(infile) > 0 then do: changes-made = true. /*(will be true soon)*/ file-number = file-number + 1. line-number = 0. display file-number @ processing-file line-number @ processing-line with frame f-processing. end. end. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE housekeeping w-code-chg PROCEDURE housekeeping : input stream intext close. if r-function < 4 then output stream outtext close. if outfile-name = infile-name then do: if cancel-chosen then do: os-delete value(infile-name). if not os-error = 0 then message ("Error " + string(os-error) + " during deletion of " + infile-name + "(processing cancelled by operator).") view-as alert-box error. os-rename "code-chg.inp" value(infile-name). if not os-error = 0 then message ("Error " + string(os-error) + " during rename of code-chg.inp to " + infile-name + " (processing cancelled by operator).") view-as alert-box error. end. if not cancel-chosen then do: os-delete "code-chg.inp". if not os-error = 0 then message ("Error " + string(os-error) + " during deletion of code-chg.inp.") view-as alert-box error. end. end. infile = "". END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-filespec w-code-chg PROCEDURE parse-filespec : define input-output parameter filespec like work-character. define output parameter dirspec like work-character. define output parameter name-pattern like work-character. define output parameter ext-pattern like work-character. if not index(filespec,slash) > 0 then do: if substring(filespec,2,1) = ':' then do: file-info_file-name = substring(filespec,1,2) + '.'. filespec = substring(filespec,3,length(filespec) - 2). end. else file-info_file-name = ".". filespec = file-info_file-name + slash + filespec. end. work-character = filespec. repeat while index(work-character,slash) > 0: /*strip off file name*/ work-character = substring(work-character ,(index(work-character,slash) + 1) ,(length(work-character) - index(work-character,slash))). end. dirspec = substring(filespec ,1 ,(length(filespec) - (length(work-character)))). if not index(work-character,'.') > 0 then work-character = work-character + '.'. name-pattern = substring(work-character ,1 ,(index(work-character,'.') - 1)). run z-check-pattern-legality (name-pattern,name-max). if length(work-character) > index(work-character,'.') then ext-pattern = substring(work-character ,(index(work-character,'.') + 1) ,(length(work-character) - index(work-character,'.'))). else ext-pattern = "". if length (ext-pattern) > 0 then run z-check-pattern-legality (ext-pattern,ext-max). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE portion-create w-code-chg PROCEDURE portion-create : define input parameter pattern like work-character. define input-output parameter portion like work-character. define variable pattern-position as integer no-undo. define variable portion-position as integer no-undo. define variable portion-core like work-character. define variable pattern-core-length as integer no-undo. work-character = "". pattern-core-length = length(replace(pattern,"*","")). if index(pattern,"*") > 0 then portion-core = substring(portion,1,(name-max - pattern-core-length)). else portion-core = "". pattern-position = 1. portion-position = 1. pattern-loop: repeat while not pattern-position > length(pattern): if substring(pattern,pattern-position,1) = "*" then do: work-character= work-character + portion-core. portion-position = length(portion-core) - 1. end. else do: if substring(pattern,pattern-position,1) = "?" then do: work-character = work-character + substring(portion,portion-position,1). end. else do: work-character = work-character + substring(pattern,pattern-position,1). end. end. pattern-position = pattern-position + 1. portion-position = portion-position + 1. end. portion = work-character. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE portion-examine w-code-chg PROCEDURE portion-examine : define input parameter pattern like work-character. define input parameter portion like work-character. define variable pattern-position as integer no-undo. define variable portion-position as integer no-undo. work-logical = true. pattern-position = 1. portion-position = 1. pattern-loop: repeat while work-logical and not pattern-position > length(pattern): if substring(pattern,pattern-position,1) = "*" then do: if pattern-position = length(pattern) then leave pattern-loop. portion-position = index(portion,substring(pattern,(pattern-position + 1),1),portion-position). if portion-position = 0 then work-logical = false. pattern-position = pattern-position + 1. end. else do: if not substring(pattern,pattern-position,1) = "?" then do: if not substring(pattern,pattern-position,1) = substring(portion,portion-position,1) then work-logical = false. end. end. pattern-position = pattern-position + 1. portion-position = portion-position + 1. if (portion-position > length(portion) and not pattern-position > length(pattern)) then do: work-logical = false. end. end. pattern-matched = work-logical. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE put-new-outtext w-code-chg PROCEDURE put-new-outtext : display stream outtext new-codeline with frame f-new-codeline. down 1 stream outtext with frame f-new-codeline. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE put-outtext w-code-chg PROCEDURE put-outtext : display stream outtext codeline with frame f-codeline. down 1 stream outtext with frame f-codeline. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE replace-or-insert-lines w-code-chg PROCEDURE replace-or-insert-lines : input stream intext from value(working-infile-name) no-echo. output stream outtext to value(outfile-name). if length(skipto-text) > 0 then skipping = true. else skipping = false. work-logical = false. /*no insertion/replacement done yet*/ repeat: import stream intext unformatted codeline no-error. if error-status:error or cancel-chosen then leave. run update-processing-display. /*increments line-number*/ if skipping then do: if (t-case-sensitive-skipto and index(codeline,skipto-text-sensitive) > 0) or (not t-case-sensitive-skipto and index(codeline,skipto-text) > 0) then skipping = false. run put-outtext. end. else do: /*MUST BE else VS. if ... then because skipping is changed in previous block*/ if (t-case-sensitive-begin and index(codeline,begin-text-sensitive) > 0) or (not t-case-sensitive-begin and index(codeline,begin-text) > 0) then work-logical = true. if begin-text = "interlace" then work-logical = true. if work-logical eq yes then do: /*replace/insert underway*/ if r-function = 2 and not t-insert-before then run put-outtext. /*insert lines after*/ if t-input-from-file then do: input stream newtext from value(source-input-file) no-echo. repeat: import stream newtext unformatted new-codeline no-error. if error-status:error or cancel-chosen then leave. run put-new-outtext. end. input stream newtext close. end. if not t-input-from-file then do: new-codeline = new-code. run put-new-outtext. end. if r-function = 1 then do: /*replace lines*/ if t-exact-match-end then do: if not t-case-sensitive-end then repeat while not codeline = end-text: import stream intext unformatted codeline no-error. if error-status:error or cancel-chosen then leave. run update-processing-display. /*increments line-number*/ end. if t-case-sensitive-end then repeat while not codeline = end-text-sensitive: import stream intext unformatted codeline no-error. if error-status:error or cancel-chosen then leave. run update-processing-display. /*increments line-number*/ end. end. else do: /*not t-exact-match-end*/ if not t-case-sensitive-end then repeat while not index(codeline,end-text) > 0: import stream intext unformatted codeline no-error. if error-status:error or cancel-chosen then leave. run update-processing-display. /*increments line-number*/ end. if t-case-sensitive-end then repeat while not index(codeline,end-text-sensitive) > 0: import stream intext unformatted codeline no-error. if error-status:error or cancel-chosen then leave. run update-processing-display. /*increments line-number*/ end. end. end. /*insert lines*/ if r-function = 2 and t-insert-before then run put-outtext. /*insert lines before*/ end. if not work-logical then run put-outtext. /*replace/insert not underway*/ if work-logical eq yes and not t-multiple-occurrences then repeat: import stream intext unformatted codeline no-error. if error-status:error or cancel-chosen then leave. run update-processing-display. /*increments line-number*/ run put-outtext. end. if work-logical eq yes and t-multiple-occurrences then work-logical = false. /*next insertion/replacement not done yet*/ end. end. run housekeeping. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE replace-words w-code-chg PROCEDURE replace-words : input stream intext from value(working-infile-name) no-echo. output stream outtext to value(outfile-name). if length(skipto-text) > 0 then skipping = true. else skipping = false. repeat with frame f-codeline: import stream intext unformatted codeline no-error. if error-status:error or cancel-chosen then leave. run update-processing-display. /*increments line-number*/ if skipping then do: if (t-case-sensitive-skipto and index(codeline,skipto-text-sensitive) > 0) or (not t-case-sensitive-skipto and index(codeline,skipto-text) > 0) then skipping = false. run put-outtext. end. else do: /*MUST BE else VS. if ... then because skipping is changed in previous block*/ if t-case-sensitive-begin then new-codeline = replace(codeline,begin-text-sensitive,new-code). else new-codeline = replace(codeline,begin-text,new-code). run put-new-outtext. end. end. run housekeeping. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-indent-spaces w-code-chg PROCEDURE set-indent-spaces : indent-spaces = fill(" ",indent-level * spaces-per-indent). if partial-indents and partial-indents-active then indent-spaces = indent-spaces + fill(" ",partial-indent-spaces). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-processing-display w-code-chg PROCEDURE update-processing-display : line-number = line-number + 1. if line-number modulo update-interval = 0 then do: display line-number @ processing-line with frame f-processing. process events. end. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE z-check-pattern-legality w-code-chg PROCEDURE z-check-pattern-legality : define input parameter current-pattern like work-character. define input parameter allowed-length as integer. check-parameters: do: if index(current-pattern,"**") > 0 then do: message "Consecutive asterisks not allowed for wildcard pattern." view-as alert-box error. params-ok = false. leave check-parameters. end. current-pattern = replace(current-pattern,"*",""). if length(current-pattern) > allowed-length then do: message "Wildcard pattern contains too many characters." view-as alert-box error. params-ok = false. leave check-parameters. end. end. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE z-missing-message w-code-chg PROCEDURE z-missing-message : message "Some information is missing -- please supply all required information." view-as alert-box information. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &UNDEFINE FRAME-NAME &UNDEFINE WINDOW-NAME