字符串串联功能在Progress 4GL中?

时间:2015-05-17 21:54:24

标签: string-concatenation progress-4gl

我在C#,string.Join()中遇到了一个函数,它对字符串连接非常有帮助。 我想知道是否有可能在Progress 4GL中执行相同的功能? 典型的C#示例是,

String result = “ ”;

result = string.Join(",", this.grpBox1.Controls.OfType<CheckBox>()
                                    .Where(x => x.Checked)
                                    .Select(c => c.Text));
MessageBox.Show(result);

我不是想将C#转换为Progress,但如果我能在Progress中实现相同的功能,那将非常有用。

2 个答案:

答案 0 :(得分:0)

如果你真的想要你的功能,你可以将它包装起来并将其声明为外部,你可以重新链接_progres以包含你自己的c libs。曾经被称为HLC(probuild),但现在它是一组脚本,直接位于Progress安装目录(DLC)下的新目录名oebuild下。 hlc和make目录位于oebuild目录下。

有关构建过程的说明,请参阅DLC目录下oebuild目录中的README文件。概率。用锤子敲碎螺母,你必须明白你不为胆小鬼做些什么。但如果你有用c写的东西,你想打电话就可以做到。概率。最好坚持4gl最接近的事情进展到阵列是不是很多人爆发到临时表的范围。 tt中的行更容易处理和迭代,所以它的思维设置和#34;切换一下。

也可以在hlc目录中的hlprodsp.c文件中找到重要注释,该目录是oebuild的子目录。

答案 1 :(得分:-1)

据我所知,这项工作并没有内置任何东西。但是,如果我理解正确,当您发出该命令时,您会得到一个给定对象类型的列表(在您的示例中,复选框)作为CSV。 我构建了类似于它的东西,作为你想要实现的任何东西的开始。它可能远非完美,但它适用于我。它是一个包含各种窗口小部件类型的窗口,您可以从组合中选择要搜索和生成的类型,它将在最后显示两个CSV变量的值:一个具有与该类型匹配的窗口小部件名称,以及一个具有相应的值。

这就是:

&Scoped-define WINDOW-NAME C-Win
/*------------------------------------------------------------------------

  File: 

  Description: 

  Input Parameters:
      <none>

  Output Parameters:
      <none>

  Author: 

  Created: 

------------------------------------------------------------------------*/
/*          This .W file was created with the Progress AppBuilder.      */
/*----------------------------------------------------------------------*/

/* Create an unnamed pool to store all the widgets created 
     by this procedure. This is a good default which assures
     that this procedure's triggers and internal procedures 
     will execute in this procedure's storage, and that proper
     cleanup will occur on deletion of the procedure. */

CREATE WIDGET-POOL.

/* ***************************  Definitions  ************************** */

/* Parameters Definitions ---                                           */

/* Local Variable Definitions ---                                       */

DEFINE VARIABLE cWidgetLst AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cValueLst  AS CHARACTER   NO-UNDO.



/* ********************  Preprocessor Definitions  ******************** */

&Scoped-define PROCEDURE-TYPE Window
&Scoped-define DB-AWARE no

/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME DEFAULT-FRAME

/* Standard List Definitions                                            */
&Scoped-Define ENABLED-OBJECTS COMBO-BOX-1 BUTTON-1 SLIDER-1 SELECT-1 ~
RADIO-SET-1 TOGGLE-1 FILL-IN-2 COMBO-BOX-3 
&Scoped-Define DISPLAYED-OBJECTS COMBO-BOX-1 SLIDER-1 SELECT-1 RADIO-SET-1 ~
TOGGLE-1 FILL-IN-2 COMBO-BOX-3 

/* Custom List Definitions                                              */
/* List-1,List-2,List-3,List-4,List-5,List-6                            */

/* ***********************  Control Definitions  ********************** */

/* Define the widget handle for the window                              */
DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.

/* Definitions of the field level widgets                               */
DEFINE BUTTON BUTTON-1 
     LABEL "Generate" 
     SIZE 15 BY 1.14.

