:




        4GL     
()     4GL.       
              ,  
  .            
   .4gl   (,  module1.4gl),        
      .per (,
form2.per).

               
   function  ()    report  (
).             main - 
,         main.      
    .

          4GL .   
   ,        ,
           
  .   (  ;)  
     .        
.

            ,  
    (     4GL).

         ,     
  .    .

        {  },
        #                 -   ,
       -- (  )   .



1.  SQL  2.  4GL       3. 

                
          ""    
                             
 
 
 

( database-name          function )
( table-name          report   )
( column-name                      label    )
( index-name                                       )
( view-name                                        )
( synonim-name                                     )

4.               5.   .
    
                                       window
statement-id -    form
cursor-name  -                   screen-field
                                       screen-record
                                       screen-array

        1.  INFORMIX.

         4GL   () -  ,
    ,  ,            (_),
            (_).    INFORMIX-4GL  
      .    i_Un103Tt  
I_UN103TT -    .

        2.    :

    -    function, main,
report.   ,   .

             
       report, function 
main.       (  , 
        ).

   -     GLOBALS
  .       ,
      .

3.        
   (DECLARE, PREPARE)    .

4.    , , ,  -  
.



                 SQL

.   schoolsql

                 
MAIN
FUNCTION
REPORT

                 
DEFINE
GLOBALS

                
LET
INITIALIZE

                

CALL            EXIT            GOTO
RETURN          FOR             LABLE
CASE            WHILE           RUN
IF              CONTINUE        SLEEP

                 
WHENEVER
DEFER

                  

PREPARE         EXECUTE         FREE

                 ""
DECLARE
OPEN            FOREACH                 PUT
CLOSE            FETCH                 FLUSH

                 

MENU                    OPEN FORM               DISPLAY ARRAY
OPTIONS                 DISPLAY FORM            SCROLL
OPEN WINDOW             CLOSE FORM              INPUT ARRAY
CURRENT WINDOW          DISPLAY                 PROMPT
CLEAR                   INPUT                   ERROR
CLOSE WINDOW            CONSTRUCT               MESSAGE

                 
START  REPORT
OUTPUT TO  REPORT
FINISH REPORT




   4GL   ,   
 .      :

    INTEGER       CHAR(n)        DATE
    SMALLINT      DECIMAL(m,n)   DATETIME _1 TO _2
    REAL          MONEY(m,n)     INTERVAL _1 TO _2
    FLOAT
 _1, _2 -   
{YEAR,MONTH,DAY,HOUR,MINUTE,SECOND,FRACTION(n)}

 FLOAT = DOUBLE PRECISSION

            
RECORD ... END RECORD   LIKE _.*

       ARRAY [i,j,k] OF type,
 type -     ,    RECORD,  
 ARRAY.

     DEFINE:

---------------------------------------------------------------
DEFINE  simw char (200), j,i,k INTEGER, ff FLOAT
#     simw  200 ,
#  i,j,k,  ff -    

DATABASE zawod
DEFINE doljno   RECORD
#   doljno,   4  
                 dolzn CHAR(20),         # 
                 zarplmin  LIKE kadry.zarplata,
                 zarplmax  money(16,2),  # 
                 vakansii int            # 
END RECORD      #     doljno
#       LIKE column_name.
#  zarplmin    ,      
# zarplata  kadry    zawod

DEFINE rrr RECORD LIKE kadry.*
#          
#  LIKE.    rrr,  , -
#                 
#   kadry
---------------------------------------------------------------

        .   
  RECORD.
---------------------------------------------------------------
DEFINE zap RECORD
         a LIKE kadry.tabnom,
         b array[8] OF REAL
       END RECORD,

  massiw ARRAY[2,15] OF RECORD
         kolwo INT,
         tip CHAR(8)
       END RECORD
#    massiw     .   
#      - kolwo  tip
---------------------------------------------------------------

          .  
        ,      
,         ,
   (.)   .
