1 / 118

Progress Training MFG/PRO

Progress Training MFG/PRO. Dec,14, 2007 SoftSpeed Consultant Ltd. Agenda 日程安排. < 一 > Progress 简介 < 二 > 数据类型和运算符 < 三 > 最简单的 Progress 程序 < 四 > 逻辑运算符和判断语句 < 五 > 循环结构 < 六 > 数组 < 七 > 过程与函数. Agenda 日程安排. < 八 > 编程访问数据库 < 九 > Database 的创建 < 十 > Database 的备份及恢复

gitano
Download Presentation

Progress Training MFG/PRO

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Progress Training MFG/PRO Dec,14, 2007 SoftSpeed Consultant Ltd.

  2. Agenda日程安排 <一> Progress简介 <二> 数据类型和运算符 <三> 最简单的Progress程序 <四> 逻辑运算符和判断语句 <五> 循环结构 <六> 数组 <七> 过程与函数

  3. Agenda日程安排 <八> 编程访问数据库 <九> Database的创建 <十> Database的备份及恢复 <十一> Database的启动文件和常用的实用工具 <十二> Cimload的使用 <十三> 举例讲解标准的报表、维护、查询程序 <十四> Progress的实用编程技巧

  4. <一> 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数据库语言,没有指针没有类也不用搞什么高级接口等

  5. 1.1 Programming in Progress (Accessing A Database With Progress) Application Code Data Dictionary Procedure Editor User Interface Builder User Interface Add ACCESS DATABASE Order Entry Del Update

  6. 1.1 Programming in Progress (Progress Model For Data Access) Memory User DATABASE Record Buffer Screen Buffer Screen Printer File

  7. 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.

  8. 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.

  9. 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

  10. 1.2 Progress File And Procedure (Internal And External Procedures)

  11. 1.2 Progress File And Procedure (Include Files) .I File MyProg.p MyCode.i DO: …. Display record. End. DO: …. Display record. End.

  12. 1.3 Starting a Progress Session (Progress UI Environments) Progress.ini (Progress.svg) Define the default Progress Environment.when You startup Progress. [ Fonts ] [Startup] [Propath]

  13. 1.3 Starting a Progress Session (Progress Environment Variables)

  14. 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

  15. 1.3 Starting a Progress Session (Database Connections) Will Be Discuss In Progress Administration Training Guide

  16. 1.4 Using The Procedure Editor (How to Use Procedure Editor) Show Buffer List Multiple Procedure Windows Checking Syntax

  17. 1.4 Using The Procedure Editor(How to Use Compile Procedure) • Using the Compile statment Compile Procedure-name Save into Directory • Using the Application compiler tool • Using Application Tool MFG-UTIL

  18. <二> 数据类型以及运算符 2.1 Progress的数据类型 2.2 常量与变量 2.3 运算符 2.4 表达式 2.5 一些特殊符号

  19. 2.1 Progress的数据类型 CHARACTER: X(8) DATE : 99/99/99 DECIMAL: ->>,>>9.99 HANDLE: >>>>>>9 INTEGER: ->,>>>,>>9 LOGICAL: yes/no

  20. 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 变量的初始值

  21. 2.2 常量与变量 第二行:def和var都是简写,def是define的简写,var是variable的简写;PROGRESS支持语法简写,但是初学者最好先写全,后面有经验了再简写。like和as的不同点是:as后面直接说明变量类型,而like后面跟另外一个变量或者字段。第三行:extent 5 ,表示该变量是数组变量。  第四行:format ">>>9"  变量格式指定变量的格式一个最大的好处就是预留宽度,这个对变量的输入或者报表的输出都很有用的。比如年份的宽度一定是4位的,那么你就可以指定格式 format "9999"。 PROGRESS程序每行结束必须有个“.”号!!!

  22. 2.2 常量与变量 Define variable Variable Buffer Assign variable Screen Buffer Display variable

  23. 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

  24. 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.

  25. 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.

  26. 2.3 运算符 & 2.4表达式 + - *  / ,就是 加 减 乘  除了!比如:ttl_amoount = ttl_ammount + dtl_amount.x_a = x_b / x_c.str_ttl = "I'm" + "sure!".dt01 = today - 1.dt01 = 3/22/2005. /* 日期 */当然,日期和字符串不能做乘法或者除法!

  27. 2.5 一些特殊符号

  28. <三> 最简单的Progress程序 3.1 Progress的三种程序结构 3.2 Progress中的输入和输出 3.3 使用代码连接或中断数据库以及 在数据库中怎样使用os的命令

  29. 3.1 Progress的三种程序结构 • 顺序结构 • 2. 分支结构 • If … then … else • 3. 循环结构 • Repeat … end • Do … end

  30. 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.

  31. 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.

  32. 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.

  33. 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.

  34. 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

  35. 3.3 使用代码连接或中断数据库以及在数据库中怎样使用os的命令 Syntax: Os-statement [SILENT ] os-specific-command Sample: OS-Create-DIR c:\temp\test. DOS Silent Copy c:\*.txt c:\temp\test\*.txt. Display Opsys.

  36. <四> 逻辑运算符和判断语句 4.1 逻辑运算符 4.2 关系运算符 4.3 条件语句及Case语句 4.4 程序举例

  37. 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

  38. 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.

  39. 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 支持嵌套。

  40. 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.

  41. 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.

  42. <五> 循环结构 5.1 Do…End语句 5.2 Repeat…End语句及Leave语句 5.3 程序举例

  43. 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.

  44. 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".

  45. 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 */

  46. 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”.

  47. <六> 数组 6.1 一维数组的定义和引用 6.2 数字数组 6.3 字符数组 6.4 程序举例(略)

  48. 6.1 一维数组的定义和引用 Syntax: DEFINE VARIABLE variable {AS datatype} [EXTENT n] [INITIAL {constant|{[constant[,constant]...]}}] [LABEL string[, string]...] Sample: Define variable v_month as integer extent 12 init [1,2,3,4,5,6,7,8,9,10,11,12] label [“一”,“二”,”三”,”四”,”五”,”六”,”七”,”八”,”九”,”十”,”十一”,”十二”]

  49. 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

  50. 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

More Related