DEFINE VARIABLE COMBO-BOX-1 AS CHARACTER FORMAT "X(256)":U 
     VIEW-AS COMBO-BOX INNER-LINES 5
     LIST-ITEMS "Fill-in","Radio-set","Toggle-box","Selection-List","slider","combo-box" 
     DROP-DOWN-LIST
     SIZE 16 BY 1 NO-UNDO.

DEFINE VARIABLE COMBO-BOX-3 AS CHARACTER FORMAT "X(256)":U 
     LABEL "Combo 3" 
     VIEW-AS COMBO-BOX INNER-LINES 5
     LIST-ITEMS "Large","Tall","Venti" 
     DROP-DOWN-LIST
     SIZE 16 BY 1 NO-UNDO.

DEFINE VARIABLE FILL-IN-2 AS CHARACTER FORMAT "X(256)":U 
     LABEL "Fill 2" 
     VIEW-AS FILL-IN 
     SIZE 14 BY 1 NO-UNDO.

DEFINE VARIABLE RADIO-SET-1 AS INTEGER 
     VIEW-AS RADIO-SET VERTICAL
     RADIO-BUTTONS 
          "Item 1", 1,
"Item 2", 2,
"Item 3", 3
     SIZE 12 BY 3 NO-UNDO.

DEFINE VARIABLE SELECT-1 AS CHARACTER 
     VIEW-AS SELECTION-LIST SINGLE SCROLLBAR-VERTICAL 
     LIST-ITEMS "First","Second","Third" 
     SIZE 23 BY 2 NO-UNDO.

DEFINE VARIABLE SLIDER-1 AS INTEGER INITIAL 0 
     VIEW-AS SLIDER MIN-VALUE 0 MAX-VALUE 100 HORIZONTAL 
     TIC-MARKS NONE 
     SIZE 31 BY 2.38 NO-UNDO.

DEFINE VARIABLE TOGGLE-1 AS LOGICAL INITIAL no 
     LABEL "Toggle 1" 
     VIEW-AS TOGGLE-BOX
     SIZE 13.4 BY .81 NO-UNDO.

DEFINE VARIABLE COMBO-BOX-2 AS CHARACTER FORMAT "X(256)":U 
     LABEL "Combo 2" 
     VIEW-AS COMBO-BOX INNER-LINES 5
     LIST-ITEMS "Item 1" 
     DROP-DOWN-LIST
     SIZE 16 BY 1 NO-UNDO.

DEFINE VARIABLE FILL-IN-3 AS CHARACTER FORMAT "X(256)":U 
     LABEL "Fill 3" 
     VIEW-AS FILL-IN 
     SIZE 14 BY 1 NO-UNDO.

DEFINE VARIABLE RADIO-SET-2 AS INTEGER 
     VIEW-AS RADIO-SET VERTICAL
     RADIO-BUTTONS 
          "Item 1", 1,
"Item 2", 2,
"Item 3", 3
     SIZE 12 BY 3 NO-UNDO.

DEFINE VARIABLE SLIDER-2 AS INTEGER INITIAL 0 
     VIEW-AS SLIDER MIN-VALUE 0 MAX-VALUE 100 HORIZONTAL 
     TIC-MARKS NONE 
     SIZE 17 BY 2.14 NO-UNDO.

DEFINE VARIABLE TOGGLE-2 AS LOGICAL INITIAL no 
     LABEL "Toggle 2" 
     VIEW-AS TOGGLE-BOX
     SIZE 13.4 BY .81 NO-UNDO.


/* ************************  Frame Definitions  *********************** */