---------------------------------------------------------------
#       :
LET   massiw[1,i+2].kolwo = zap.a + LENGTH(massiw[1,i+2].tip)
---------------------------------------------------------------

         -
  (*). , strkt.*      
 strkt.     THRU: (    )
---------------------------------------------------------------
SELECT kadry.* INTO strkt.* FROM kadry WHERE kadry.tabnom=i+j

SELECT * INTO strukt.b THRU strkt.e FROM kadry
---------------------------------------------------------------

            
GLOBALS       (    ).
    :   , 
 ,   GLOBALS .    -
        .  
      progrglob.4gl:
---------------------------------------------------------------
DATABASE zawod
 GLOBALS
  DEFINE zap RECORD LIKE kadry.*
  DEFINE ext_count INT
   . . .
 END GLOBALS
---------------------------------------------------------------

    ,      -
 ,   
---------------------------------------------------------------
GLOBALS "progrglob"
  . . .
---------------------------------------------------------------



   4GL    () -
  function.        
.    .   -
  -  ,      -
   CALL  RETURNING   
,       .  
  .
---------------------------------------------------------------
FUNCTION stroka(rec)
DEFINE rec RECORD       i int, st char(256)  END RECORD
RETURN  st clipped,""
END FUNCTION
 . . .
MAIN
 . . .
   CALL stroka(rec1.*) RETURNING simw
 . . .
   LET simw=stroka(7,"  ")
#        ,    -
#            .
   MESSAGE simw
 . . .
END MAIN
---------------------------------------------------------------
   :
+--------------------------------------------------------+
|                             |
|                                                        |
|                                                        |
|                                                        |
+--------------------------------------------------------+



      .
---------------------------------------------------------------
GOTO metka
 . . .
LABEL  metka:   . . .
---------------------------------------------------------------

 .
---------------------------------------------------------------
CASE
   WHEN iscreen=1
        current window is w1
   WHEN iscreen=2
        current window is w2
        let iscreen=1
   OTHERWISE
        current window is SCREEN
END CASE

CASE   (a+b)                  #       CASE
       WHEN  1
        message "a=",a
       WHEN  2
        message "b=",b
 END CASE
---------------------------------------------------------------

 .
---------------------------------------------------------------
IF str = "" OR y<0 THEN   exit program
#      
#   END IF.
END IF
---------------------------------------------------------------

 .
---------------------------------------------------------------
  FOR     I= i1 TO 23
  let a[i]=0
     if b[i]=100 then
         EXIT FOR
         END IF
  END FOR
---------------------------------------------------------------

 "".
---------------------------------------------------------------
  WHILE      ff > 3 or nn=""
   PROMPT "  " for n
   let i=n+1
   message "   ",i,", .    ."
   SLEEP  5
   RUN "rm *" WITHOUT WAITING
  END WHILE
---------------------------------------------------------------



 PREPARE  EXECUTE    (
  )     -
  SQL ( 4GL !!!).

            
               SQL
(, ,   : DROP DATABASE buhgalteriq).
         -
      EXECUTE.    -
 ,       -
    status,   
 .
---------------------------------------------------------------
DEFINE stroka char(200)

  MAIN
  . . .
   LABEL METK2:PROMPT "   SQL: " FOR stroka

    WHENEVER ERROR CONTINUE     #      "   
                                #    
                                # "

    PREPARE st1 FROM stroka     #   
                                #  
    EXECUTE st1         #     
    IF status<0 THEN
       ERROR "  ", status, "   "
       GOTO metk2
       END IF

    WHENEVER ERROR STOP         #   
                                # "   
                                #   "
  . . .
  END MAIN
---------------------------------------------------------------
   status    
 4GL (status=0   , status<0  -
 ).  status    
        -
 - .



           (  )
,          -
   ,   SELECT. -
 DECLARE    ,  OPEN
       -
.       .   -
   FETCH     ,  -
  ,        -
