Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
<一> Progress 简介 1.1 Programming in Progress 1.2 Progress Files and Procedures 1.3 Starting A Progress Session 1.4 Using The Procedure Editor PROGRESS属于4GL数据库语言,没有指针没有类也不用搞什么高级接口等
1.1 Programming in Progress (Progress Statements) Sample: define variable code like cm_addr. for each cm_mstr no-lock: display cm_addr . end. Prompt-for "Cust:" code with No-labels. find first cm_mstr where cm_addr = Input code. display cm_addr . for each so_mstr where so_cust = cm_addr: display so_nbr with 2 Columns. for each sod_det where sod_nbr = so_nbr no-lock: display sod_line sod_part sod_qty_ord. end. end.
1.2 Progress File And Procedure (Database File Types) .db Database FileMain Database (Data) Store the Table structure / Index / Data / Trigger ..... .lg Event log FileLog File for Datebase Startup/Shutdown database Will be Recorded The format is TXT. .bi Before-ImageBuffer For Database Like Buffer to Store the Data Before Write to Database. If System fails, It can be use to Restore the Database. .lk lock FileLock File For Database Signifies that the database is use. You must delete the Lock file , if system fail.
1.2 Progress File And Procedure (Progress Program File Types) .P Procedure File Main Procedure You Can Directly Run In MFG/PRO Sub-Procedure Call By Main Procedure .I Include file A file that is included in procedure during compilation .W User interface Program Program file containing User Interface elements .eg. Dialog Box .. .R Compiled File Can Directly Run in MFG/PRO All .P file can create corresponding .R file
1.3 Starting a Progress Session (Progress Propath) Propath is a list of directories Progress uses to find Procedures you in a session. How To set Propath ? 1. Edit Configure file Progress.ini 2. Using the Propath Editor in PRO*Tools 3. In Progress Editor , Assign to Propath
2.2 常量与变量 变量必须在第一次被使用之前定义,可以定义在程序的任何地方!但是通常为了增加程序的可读性,变量定义都放在程序的开始处!以下是变量定义的几个实例: define variable str01 as char label "DemoString" initial "hello". def var str02 like str01. def var dt01 as date extent 5. def var inte01 as inte format ">>>9". 说明,第一行:str01 是变量名, 变量名不要与系统关键字重复,字符或者下划线开头,比如strModel,_Model ;char 表示变量类型,本例指字符型变量,其它类似的比如integer,date,logical等 ;label 就是后续程序中对变量的描述,比如需要用户输入这个变量值时,系统提示“DemoString" ;initial 变量的初始值
2.2 常量与变量 As Data type format format Syntax : Define variable var-name init value Label “ABC“. Like Field Sample: Define variable Var1 as decimal decimals 1 label "Qty". Define variable Var2 as Character format "x(5)". Define variable Var3 as integer Extent 3 . Define variable Var4 as Character Format "Q 9" Extent 4 initial [1,2,3,4]. Define variable Var5 as logical Format "Detail/Summary" initial "Detail". Data Type
2.2 常量与变量 Syntax : Assign Variable = Value Display Variable . Sample: Define variable Var1 as decimal decimals 1 label "Qty". Define variable Var2 as Character format "x(5)". Assign Var1 = 1 var2 = “ABC”. Display Var1 Space(10) skip(1) Var2.
2.2 常量与变量 Syntax : SET ** Assign it to Record Buffer. Record Buffer Screen Buffer Prompt-for ** Save it to screen buffer ONLY. Sample: Define variable name as character format "x(20)" label "Enter You Name". Define variable greeting as Character format "x(27)". Set name. Assign greeting = "Hello," + name + "!". /* Prompt-for name. Assign greeting = "Hello," + Input name + "!". */ Display greeting.
3.1 Progress的三种程序结构 • 顺序结构 • 2. 分支结构 • If … then … else • 3. 循环结构 • Repeat … end • Do … end
3.2 Progress的输入和输出 • Every procedure automatically gets one input stream and one output stream. • Input • Prompt-for, assign, update, set • Sample: • Repeat : • Prompt-for customer.cust_num. • find customer using cust_num. • display • name state credit_limit. • End.
3.2 Progress的输入和输出 Sample: For each customer : update name state credit_limt. end. find first customer where name = “AA” no-lock no-error. if not availabel customer then do : create customer. assign name = “AA” state = “” credit_limit = “”. end.
3.2 Progress的输入和输出 2. Output Display, put, output Sample: DEFINE VARIABLE f AS CHARACTER NO-UNDO. DEFINE VARIABLE i AS INTEGER NO-UNDO. DEFINE VARIABLE j AS INTEGER NO-UNDO. i = 0. j = 0. f = "out.txt". OS-DELETE VALUE(f). OUTPUT TO VALUE(f) APPEND.
3.2 Progress的输入和输出 FOR EACH gltr_hist: i = i + 1. IF i = 50001 THEN DO: i = 1. OUTPUT CLOSE. j = j + 1. f = "out_" + STRING( j) + ".txt". OS-DELETE VALUE(f). OUTPUT TO VALUE(f) APPEND. END. EXPORT DELIMITER "~011" gltr_hist. END. OUTPUT CLOSE.
3.3 使用代码连接或中断数据库以及在数据库中怎样使用os的命令 Syntax: Connect Physical Database–ld logical Name No Error Disconnect logical Name No Error DB Type Logical Name Physical Name Sample: Connect E:\Database\mfgtrain.db -ld "testDB". Display "Connect To" LDBName(1) PDBName(1) format "x(40)" DBType(1) skip with width 100 . Connect E:\Database\mfgtrain.db -ld "TrainDB". Display "Connect To" LDBName(2) PDBName(2) format "x(40)" DBType(2) skip with width 100 . Display "Number of database connections:" Num-DBS. Disconnect testDB. Disconnect trainDB. DB Counter
4.1 逻辑运算符 & 4.2 关系运算符 Operators: + - * / Logical Operators: Not And Or Comparison Operators: = <> < > <= >= Begins Matches Precedence in Logical Operations: 1) () 2) Not 3) And 4) Or
4.1 逻辑运算符 & 4.2 关系运算符 Sample: Define var x as integer init 5. For each so_mstr: find first sod_det where sod_nbr = so_nbr no-lock no-error. if (not availabel sod_det and x <> 5) then do : create so. assign sod_nbr = “”. end.
4.3 条件语句及Case语句 判断最简单了,就是一个if 条件 then ... else ...,比如:if str01 = "cpu" then disp "CPU" else disp "Not CPU".当然,这个”条件“可能有很复杂的组合。如果,涉及到的动作比较多,那么做法是用do: ... end.,比如if str01 = "cpu" then do: str01 = "my cpu". disp "CPU".end.else do: str01 = "my memory". disp "Not CPU".end.if 支持嵌套。
4.3 条件语句及Case语句 Syntax: IF Condition THEN expression1 ELSE expression2. IF Condition THEN DO: Statement1. Statement2. END. ELSE DO: Statement3. Statement4. END. Sample: Connect E:\database\mfgtrain.db -ld mfgtrain. if connected("mfgtrain") Then do: display "You Are Connected to :" DBName(1). display skip(1) LDBName(1) " Is a " DBTYPE(1) “DB". end. else do: Message "Cannot Connect to the database". Pause. Quit. end.
4.3 条件语句及Case语句 Syntax: Case expression: When Value1 then Statement1. When Value2 then Statement2. When Value3 then Statement3. Otherwise statement4. End Case Sample: Define variable OS as character. Assign OS= opsys. Case OS: When "UNIX" Then UNIX ls. When "MSDOS" OR When "OS2" Then OS-Command Dir. When "VMS" Then VMS Directory. When "BTOS" Then BTOS "[Sys]<sys>files.run" files. When "WIN32" Then display "Windows OS". Otherwise Display OPSYS "is An Unsupported OS". End Case.
5.1 Do: … End 语句 Syntax: DO [Var = expression1 To expression2 [BY n]]: statement. END. Sample: Define variable i as integer. Do i = 1 to 10 by 2: Display i. Pause. End.
5.2 Repeat … End 语句及Leave语句 Syntax: Repeat [Var = expression1 To expression2 [BY n]]: statement. END. Sample: Define variable i as integer. Define variable count as integer format "99" initial 0. Repeat i = 1 TO Num-entries(propath): Display ENTRY(i, propath) format "x(45)". Count = count + 1. End. Message "There are" count "items in the list".
5.2 Repeat … End 语句及Leave语句 Syntax: Repeat [Var = expression1 To expression2 [BY n]]: statement. END. Sample: Define variable i as integer. Define variable count as integer format "99" initial 0. Repeat i = 1 TO Num-entries(propath): Display ENTRY(i, propath) format "x(45)". Count = count + 1. End. Message "There are" count "items in the list". /* Do I = 1 to xxx with down */
5.2 Repeat … End 语句及Leave语句 Syntax: Loop: Do / Repeat [While expression]: statements. If xxx Then Leave loop. Statements. End. Sample: Define variable count as integer format "99" initial 0. AA: Repeat: count = count + 1. if count = 13 then do: pause. display "count = " count. leave AA. end. end. Display “Process OK”.
6.2数字数组 Syntax: DEFINE VARIABLE int_value AS INTEGER EXTENT 3 INITIAL [1, 2, 3]. Sample: DEFINE VARIABLE int_value AS INTEGER EXTENT 3 INITIAL [1, 2, 3]. DEFINE VARIABLE i AS INTEGER. DEFINE VARIABLE tot AS INTEGER LABEL "The total is". DO i = 1 TO EXTENT(int_value): tot = tot + int_value[i]. END. DISPLAY tot. 6
6.3 字符数组 Syntax: DEFINE VARIABLE int_value AS CHAR EXTENT 3 INITIAL [“1”,”2”, “3”]. Sample: DEFINE VARIABLE int_value AS CHAR EXTENT 3 INITIAL [“1”,”2”, “3”]. DEFINE VARIABLE i AS INTEGER. DEFINE VARIABLE tot AS INTEGER LABEL "The total is". DO i = 1 TO EXTENT(int_value): tot = tot + int_value[i]. END. DISPLAY tot. 123
Connexion au compte
Connectez-vous pour publier votre contenu sur SlideServe.