DEFINE FRAME DEFAULT-FRAME
     COMBO-BOX-1 AT ROW 1.95 COL 13 COLON-ALIGNED NO-LABEL WIDGET-ID 14
     BUTTON-1 AT ROW 1.95 COL 32 WIDGET-ID 2
     SLIDER-1 AT ROW 3.62 COL 42 NO-LABEL WIDGET-ID 18
     SELECT-1 AT ROW 3.86 COL 10 NO-LABEL WIDGET-ID 16
     RADIO-SET-1 AT ROW 6.24 COL 10 NO-LABEL WIDGET-ID 6
     TOGGLE-1 AT ROW 6.24 COL 30 WIDGET-ID 10
     FILL-IN-2 AT ROW 7.19 COL 28 COLON-ALIGNED WIDGET-ID 12
     COMBO-BOX-3 AT ROW 7.29 COL 56 COLON-ALIGNED WIDGET-ID 20
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
         SIDE-LABELS NO-UNDERLINE THREE-D 
         AT COL 1 ROW 1
         SIZE 80 BY 16 WIDGET-ID 100.

DEFINE FRAME FRAME-A
     TOGGLE-2 AT ROW 1.24 COL 51 WIDGET-ID 6
     RADIO-SET-2 AT ROW 1.48 COL 3 NO-LABEL WIDGET-ID 2
     FILL-IN-3 AT ROW 1.95 COL 25 COLON-ALIGNED WIDGET-ID 8
     SLIDER-2 AT ROW 3.14 COL 46 NO-LABEL WIDGET-ID 12
     COMBO-BOX-2 AT ROW 3.38 COL 24 COLON-ALIGNED WIDGET-ID 10
    WITH 1 DOWN KEEP-TAB-ORDER OVERLAY 
         SIDE-LABELS NO-UNDERLINE THREE-D 
         AT COL 5 ROW 10.29
         SIZE 72 BY 5.71
         TITLE "Frame A" WIDGET-ID 200.


/* *********************** Procedure Settings ************************ */

/* Settings for THIS-PROCEDURE
   Type: Window
   Allow: Basic,Browse,DB-Fields,Window,Query
   Other Settings: COMPILE
 */

/* *************************  Create Window  ************************** */

IF SESSION:DISPLAY-TYPE = "GUI":U THEN
  CREATE WINDOW C-Win ASSIGN
         HIDDEN             = YES
         TITLE              = "<insert window title>"
         HEIGHT             = 16
         WIDTH              = 80
         MAX-HEIGHT         = 16
         MAX-WIDTH          = 80
         VIRTUAL-HEIGHT     = 16
         VIRTUAL-WIDTH      = 80
         RESIZE             = yes
         SCROLL-BARS        = no
         STATUS-AREA        = no
         BGCOLOR            = ?
         FGCOLOR            = ?
         KEEP-FRAME-Z-ORDER = yes
         THREE-D            = yes
         MESSAGE-AREA       = no
         SENSITIVE          = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION                                                */



/* ***********  Runtime Attributes and AppBuilder Settings  *********** */

/* SETTINGS FOR WINDOW C-Win
  VISIBLE,,RUN-PERSISTENT                                               */
/* REPARENT FRAME */
ASSIGN FRAME FRAME-A:FRAME = FRAME DEFAULT-FRAME:HANDLE.

/* SETTINGS FOR FRAME DEFAULT-FRAME
   FRAME-NAME                                                           */

DEFINE VARIABLE XXTABVALXX AS LOGICAL NO-UNDO.

ASSIGN XXTABVALXX = FRAME FRAME-A:MOVE-AFTER-TAB-ITEM (COMBO-BOX-3:HANDLE IN FRAME DEFAULT-FRAME)
/* END-ASSIGN-TABS */.

/* SETTINGS FOR FRAME FRAME-A
                                                                        */
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
THEN C-Win:HIDDEN = no.






/* ************************  Control Triggers  ************************ */

&Scoped-define SELF-NAME C-Win
ON END-ERROR OF C-Win /* <insert window title> */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
  /* This case occurs when the user presses the "Esc" key.
     In a persistently run window, just ignore this.  If we did not, the
     application would exit. */
  IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.


ON WINDOW-CLOSE OF C-Win /* <insert window title> */
DO:
  /* This event will close the window and terminate the procedure.  */
  APPLY "CLOSE":U TO THIS-PROCEDURE.
  RETURN NO-APPLY.