.       .

      FOREACH _ ... END
FOREACH        ,     
SELECT.  OPEN     .
---------------------------------------------------------------
  DATABASE zawod
  DEFINE zap RECORD LIKE kadry.*
  DECLARE curs1 CURSOR FOR
     select * from kadry where datarovd>"9/25/1973"

 #    FOREACH        kadry,
 #      datarovd    25 
 #  1973 .
  FOREACH curs1 INTO zap.*      #      -
                                #     zap
  MESSAGE zap.*                 #    zap  
  PROMPT " ?" FOR CHAR c
  END FOREACH                   #    FOREACH
---------------------------------------------------------------

         kadry  
 curs2    z1 (   100 ).
---------------------------------------------------------------
  DATABASE zawod
  DEFINE z1 ARRAY[100] OF RECORD LIKE kadry.*, counter int

  DECLARE curs2 CURSOR FOR SELECT * FROM kadry
        WHERE datarovd<"9/26/1973"
  OPEN curs2

  FOR counter=1 TO 100

  FETCH curs2 INTO z1[counter].*
  #           
  #   z1

  IF status=NOTFOUND THEN
  #     ,  
     EXIT FOR
     END IF

  END FOR

LET   counter=counter-1
MESSAGE "  z1  ",counter, " "
---------------------------------------------------------------
          
status.   FETCH         
    ,    status -
    NOTFOUND,  
100.        status  
FETCH     100,      -
 .

       ,  -
      ceh. ,  ,  
:  "nomerceh>15  and nomerceh<23".   
  ,     SELECT  ,  
  "SELECT * FROM ceh WHERE nomerceh>15 and nomerceh<23",
   ,     
SELECT  .      
.
---------------------------------------------------------------
DEFINE z2 ARRAY[100] OF RECORD LIKE ceh.*,
         counter int, simw char(200)
PROMPT "  SELECT * FROM ceh WHERE " FOR simw
IF LENGTH(simw)=0 THEN
    LET simw="TRUE"
    END IF
LET simw="SELECT * FROM ceh WHERE ", simw CLIPPED
PREPARE st2 FROM simw
  DECLARE cs2 FOR st2

  let counter=1
  FOREACH cs2 INTO z2[counter].*
  LET counter=counter+1
  IF counter>100 THEN
     EXIT FOREACH
     END IF
  END FOREACH
LET   counter=counter-1
MESSAGE "  z2  ",counter, " "
---------------------------------------------------------------



          
,     /  . 
         (-
,  green, revers, underline  ..)    , -
  MESSAGE, PROMPT  ERROR  .

           /
     .

      , ,  -
   ,  ,     (  
),     ,   () -
       DISPLAY (INPUT).   
   .       
         -
 .

   ,    .
---------------------------------------------------------------
OPEN WINDOW wind1 AT 2,30 WITH 10 ROWS, 40 COLUMNS
     ATTRIBUTE(BORDER, REVERSE, MESSAGE LINE FIRST)
        #    wind1

        . . .
OPEN WINDOW wind2 AT 5,15 WITH FORM "schoolp"
ATTRIBUTE(GREEN,PROMPT LINE LAST,
 MESSAGE LINE LAST, FORM LINE FIRST)
        #    wind2

CLEAR  WINDOW wind1
        . . .

CURRENT WINDOW IS wind1
        #    wind1

OPEN FORM form1 from "schoolp"  #   form1
                                #     
                                # schoolp.frm
DISPLAY FORM form1      #   form1   
                        # ..  wind1

---------------------------------------------------------------
               
   :
+-------------------------------------------------------------+
|          +----------------------------------------+     |
|          |   8                       |  |wind1 |
|    +---------------------------------------+      |  |      |
|    |         [  2] [     ]      |      |<-+      |
|    |  . [26         ]              |      |     |
|    |     [ ..         ]     |      |  | wind2|
|    |   [            ]     |      |  |      |
|    |    [$340         ]            |<--------+      |
|    |   [31.12.1952]            |      |         |
|    |                                       |      |         |
|    +---------------------------------------+      |         |
|          |  789                                   |         |
|          +----------------------------------------+         |
|                                                             |
|                                                     |
+-------------------------------------------------------------+




    
---------------------------------------------------------------
let sta_return=podtwervdenie("     ? ")
        ...
function podtwervdenie(stroka)
define stroka char(38) , kod_wozwr  int

  open window podtwervdenie AT 11,10 WITH 4 rows, 39 columns ATTRIBUTE(border)
  display stroka at 4, 2 attribute (reverse)

    menu " "
      command key("Y")     "   Yes   " "  ."
        let kod_wozwr=1
        exit menu
      command key("N",ESC) "   No    " ",  ."
        let kod_wozwr=0
        exit menu
      command key("A")     "  Abort  " ".  ."
        let kod_wozwr=-1
        exit menu
    end menu
  close window podtwervdenie
  return kod_wozwr
end function
---------------------------------------------------------------
       

        +---------------------------------------+
        | :      Yes        No        Abort     |
        |  .                     |
        |                                       |
        |     ?        |
        +---------------------------------------+



  OPTIONS       -
,       .
---------------------------------------------------------------
OPTIONS     MESSAGE LINE 23,
     HELP    FILE "h4gl.txt",   HELP  KEY CONTROL-T,
     DISPLAY ATTRIBUTE(REVERSE, UNDERLINE)
---------------------------------------------------------------



 MESSAGE          message
line.  MESSAGE     , 
 .
---------------------------------------------------------------
let ttmm=CURRENT
message "  ", ttmm

error "  ,  ", n, " "
---------------------------------------------------------------
 ERROR  ,   MESSAGE,     
  REVERSE.    24-  .



 PROMPT    display-list -  
  ,       -
       FOR .
---------------------------------------------------------------
PROMPT "   ?" FOR answer
        ON KEY (CONTROL-U)
           LET  answer=wozderv()
           EXIT PROMPT
END PROMPT
---------------------------------------------------------------
   PROMPT    ,   
  .         
   CTRL-U      
ON  KEY  :      wozderv()  
  PROMPT,   .




 DISPLAY      .
---------------------------------------------------------------
DISPLAY a,b,zap[i].nomerceh TO pole1,fscr.* ATTRIBUTE(BOLD)
---------------------------------------------------------------

          
        ,    
 BY NAME.
---------------------------------------------------------------
DISPLAY BY NAME fio, dolvnostx
---------------------------------------------------------------

  INPUT           
 .     
.           
AFTER, BEFORE, ON KEY.
---------------------------------------------------------------
INPUT  kadr.* FROM fio, dolvnostx, nomerceh
     BEFORE FIELD nomerceh
        message "   5  6"
        sleep 2
        message ""
     AFTER FIELD nomerceh
        IF kadr.nomerceh > 6 then
        MESSAGE "  , "
        NEXT FIELD NOMERCEH
        ENF IF
END INPUT
---------------------------------------------------------------

           4GL       
    :

+--------+                      
| +--------+ |        +---------------+
| |        +------------------->      |
| | | |    DECLARE FOR  |  |
| |        | |    SELECT-|  |
| |        | |      OPEN      |  |
| +--------+ |                 +-+-------------+
|            |              FETCH
|            |              FOREACH
+------------+                   |
                              +--V------------+
+-----------------+   |    |
|                         |   |         |
|+-----------------------+|   +--+------------+
||                       ||   | DISPLAY
||     [               ] ||   | DISPLAY ARRAY
||     [       ] ||      |
||     [         ] <-------+
||     [               ] ||
|+-----------------------+|
+-------------------------+



                  (
   )      
.    ceh     :    
.       wyborceh,
        ceh     .
         
    CR.         
   .
---------------------------------------------------------------
DATABASE zawod
 . . .