END.


&Scoped-define SELF-NAME BUTTON-1
ON CHOOSE OF BUTTON-1 IN FRAME DEFAULT-FRAME /* Generate */
DO:
  assign cWidgetLst = ''
         cValueLst  = ''.
  run downTheRabbitHole ( input {&window-name}:handle).

MESSAGE cWidgetLst SKIP cValueLst
    VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.


&UNDEFINE SELF-NAME



/* ***************************  Main Block  *************************** */

/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames.        */
ASSIGN CURRENT-WINDOW                = {&WINDOW-NAME} 
       THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.

/* The CLOSE event can be used from inside or outside the procedure to  */
/* terminate it.                                                        */
ON CLOSE OF THIS-PROCEDURE 
   RUN disable_UI.

/* Best default for GUI applications is...                              */
PAUSE 0 BEFORE-HIDE.

/* Now enable the interface and wait for the exit condition.            */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire.    */
MAIN-BLOCK:
DO ON ERROR   UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
  RUN enable_UI.
  IF NOT THIS-PROCEDURE:PERSISTENT THEN
    WAIT-FOR CLOSE OF THIS-PROCEDURE.
END.


/* **********************  Internal Procedures  *********************** */

PROCEDURE buildCSV :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
DEFINE INPUT-OUTPUT PARAMETER iopcList AS CHARACTER   NO-UNDO.
DEFINE INPUT        PARAMETER ipcValue AS CHARACTER   NO-UNDO.

if ipcValue = ? then
   assign ipcValue = '?'.
if ipcValue = '' then
   assign ipcValue = ' '.
assign iopcList = iopcList + (if iopcList = '' then '' else ',') + ipcValue.
END PROCEDURE.

PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
  Purpose:     DISABLE the User Interface
  Parameters:  <none>
  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 AND VALID-HANDLE(C-Win)
  THEN DELETE WIDGET C-Win.
  IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.

PROCEDURE downTheRabbitHole :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
DEFINE INPUT  PARAMETER iphWidget    AS HANDLE      NO-UNDO.

DEFINE VARIABLE hHandle AS HANDLE      NO-UNDO.

assign hHandle = iphWidget:first-child.


do while valid-handle(hHandle):
   if can-query(hHandle,"type") and hHandle:type = combo-box-1:screen-value in frame {&frame-name} then do:
      /* something something something dark side... */
      if can-query(hHandle,"name") then run buildCSV(input-output cWidgetLst,hHandle:name).
      if can-query(hHandle,"screen-value") then run buildCSV(input-output cValueLst,hHandle:screen-value).
   end.
   if hHandle:type = "FIELD-GROUP" or hHandle:type = "FRAME" then
      run downTheRabbitHole(input hHandle:first-child).
   assign hHandle = hHandle:next-sibling.
end.

END PROCEDURE.

PROCEDURE enable_UI :
/*------------------------------------------------------------------------------
  Purpose:     ENABLE the User Interface
  Parameters:  <none>
  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.
------------------------------------------------------------------------------*/
  DISPLAY COMBO-BOX-1 SLIDER-1 SELECT-1 RADIO-SET-1 TOGGLE-1 FILL-IN-2 
          COMBO-BOX-3 
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  ENABLE COMBO-BOX-1 BUTTON-1 SLIDER-1 SELECT-1 RADIO-SET-1 TOGGLE-1 FILL-IN-2 
         COMBO-BOX-3 
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  {&OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME}
  DISPLAY TOGGLE-2 RADIO-SET-2 FILL-IN-3 SLIDER-2 COMBO-BOX-2 
      WITH FRAME FRAME-A IN WINDOW C-Win.
  ENABLE TOGGLE-2 RADIO-SET-2 FILL-IN-3 SLIDER-2 COMBO-BOX-2 
      WITH FRAME FRAME-A IN WINDOW C-Win.
  {&OPEN-BROWSERS-IN-QUERY-FRAME-A}
  VIEW C-Win.
END PROCEDURE.