let nc= wyborceh()
 . . .
  FUNCTION wyborceh()     #   ,   
  DEFINE counter  int
  DEFINE ceharr ARRAY[25] OF RECORD       #   
         nomerceh  int,      #        
         nameceh char(20)    #                ceh
         END RECORD

#           cehform
    OPEN WINDOW cehwind AT 4 ,6 WITH FORM "cehform"
         ATTRIBUTE(BORDER)

#        ceh
        DECLARE cehcurs CURSOR FOR
          SELECT * FROM ceh ORDER BY nomerceh

#          -
#    ceharr
        LET counter = 0
        FOREACH cehcurs INTO ceharr[counter+1].*
                LET counter = counter + 1
                IF counter >=25 THEN   EXIT FOREACH   END IF
        END FOREACH
#  counter          
#  

        MESSAGE "    CR"

#      cehscreen    cehform
#  counter      ceharr
        call set_count(counter)
        DISPLAY ARRAY ceharr TO cehscreen.*
        ON KEY (CONTROL-M) EXIT DISPLAY
        END DISPLAY
#        CR

#      cehform
CLOSE WINDOW cehwind

let counter=arr_curr()             #  ,
                                   #   CR
RETURN ceharr[counter].nomerceh  # ,
                                 #   CR
END FUNCTION
---------------------------------------------------------------
     :

   +----------------------------+
   |                    |
   |[3  ] [            ]|
   |[4  ] [               ]|
   |[5  ] [             ]|
   |[6  ] [            ]|
   |[   ] [                    ]|
   |    CR   |
   +----------------------------+



             
cehform.per.       .   
   cehform.per     -
   Informix' form4gl.



---------------------------------------------------------------
DATABASE zawod
SCREEN
{
        
[f00] [f001                ]
[f00] [f001                ]
[f00] [f001                ]
[f00] [f001                ]
[f00] [f001                ]
}
TABLES
ceh

ATTRIBUTES
f00 =  ceh.nomerceh;
f001 = ceh.nameceh;

INSTRUCTIONS
screen record cehscreen[5] (ceh.*)
END
---------------------------------------------------------------
         DATABASE     ;   SCREEN
 ,     ;    TABLES
  ,    ATRIBUTES    
, (, ,  )      INSTRUCTIONS  
     cehscreen            
(nomerceh  nameceh)


             , 
  .         
.             
,   .
---------------------------------------------------------------
function kalkulator()           #       
define wyravenie, kalkulator char(64), kolichestwo int
define stroka_kalkulatora char(200)
define beep char(1)
let beep=ascii 7
open   window   kalkulator   at   2,2  with  form  "kalkulator"
attribute(border, form line first)

 input by name wyravenie, kalkulator without defaults
 before field kalkulator

   let stroka_kalkulatora=
   "select  count(*),",wyravenie," from systables"

   whenever error continue
   prepare kalkulqtor_operator from stroka_kalkulatora
   if status<0 then
      display  beep   to kalkulator
      display  " "  to kalkulator
      next field  wyravenie
      end if

   declare kalkulator cursor for kalkulqtor_operator

     foreach kalkulator into kolichestwo, kalkulator
     if status<0 then
        display  beep   to kalkulator
        display  " "  to kalkulator
        next field  wyravenie
        end if
     end foreach
    whenever error stop

  display  kalkulator to kalkulator
  next field wyravenie
  end input

close window kalkulator
return kalkulator

end function
---------------------------------------------------------------

             
   kalkulator.per        
 form4gl.
---------------------------------------------------------------
DATABASE formonly
SCREEN
{
        .               ESC
[wyravenie                                                    ]
[kalkulator                                                   ]
}
ATTRIBUTES
wyravenie =formonly.wyravenie;
kalkulator=formonly.kalkulator;
END
---------------------------------------------------------------

Last-modified: Tue, 25 Nov 1997 07:26:02 GMT
: