118
Add Month 2000 Progress Training MFG/PRO Dec,14, 2007 SoftSpeed Consultant Ltd.

Progress Training MFG/PRO

  • Upload
    gitano

  • View
    81

  • Download
    1

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Progress Training         MFG/PRO

Add Month 2000

Progress Training MFG/PROProgress Training MFG/PRO

Dec,14, 2007SoftSpeed Consultant Ltd.

Dec,14, 2007SoftSpeed Consultant Ltd.

Page 2: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 3: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 4: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 5: Progress Training         MFG/PRO

www.softspeed.com.hk

1.1 Programming in Progress 1.1 Programming in Progress (Accessing A Database With Progress)(Accessing A Database With Progress)

ACCESS DATABASE

Application

Code

Order Entry

User Interface

Data Dictionary

Procedure Editor

User Interface Builder

Update

Add

Del

Page 6: Progress Training         MFG/PRO

www.softspeed.com.hk

1.1 Programming in Progress 1.1 Programming in Progress (Progress Model For Data Access)(Progress Model For Data Access)

DATABASE

RecordBuffer

Screen Buffer

Memory User

Screen

Printer

File

Page 7: Progress Training         MFG/PRO

www.softspeed.com.hk

1.1 Programming in Progress 1.1 Programming in Progress (Progress Statements) (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.

Page 8: Progress Training         MFG/PRO

www.softspeed.com.hk

1.2 Progress File And Procedure 1.2 Progress File And Procedure (Database File Types) (Database File Types)

.db Database File Main Database (Data)

.lg Event log File Log File for Datebase

.bi Before-Image Buffer For Database

.lk lock File Lock File For Database

Startup/Shutdown database Will be Recorded

Store the Table structure / Index / Data / Trigger .....

The format is TXT.

If System fails, It can be use to Restore the Database.

Like Buffer to Store the Data Before Write to Database.

Signifies that the database is use.

You must delete the Lock file , if system fail.

Page 9: Progress Training         MFG/PRO

www.softspeed.com.hk

1.2 Progress File And Procedure 1.2 Progress File And Procedure (Progress Program File Types) (Progress Program File Types)

.P Procedure File

.I Include file

.W User interface Program

.R Compiled File

A file that is included in procedure during compilation

Main Procedure You Can Directly Run In MFG/PRO

Program file containing User Interface elements .eg. Dialog Box ..

Can Directly Run in MFG/PRO

All .P file can create corresponding .R file

Sub-Procedure Call By Main Procedure

Page 10: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Comparing Internal Procedure

External

Procedure

Re-use Use By Main

Program Only

Use by All

Program

Code-length Relatively

short

Any length

Performance Allocate

Memory

Needs to be

Loaded

Page 11: Progress Training         MFG/PRO

www.softspeed.com.hk

1.2 Progress File And Procedure 1.2 Progress File And Procedure (Include Files) .I File (Include Files) .I File

DO: …. Display record.End.

DO: …. Display record.End.

MyProg.p

MyCode.i

Page 12: Progress Training         MFG/PRO

www.softspeed.com.hk

1.3 Starting a Progress Session1.3 Starting a Progress Session (Progress UI Environments) (Progress UI Environments)

UI Environment Environment File

MS Windows PROGRESS.INI( \Dlc\Bin )

Character PROTERMCAP

Progress.ini (Progress.svg)Define the default Progress Environment.whenYou startup Progress.

[ Fonts ] [Startup] [Propath]

Page 13: Progress Training         MFG/PRO

www.softspeed.com.hk

1.3 Starting a Progress Session1.3 Starting a Progress Session (Progress Environment Variables) (Progress Environment Variables)

Variable Points to Path Name of ….

DLC Progress Install Directory

Procfg Configuration information Directory (C:/Dlc)

Promsgs Error Message File (C:\Dlc)

ProPath Directory List for Process

Searches Procedure File

Page 14: Progress Training         MFG/PRO

www.softspeed.com.hk

1.3 Starting a Progress Session1.3 Starting a Progress Session (Progress Propath) (Progress Propath)

Propath is a list of directories Progress uses to findProcedures you in a session.

1. Edit Configure file Progress.ini

2. Using the Propath Editor in PRO*Tools

How To set Propath ?

3. In Progress Editor , Assign to Propath

Page 15: Progress Training         MFG/PRO

www.softspeed.com.hk

1.3 Starting a Progress Session1.3 Starting a Progress Session (Database Connections) (Database Connections)

Will Be Discuss In Progress Administration Training

Guide

Page 16: Progress Training         MFG/PRO

www.softspeed.com.hk

1.4 1.4 Using The Procedure Editor (How to Use Procedure Editor) (How to Use Procedure Editor)

Key Function

F2 Help

F1 Run

F7 Next Buffer

F9 Find

Show Buffer List

Multiple Procedure Windows

Checking Syntax

Page 17: Progress Training         MFG/PRO

www.softspeed.com.hk

1.4 1.4 Using The Procedure Editor (How to Use Compile Procedure)(How to Use Compile Procedure)

Using the Compile statment

Using the Application compiler tool

Using Application Tool MFG-UTIL

Compile Procedure-name Save into Directory

Page 18: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 19: Progress Training         MFG/PRO

www.softspeed.com.hk

2.1 Progress2.1 Progress 的数据类型的数据类型

CHARACTER: X(8)CHARACTER: X(8)DATE : 99/99/99DATE : 99/99/99DECIMAL:DECIMAL: ->>,>>9.99 ->>,>>9.99HANDLE:HANDLE: >>>>>>9 >>>>>>9INTEGER:INTEGER: ->,>>>,>>9 ->,>>>,>>9LOGICAL:LOGICAL: yes/no yes/no

Page 20: Progress Training         MFG/PRO

www.softspeed.com.hk

2.2 2.2 常量与变量常量与变量

变量必须在第一次被使用之前定义,可以定义在程序的任何地方!变量必须在第一次被使用之前定义,可以定义在程序的任何地方!但是通常为了增加程序的可读性,变量定义都放在程序的开始处!但是通常为了增加程序的可读性,变量定义都放在程序的开始处!以下是变量定义的几个实例:以下是变量定义的几个实例: define variable str01 as char label "DemoString" initial "hello". define variable str01 as char label "DemoString" initial "hello". def var str02 like str01.def var str02 like str01. def var dt01 as date extent 5. def var dt01 as date extent 5. def var inte01 as inte format ">>>9". def var inte01 as inte format ">>>9".

说明,第一行:说明,第一行:str01 str01 是变量名, 变量名不要与系统关键字重复,字符或者下划线是变量名, 变量名不要与系统关键字重复,字符或者下划线开头,比如开头,比如 strModel,_Model strModel,_Model ;;char char 表示变量类型,本例指字符型变量,其它类似的比如表示变量类型,本例指字符型变量,其它类似的比如 integerinteger ,,datedate ,, logicallogical 等 ;等 ;label label 就是后续程序中对变量的描述,比如需要用户输入这个变量就是后续程序中对变量的描述,比如需要用户输入这个变量值时,系统提示“值时,系统提示“ DemoString" DemoString" ;;initial initial 变量的初始值变量的初始值

Page 21: Progress Training         MFG/PRO

www.softspeed.com.hk

2.2 2.2 常量与变量常量与变量

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

Page 22: Progress Training         MFG/PRO

www.softspeed.com.hk

2.2 2.2 常量与变量常量与变量

Define variable

Assignvariabl

e

Display variable

Variable BufferScreen Buffer

Page 23: Progress Training         MFG/PRO

www.softspeed.com.hk

2.2 2.2 常量与变量常量与变量

Syntax :

Define variable var-name init value Label “ABC“.

As Data type format format

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

Page 24: Progress Training         MFG/PRO

www.softspeed.com.hk

2.2 2.2 常量与变量常量与变量

Syntax :

Sample:

Assign Variable = Value Display Variable .

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.

Page 25: Progress Training         MFG/PRO

www.softspeed.com.hk

2.2 2.2 常量与变量常量与变量

Syntax :

Sample:

SET ** Assign it to Record Buffer.

Prompt-for ** Save it to screen buffer ONLY.

Screen Buffer

RecordBuffer

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.

Page 26: Progress Training         MFG/PRO

www.softspeed.com.hk

2.3 2.3 运算符 运算符 & 2.4& 2.4 表达式表达式

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

Page 27: Progress Training         MFG/PRO

www.softspeed.com.hk

2.5 2.5 一些特殊符号一些特殊符号

Symbols Role

/* */ Enclosing a comment

* Multi Character wildcard

. Terminating a statement

Delimiter for fully qualified field name

: Terminating a block header or block label

? Specifying the unknown value

“” Or ‘’ Enclosing of a character string

{filename} Include file reference

[ ] Define Array variable

Page 28: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 29: Progress Training         MFG/PRO

www.softspeed.com.hk

3.1 Progress3.1 Progress 的三种程序结构的三种程序结构

1.1. 顺序结构顺序结构

2. 2. 分支结构分支结构 If … then … elseIf … then … else

3. 3. 循环结构循环结构 Repeat … endRepeat … end Do … endDo … end

Page 30: Progress Training         MFG/PRO

www.softspeed.com.hk

3.2 Progress3.2 Progress 的输入和输出的输入和输出

Every procedure automatically gets one input stream and Every procedure automatically gets one input stream and one output stream.one output stream.

• Input Input Prompt-for, assign, update, setPrompt-for, assign, update, set Sample:Sample: Repeat :Repeat : Prompt-for customer.cust_num.Prompt-for customer.cust_num. find customer using cust_num.find customer using cust_num. display display name state credit_limit.name state credit_limit. End.End.

Page 31: Progress Training         MFG/PRO

www.softspeed.com.hk

3.2 Progress3.2 Progress 的输入和输出的输入和输出

Sample:Sample: For each customer :For each customer : update name state credit_limt.update name state credit_limt. end.end.

find first customer where name = “AA” no-lock no-error.find first customer where name = “AA” no-lock no-error. if not availabel customer then do :if not availabel customer then do : create customer.create customer. assign assign name = “AA”name = “AA” state = “”state = “” credit_limit = “”.credit_limit = “”. end.end.

Page 32: Progress Training         MFG/PRO

www.softspeed.com.hk

3.2 Progress3.2 Progress 的输入和输出的输入和输出

2. Output2. Output Display, put, output Display, put, output Sample:Sample:

DEFINE VARIABLE f AS CHARACTER NO-UNDO.DEFINE VARIABLE f AS CHARACTER NO-UNDO.DEFINE VARIABLE i AS INTEGER NO-UNDO.DEFINE VARIABLE i AS INTEGER NO-UNDO.DEFINE VARIABLE j AS INTEGER NO-UNDO.DEFINE VARIABLE j AS INTEGER NO-UNDO.i = 0.i = 0.j = 0.j = 0.f = "out.txt".f = "out.txt".OS-DELETE VALUE(f).OS-DELETE VALUE(f).OUTPUT TO VALUE(f) APPEND.OUTPUT TO VALUE(f) APPEND.

Page 33: Progress Training         MFG/PRO

www.softspeed.com.hk

3.2 Progress3.2 Progress 的输入和输出的输入和输出

FOR EACH gltr_hist:FOR EACH gltr_hist: i = i + 1.i = i + 1. IF i = 50001 THEN DO:IF i = 50001 THEN DO: i = 1.i = 1. OUTPUT CLOSE.OUTPUT CLOSE. j = j + 1.j = j + 1. f = "out_" + STRING( j) + ".txt".f = "out_" + STRING( j) + ".txt". OS-DELETE VALUE(f).OS-DELETE VALUE(f). OUTPUT TO VALUE(f) APPEND.OUTPUT TO VALUE(f) APPEND. END.END. EXPORT DELIMITER "~011" gltr_hist.EXPORT DELIMITER "~011" gltr_hist.END.END.OUTPUT CLOSE.OUTPUT CLOSE.

Page 34: Progress Training         MFG/PRO

www.softspeed.com.hk

3.3 使用代码连接或中断数据库以及在数据库中怎样使用 os 的命令

Syntax:Connect Physical Database –ld logical Name No Error

Disconnect logical Name No Error

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.

Logical NamePhysical Name DB Type

DB Counter

Page 35: Progress Training         MFG/PRO

www.softspeed.com.hk

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.

Page 36: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 37: Progress Training         MFG/PRO

www.softspeed.com.hk

4.1 4.1 逻辑运算符 逻辑运算符 & 4.2 & 4.2 关系运算符关系运算符

Operators: + - * /

Logical Operators: Not And Or

Comparison Operators: = <> < > <= >= Begins Matches

Precedence in Logical Operations: 1) () 2) Not 3) And 4) Or

Page 38: Progress Training         MFG/PRO

www.softspeed.com.hk

4.1 4.1 逻辑运算符 逻辑运算符 & 4.2 & 4.2 关系运算符关系运算符

Sample:Sample:

Define var x as integer init 5.Define var x as integer init 5.

For each so_mstr:For each so_mstr:find first sod_det where sod_nbr = so_nbr no-lock no-error.find first sod_det where sod_nbr = so_nbr no-lock no-error.if (not availabel sod_det and x <> 5) then do :if (not availabel sod_det and x <> 5) then do : create so.create so. assign assign sod_nbr = “”.sod_nbr = “”.end.end.

Page 39: Progress Training         MFG/PRO

www.softspeed.com.hk

4.3 4.3 条件语句及条件语句及 CaseCase 语句语句判断最简单了,就是一个判断最简单了,就是一个 if if 条件 条件 then ... else ...then ... else ... ,比如:,比如:

if str01 = "cpu" then disp "CPU" if str01 = "cpu" then disp "CPU"                  else disp "Not CPU".                 else disp "Not CPU".当然,这个”条件“可能有很复杂的组合。如果,涉及到的当然,这个”条件“可能有很复杂的组合。如果,涉及到的动作比较多,那么做法是用动作比较多,那么做法是用 do: ... end.do: ... end. ,比如,比如if str01 = "cpu" then do:if str01 = "cpu" then do:   str01 = "my cpu".   str01 = "my cpu".   disp "CPU".   disp "CPU".end.end.else do:else do:   str01 = "my memory".   str01 = "my memory".   disp "Not CPU".   disp "Not CPU".end.end.if if 支持嵌套。 支持嵌套。

Page 40: Progress Training         MFG/PRO

www.softspeed.com.hk

4.3 4.3 条件语句及条件语句及 CaseCase 语句语句

Syntax:

Sample:

IF Condition THEN expression1 ELSE expression2.

IF Condition THEN DO: Statement1. Statement2.END.ELSE DO: Statement3. Statement4.END.

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.

Page 41: Progress Training         MFG/PRO

www.softspeed.com.hk

4.3 4.3 条件语句及条件语句及 CaseCase 语句语句

Syntax:

Sample:

Case expression: When Value1 then Statement1. When Value2 then Statement2. When Value3 then Statement3. Otherwise statement4.End CaseDefine 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.

Page 42: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 43: Progress Training         MFG/PRO

www.softspeed.com.hk

5.1 Do: … End 5.1 Do: … End 语句语句

Syntax:

Sample:

DO [Var = expression1 To expression2 [BY n]]: statement.END.

Define variable i as integer.Do i = 1 to 10 by 2: Display i. Pause.End.

Page 44: Progress Training         MFG/PRO

www.softspeed.com.hk

5.2 Repeat … End 5.2 Repeat … End 语句及语句及 LeaveLeave 语句语句

Syntax:

Sample:

Repeat [Var = expression1 To expression2 [BY n]]: statement.END.

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

Page 45: Progress Training         MFG/PRO

www.softspeed.com.hk

5.2 Repeat … End 5.2 Repeat … End 语句及语句及 LeaveLeave 语句语句

Syntax:

Sample:

Repeat [Var = expression1 To expression2 [BY n]]: statement.END.

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

Page 46: Progress Training         MFG/PRO

www.softspeed.com.hk

5.2 Repeat … End 5.2 Repeat … End 语句及语句及 LeaveLeave 语句语句

Syntax:

Sample:

Loop:Do / Repeat [While expression]: statements. If xxx Then Leave loop. Statements. End.

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

Page 47: Progress Training         MFG/PRO

www.softspeed.com.hk

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

Page 48: Progress Training         MFG/PRO

www.softspeed.com.hk

6.1 一维数组的定义和引用

Syntax:

Sample:

DEFINE VARIABLE variable {AS datatype} [EXTENT n] [INITIAL {constant|{[constant[,constant]...]}}] [LABEL string[, string]...]

Define variable v_month as integer extent 12 init [1,2,3,4,5,6,7,8,9,10,11,12]label [“ 一” ,“ 二” ,” 三” ,”四” ,”五” ,”

六” ,”七” ,”八” ,”九” ,”十” ,”十一” ,”十二” ]

Page 49: Progress Training         MFG/PRO

www.softspeed.com.hk

6.2 数字数组

Syntax:

Sample:

DEFINE VARIABLE int_value AS INTEGER EXTENT 3 INITIAL [1, 2, 3].

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

Page 50: Progress Training         MFG/PRO

www.softspeed.com.hk

6.3 字符数组

Syntax:

Sample:

DEFINE VARIABLE int_value AS CHAR EXTENT 3 INITIAL [“1”,”2”, “3”].

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

Page 51: Progress Training         MFG/PRO

www.softspeed.com.hk

< 七 > 过程和函数 7.1 过程及其调用 7.2 函数极其调用 7.3 系统常用函数 7.4 程序举例

Page 52: Progress Training         MFG/PRO

www.softspeed.com.hk

7.1 7.1 过程及其调用过程及其调用

Syntax:

Sample:

Procedure procedure-name: [Define Input/Output ] Parameter parameter as Datatype Statement code.End Procedure.Define variable factorialResult as integer.

Define variable factorialInput as integer.Repeat: Set FactorialInput. RUN factorial (Input FactorialInput , Output FactorialResult). Display FactorialResult.End.

Procedure factorial: Define input Parameter Pterm as integer. Define Output Parameter FactorialResult as integer. Define variable workingResult As Integer. If Pterm <=1 Then Do: FactorialResult = 1. Return. End. Else do: Run factorial (Input Pterm - 1,Output workingResult). FactorialResult = Pterm * WorkingResult. End. End Procedure.

Page 53: Progress Training         MFG/PRO

www.softspeed.com.hk

7.2 7.2 函数及其调用函数及其调用

Syntax:

Sample:

FUNCTION function-name [RETURNS] data-type[(param [, param ]...)]

FUNCTION doubler RETURNS INTEGER (INPUT parm1 FUNCTION doubler RETURNS INTEGER (INPUT parm1 AS INTEGER).AS INTEGER). RETURN (2 * parm1). RETURN (2 * parm1). END FUNCTION. END FUNCTION. /* Reference doubler() *//* Reference doubler() */DISPLAYDISPLAY "doubler(0)=" doubler(0) skip"doubler(0)=" doubler(0) skip

"doubler(1)=" doubler(1) skip"doubler(1)=" doubler(1) skip"doubler(2)=" doubler(2) skip."doubler(2)=" doubler(2) skip.

Page 54: Progress Training         MFG/PRO

www.softspeed.com.hk

7.3 7.3 系统常用函数系统常用函数 (( 一一 ))

Function Sample

String Display String(1) + “A”

Begins Display “ABCD” begins “AB”

Matches Display "ABCD" Matches "A.C*D*"

Length Display length("ABCD")

Index Display Index("ABCD","C")

Substring Display substring("AVC",2,1)

Trim Display Trim(" ABC ") + "D"

Fill Display Fill(“A",10)

Page 55: Progress Training         MFG/PRO

www.softspeed.com.hk

7.3 7.3 系统常用函数系统常用函数 (( 二二 ))

Function Sample

Today Display Today

Date Display Date(10,13,2001)

Day Display day(today)

Month Display day(Month)

Weekday Display Weekday(today)

Year Display Year(today)

Time Display time

+ Display Today + 3

Page 56: Progress Training         MFG/PRO

www.softspeed.com.hk

< 八 > 编程访问数据库 8.1 从数据库中返回数据 8.2 修改数据库中的数据 8.3 锁定与事务 8.4 怎样使用 Frame作为显示模板

Page 57: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Introduction) (Introduction)

How to Retrieving Data in Progress :

Find

For Each

Retrieves Retrieves ONEONE Record form database Record form database

Retrieves Retrieves ONEONE or or MOREMORE records going forwards only in the set of recorders records going forwards only in the set of recorders

CustomerCustomer Sales OrderSales Order

ONE TO ONEONE TO ONEONE TO MOREONE TO MOREONE TO NONEONE TO NONE

PO Receive DataPO Receive Data Transaction “RCT-PO”Transaction “RCT-PO”

Page 58: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using Find to Retrieving Records) (Using Find to Retrieving Records)

Syntax :

Find First record-name [WHERE expression] [USE-INDEX index-name][NO-ERROR] IF Available( record-name ).

NextNextPrevPrevLastLast

Sample :

Find last tr_hist.Find last tr_hist. Display tr_type tr_part tr_effdate tr_qty_chg.Display tr_type tr_part tr_effdate tr_qty_chg.

FFind first tr_hist where tr_nbr = "xxx" and tr_type ="RCT-PO".ind first tr_hist where tr_nbr = "xxx" and tr_type ="RCT-PO". Display tr_part.Display tr_part.

What is Last Inventory Transaction What is Last Inventory Transaction

PO xxx Already Received PO xxx Already Received

How to improve speed for data retrieving ?How to improve speed for data retrieving ?

INDEX INDEX

Page 59: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using Find to Retrieving (Using Find to Retrieving Records) Records)

Syntax :

Find First record-name [WHERE expression] [USE-INDEX index-name][NO-ERROR]

NextNextPrevPrevLastLast

Sample :

Find last tr_hist.Find last tr_hist. Display tr_type tr_part tr_effdate tr_qty_chg.Display tr_type tr_part tr_effdate tr_qty_chg.

FFind first tr_hist where tr_nbr = "xxx" and tr_type ="RCT-PO".ind first tr_hist where tr_nbr = "xxx" and tr_type ="RCT-PO". Display tr_part.Display tr_part.

What is Last Inventory Transaction What is Last Inventory Transaction

PO xxx Already Received PO xxx Already Received

How to improve speed for data retrieving ?How to improve speed for data retrieving ?

INDEX INDEX

Page 60: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using Find Parameter ---- WHERE) (Using Find Parameter ---- WHERE)

Find first prh_hist where prh_nbr begins Find first prh_hist where prh_nbr begins ““POPO”” no-error. no-error.Display prh_histDisplay prh_hist

WHERE

WHERE

Sample :

= , > , < ,<>,>=,<=,= , > , < ,<>,>=,<=,Begins,MatchesBegins,Matches

WHERE Variable / Field Begins WHERE Variable / Field Begins stringstringWHERE Variable / Field Matches WHERE Variable / Field Matches stringstring (*ABC*) (*ABC*)

Syntax :

Page 61: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using Find Parameter ---- INDEX)(Using Find Parameter ---- INDEX)

IndexIndex is a structure that holds sorted data from one or more filed. is a structure that holds sorted data from one or more filed.

An index on a field helps retrieve records An index on a field helps retrieve records fasterfaster when retrieval is when retrieval is Based on that field.Based on that field.

How to find item”D”saftyHow to find item”D”safty stock fastest ???stock fastest ???

Item SS

A 100

B 200

C 400

D 300

E 500

Item SS

C 400

A 100

E 500

B 200

D 300

INDEXINDEX

Syntax :Find first Find first table-nametable-name WHERE condition USE-INDEX WHERE condition USE-INDEX index-nameindex-name

Sample :

Find first pt_mstr Where pt_part = Find first pt_mstr Where pt_part = ““DD”” USE-INDEX pt_part. USE-INDEX pt_part.

Wrong Index will lowest search speed!!!!Wrong Index will lowest search speed!!!!

Page 62: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using Find Parameter----LOCK) (Using Find Parameter----LOCK)

Default is Share-lock.Default is Share-lock. Only lock RECORD.Only lock RECORD.

For each pt_mstr EXCLUSIVE-LOCK.For each pt_mstr EXCLUSIVE-LOCK.

update pt_part.update pt_part.

end.end.

Find first pt_mstr share-lock.Find first pt_mstr share-lock.

display pt_partdisplay pt_part

In Customization Report, Please use In Customization Report, Please use no-lockno-lock in Retrieving Data in Retrieving Data

NO-LOCKNO-LOCK To read a record even if another user has it EXCLUSIVE-LOCKed. To read a record even if another user has it EXCLUSIVE-LOCKed. EXCLUSIVE-LOCKEXCLUSIVE-LOCK Other users cannot read or update a record that is EXCLUSIVE-LOCKed, Other users cannot read or update a record that is EXCLUSIVE-LOCKed, except by using the NO-LOCK optionexcept by using the NO-LOCK option.. SHARE-LOCKSHARE-LOCK Ther users can still read a record that is share locked,Ther users can still read a record that is share locked, but they cannot update it.but they cannot update it.

Find first pt_mstr share-Find first pt_mstr share-lock.lock.

update pt_desc1.update pt_desc1.

Find first pt_mstr share-Find first pt_mstr share-lock.lock.

update pt_desc1.update pt_desc1.

Page 63: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using FOR EACH ) (Using FOR EACH )

Use the FOR EACH statement when you want to retrieve a set of records and want to:Use the FOR EACH statement when you want to retrieve a set of records and want to:

Use the same selection criteria for all of these records.Use the same selection criteria for all of these records. Loop through the list of records and process each of them in each iteration of the Loop through the list of records and process each of them in each iteration of the FOR EACH block.FOR EACH block.

Syntax :

FOR EACH record-phrase WHERE condition ……: Statement.END.

Sample :

for each prh_hist no-lock:for each prh_hist no-lock: display prh_rcp_date prh_receiver prh_nbr prh_part prh_rcvd .display prh_rcp_date prh_receiver prh_nbr prh_part prh_rcvd .end.end.

Page 64: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using FOR EACH Parameter - BY ) (Using FOR EACH Parameter - BY )

Sorting Records By Certain Field ValuesSorting Records By Certain Field Values

You Can Sorting By You Can Sorting By ONEONE field OR field OR MoreMore fields fields With the With the DESCENDINGDESCENDING option of BY you can specify the opposite sort order. option of BY you can specify the opposite sort order.

Sample :

for each prh_hist by prh_rcp_date desc by prh_nbr no-lock:for each prh_hist by prh_rcp_date desc by prh_nbr no-lock: display prh_rcp_date prh_receiver prh_nbr prh_part prh_rcvd .display prh_rcp_date prh_receiver prh_nbr prh_part prh_rcvd .end.end.

Can i know last receiverCan i know last receiverinformation for specific PO information for specific PO

Page 65: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using FOR EACH - Retrieving Data from Multiple Tables ) (Using FOR EACH - Retrieving Data from Multiple Tables )

Sample :

For each tr_hist ,each pt_mstr where tr_part = pt_part NO-LOCK:For each tr_hist ,each pt_mstr where tr_part = pt_part NO-LOCK: display tr_type tr_part pt_desc1 pt_desc2 tr_effdate.display tr_type tr_part pt_desc1 pt_desc2 tr_effdate.End.End.

Syntax :

FOR EACH FOR EACH table-name1table-name1 , , EACHEACH table-name2table-name2 Where Where table-name1.field1table-name1.field1 = = table-name2.Field1table-name2.Field1 NO-LOCK: NO-LOCK: statement.statement.END.END. DO YOU KNOW ?DO YOU KNOW ?

Table-name.Field-nameTable-name.Field-name

Page 66: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using FOR EACH - Summary ) (Using FOR EACH - Summary )

Syntax :

FOR EACH FOR EACH table-nametable-name BREAK BY BREAK BY field-name1field-name1 BY BY field-name2field-name2 NO-LOCK: NO-LOCK:

IF FIRST-OF(IF FIRST-OF(field-name1) field-name1) Then Then statement1.statement1. ACCUMULATE ACCUMULATE QtyQty ( TOTAL). ( TOTAL).

ACCUMULATE ACCUMULATE QtyQty ( TOTAL BY ( TOTAL BY field-name1field-name1).).

ACCUMULATE ACCUMULATE Qty * PriceQty * Price ( TOTAL BY ( TOTAL BY field-name2field-name2 ). ).

statement2 .statement2 . IF LAST-OF(IF LAST-OF(field-name1field-name1) Then Display ACCUM TOTAL BY ) Then Display ACCUM TOTAL BY field-name1field-name1 Qty. Qty.

IF LAST-OF(IF LAST-OF(field-name2field-name2) Then Display ACCUM TOTAL BY ) Then Display ACCUM TOTAL BY field-name2field-name2 Qty * Price Qty * Price.. END.END. BREAK BYBREAK BY

FIRST-OFFIRST-OF LAST-OFLAST-OF ACCUMULATEACCUMULATE ACCUMACCUM

Key WordsKey Words

Page 67: Progress Training         MFG/PRO

www.softspeed.com.hk

8.1 8.1 从数据库中返回数据从数据库中返回数据 (Using FOR EACH - Summary ) (Using FOR EACH - Summary )

Sample : FOR EACH tr_hist WHERE tr_type = "RCT-PO" ,EACH pt_mstr WHERE FOR EACH tr_hist WHERE tr_type = "RCT-PO" ,EACH pt_mstr WHERE pt_part =pt_part =

tr_part BREAK BY tr_lot BY tr_part :tr_part BREAK BY tr_lot BY tr_part :

If FIRST-OF(tr_part) Then Display pt_part pt_desc1 with frame a.If FIRST-OF(tr_part) Then Display pt_part pt_desc1 with frame a.

ACCUMULATE tr_qty_loc ( TOTAL ).ACCUMULATE tr_qty_loc ( TOTAL ).

ACCUMULATE tr_qty_loc ( TOTAL BY tr_lot ).ACCUMULATE tr_qty_loc ( TOTAL BY tr_lot ).

ACCUMULATE tr_qty_loc ( TOTAL BY tr_part ).ACCUMULATE tr_qty_loc ( TOTAL BY tr_part ).

Display tr_part tr_lot tr_qty_loc.Display tr_part tr_lot tr_qty_loc.

if LAST-OF(tr_part) Then display ACCUM TOTAL BY tr_part tr_qty_locif LAST-OF(tr_part) Then display ACCUM TOTAL BY tr_part tr_qty_loc

label "SUM Part".label "SUM Part".

if LAST-OF(tr_lot) Then display ACCUM TOTAL BY tr_lot tr_qty_locif LAST-OF(tr_lot) Then display ACCUM TOTAL BY tr_lot tr_qty_loc

label "SUM RE".label "SUM RE".

End.End.

Show PO Receive information Show PO Receive information Order by ITEM and Receiver NOOrder by ITEM and Receiver NO

Page 68: Progress Training         MFG/PRO

www.softspeed.com.hk

8.2 8.2 修改数据库中的数据修改数据库中的数据 (Changing Database Data ) (Changing Database Data )

Objectives :

Create table (temp table)Create table (temp table) Create a new record in the databaseCreate a new record in the database

Change data recordsChange data records

Delete existing database recordsDelete existing database records

Page 69: Progress Training         MFG/PRO

www.softspeed.com.hk

8.2 8.2 修改数据库中的数据修改数据库中的数据 (Changing Database Data – Create temp table ) (Changing Database Data – Create temp table )

Syntax :

Sample :

DEFINEDEFINE [[NEW] SHARED] {WORK-TABLE| [[NEW] SHARED] {WORK-TABLE|WORKFILEWORKFILE} } work-table-namework-table-name

[NO-UNDO] [LIKE tablename][[NO-UNDO] [LIKE tablename][FIELDFIELD field-namefield-name {{AS{{AS

datatype}|{datatype}|{LIKELIKE field field }} [field-options]]...}} [field-options]]...

DEFINE WORK-TABLE ptmstrDEFINE WORK-TABLE ptmstr

FIELD ptpart LIKE pt_part LABEL “Part"FIELD ptpart LIKE pt_part LABEL “Part"

FIELD ptdesc1 LIKE pt_desc1 LABEL “Desc1"FIELD ptdesc1 LIKE pt_desc1 LABEL “Desc1"

FIELD ptdesc2 AS character “x(40)” LABEL “Desc2".FIELD ptdesc2 AS character “x(40)” LABEL “Desc2".

Page 70: Progress Training         MFG/PRO

www.softspeed.com.hk

8.2 8.2 修改数据库中的数据修改数据库中的数据 (Changing Database Data – Create a new record to table ) (Changing Database Data – Create a new record to table )

Syntax :

Sample :

CREATECREATE table-name.table-name.

ASSIGN ASSIGN field-name1field-name1 = = Variable1Variable1

field-name2field-name2 = = Variable2.Variable2.

DEFINE WORK-TABLE ptmstrDEFINE WORK-TABLE ptmstr

FIELD ptpart LIKE pt_part LABEL FIELD ptpart LIKE pt_part LABEL ““Part"Part"

FIELD ptdesc1 LIKE pt_desc1 LABEL FIELD ptdesc1 LIKE pt_desc1 LABEL ““Desc1"Desc1"

FIELD ptdesc2 AS character FIELD ptdesc2 AS character ““x(40)x(40)”” LABEL LABEL ““Desc2".Desc2".

CREATE ptmstr.CREATE ptmstr.

Assign ptpart = Assign ptpart = ““AAAAAAAA””..

display ptmstr.display ptmstr.

CREATE BLANK RECORDCREATE BLANK RECORD

ASSIGN DATA TO FIELDASSIGN DATA TO FIELD

Page 71: Progress Training         MFG/PRO

www.softspeed.com.hk

8.2 8.2 修改数据库中的数据修改数据库中的数据 (Changing Database Data – Change Existing Data ) (Changing Database Data – Change Existing Data )

Syntax :

Sample :

UPDATE Table-name / Field-name.UPDATE Table-name / Field-name.

DEFINE WORK-TABLE ptmstrDEFINE WORK-TABLE ptmstr

FIELD ptpart LIKE pt_part LABEL FIELD ptpart LIKE pt_part LABEL ““Part"Part"

FIELD ptdesc1 LIKE pt_desc1 LABEL FIELD ptdesc1 LIKE pt_desc1 LABEL ““Desc1"Desc1"

FIELD ptdesc2 AS character FIELD ptdesc2 AS character ““x(40)x(40)”” LABEL LABEL ““Desc2".Desc2".

CREATE ptmstr.CREATE ptmstr.

Assign ptpart = Assign ptpart = ““AAAAAAAA””..

Update ptmstr.Update ptmstr.

Page 72: Progress Training         MFG/PRO

www.softspeed.com.hk

8.2 8.2 修改数据库中的数据修改数据库中的数据 (Changing Database Data – Delete A Record ) (Changing Database Data – Delete A Record )

Syntax :

Sample :

Delete table-name / Field-name.Delete table-name / Field-name.

DEFINE WORK-TABLE ptmstrDEFINE WORK-TABLE ptmstr

FIELD ptpart LIKE pt_part LABEL FIELD ptpart LIKE pt_part LABEL ““Part"Part"

FIELD ptdesc1 LIKE pt_desc1 LABEL FIELD ptdesc1 LIKE pt_desc1 LABEL ““Desc1"Desc1"

FIELD ptdesc2 AS character FIELD ptdesc2 AS character ““x(40)x(40)”” LABEL LABEL ““Desc2".Desc2".

CREATE ptmstr. Assign ptpart = CREATE ptmstr. Assign ptpart = ““AAAAAAAA””..

CREATE ptmstr. Assign ptpart = CREATE ptmstr. Assign ptpart = ““BBBBBBBB””..

FOR EACH ptmstr.FOR EACH ptmstr.

DELETE ptmstr.DELETE ptmstr.

END.END.

CLEAR TEMP TABLE RECORDCLEAR TEMP TABLE RECORD

Delete one record ONLYDelete one record ONLY

Page 73: Progress Training         MFG/PRO

www.softspeed.com.hk

8.3 8.3 锁定与事务锁定与事务 (Multi-user Client/Server Session)(Multi-user Client/Server Session)

_mprosrv.exe

SERVERSERVER

CLIENTCLIENT

DATABASEDATABASE

Local UserLocal UserStartupStartup

Remote UserRemote User

CONNECTCONNECT

CONNECT

CONNECT

PROWIN32.EXE

GUI Environment

Local UserLocal User

Remote UserRemote User

UNIX Environment

CONNECT

CONNECT

STARTUP

STARTUPSTARTUP

Page 74: Progress Training         MFG/PRO

www.softspeed.com.hk

8.3 8.3 锁定与事务锁定与事务 (LOCKING)(LOCKING)

ITEM QTYITEM QTY

AAA 10 AAA 10

Sure, I Can send you 7 Sure, I Can send you 7 AAA Tomorrow!AAA Tomorrow!

Sure, I Can send you 6 Sure, I Can send you 6 AAA Tomorrow!AAA Tomorrow!

Sales Person ASales Person A

Sales Person BSales Person B

Page 75: Progress Training         MFG/PRO

www.softspeed.com.hk

8.3 8.3 锁定与事务锁定与事务 (LOCKING)(LOCKING)

ITEM QTYITEM QTY

AAA 10 AAA 10

Sure, I Can send you 7 Sure, I Can send you 7 AAA Tomorrow!AAA Tomorrow!

Sales Person ASales Person A

I Can send you 3I Can send you 3AAA Tomorrow!AAA Tomorrow!

Sales Person BSales Person B

Someone Someone order AAA ?order AAA ?

Page 76: Progress Training         MFG/PRO

www.softspeed.com.hk

8.4 8.4 怎样使用怎样使用 FrameFrame 作为显示模板作为显示模板

Controlling the display with frames , including Variable , field ......

Display Report Header/Foot Display Report Header/Foot

Display fixed format in ProgrammingDisplay fixed format in Programming

Function :

Define FrameDefine Frame Statement Statement Statements that display data , such as Statements that display data , such as DISPLAY,DISPLAY, SETSET, and so on, and so on DODO Block header Block header REPEATREPEAT block header block header FOR EACHFOR EACH block header block header

Where To Use ?Where To Use ?Scope :

Syntax :

WITH [[expression] DOWN][Frame Frame-name] [Title string][NO-BOX][NO-LABEL]......

Page 77: Progress Training         MFG/PRO

www.softspeed.com.hk

8.4 8.4 怎样使用怎样使用 FrameFrame 作为显示模板作为显示模板

Define variable ii as integer.Define variable ii as integer.Display propath.Display propath.Do ii = 1 to Num-Entries(Propath) Do ii = 1 to Num-Entries(Propath) with downwith down:: Display Entry(ii,Propath) Format "x(35)“ Display Entry(ii,Propath) Format "x(35)“ downdown..ENd.ENd.

Sample:

Page 78: Progress Training         MFG/PRO

www.softspeed.com.hk

8.4 8.4 怎样使用怎样使用 FrameFrame 作为显示模板作为显示模板

for each pt_mstr :for each pt_mstr : display pt_part with frame a display pt_part with frame a side-labelside-label.. display pt_desc1 pt_desc2 with frame b .display pt_desc1 pt_desc2 with frame b . end.end.

Sample:

for each pt_mstr :for each pt_mstr :

display pt_mstr display pt_mstr with 2 columnwith 2 column. .

end.end.

Sample:

( Using Column in a Frame)( Using Column in a Frame)

Page 79: Progress Training         MFG/PRO

www.softspeed.com.hk

8.4 8.4 怎样使用怎样使用 FrameFrame 作为显示模板作为显示模板

for each pt_mstr :for each pt_mstr : display pt_part with display pt_part with NO-BOXNO-BOX..end.end.

Sample:

for each pt_mstr :for each pt_mstr :

display pt_part display pt_part with Centered with Centered ..

/* display pt_part /* display pt_part with column 15 ROW 5 with column 15 ROW 5 .*/ .*/

end.end.

( Specifying Exact Location for the Frame)( Specifying Exact Location for the Frame)

Sample:

Page 80: Progress Training         MFG/PRO

www.softspeed.com.hk

8.4 8.4 怎样使用怎样使用 FrameFrame 作为显示模板作为显示模板

for each pt_mstr :for each pt_mstr : display pt_part pt_desc with display pt_part pt_desc with Title “Item Master Maintenance”Title “Item Master Maintenance”..end.end.

Sample:

for each pt_mstr:for each pt_mstr:

display pt_part display pt_part at 20at 20 with frame a. with frame a.

display pt_part display pt_part to 20to 20 with frame b. with frame b.

display pt_part display pt_part at column 20 row 2at column 20 row 2 with frame c. with frame c.

end.end.

(Controlling Layout of items Inside the Frame)(Controlling Layout of items Inside the Frame)

Sample:

Page 81: Progress Training         MFG/PRO

www.softspeed.com.hk

8.4 8.4 怎样使用怎样使用 FrameFrame 作为显示模板作为显示模板

Syntax:

define variable fname as character format "x(10)"

label "First Name" init "Sam".

define variable lname as character format "x(10)"

label "Last" init "Song".

define variable co as character format "x(10)"

label "Company" init "Softspeed".

define frame f-name

fname colon 15

lname colon 15

co colon 15

with side-labels row 1 centered .

define frame f-co

fname at row 2 column 8

"Work at" at row 2 column 15

co at row 2 column 25

with no-label centered no-box.

view frame f-name.

display fname lname co with frame f-name.

display fname co with frame f-co.

Sample:

DEFINE FRAME Frame-name Variable / Field /SPACE[n]/SKIP[n] WITH [side-labels].

DISPLAY ...... WITH FRAME Frame-name.

Page 82: Progress Training         MFG/PRO

www.softspeed.com.hk

8.4 8.4 怎样使用怎样使用 FrameFrame 作为显示模板作为显示模板

Question :

Answer :

Show following Data format specify format

IntroduceIntroduce

My name is My name is JaneJane XX DoeDoe

IntroduceIntroduce

My name isMy name is Jane Jane X DoeX Doe

define variable fname as char format "x(10)" init "Jane".

define variable mname as char format "x(1)" init "X".

define variable lname as char format "x(15)" init "DOE".

display "My Name is"

fname mname lname with no-label title "Introduction".

/* Display “My Name is“ at ROW 2 column 10

fname at ROW 3 column 10 mname ROW 3 column 18

lname at ROW 3 column 20 with no-label title “Introduction” */

Page 83: Progress Training         MFG/PRO

www.softspeed.com.hk

< 九 > Database 的创建 9.1 单卷数据库的创建 9.2 多卷数据库的创建

9.1 单卷数据库的创建

• Windows Version:

Page 84: Progress Training         MFG/PRO

www.softspeed.com.hk

Page 85: Progress Training         MFG/PRO

www.softspeed.com.hk

9.1 单卷数据库的创建

• CHAR模式下命令:• Prodb /app/test.db /app/progress/empty.db• Windows下命令:• Prodb d:\test.db \c:\dlc\empty.db

•只是路径不同而已

Page 86: Progress Training         MFG/PRO

www.softspeed.com.hk

9.2 多卷数据库的创建

• 9.2.1 先建立一个文本文件 test.st,内容如下:

d f:\dg\test.d1 f 500000d f:\dg\test.d1 f 500000d f:\dg\test.d2 f 500000d f:\dg\test.d2 f 500000d f:\dg\test.d3 f 500000d f:\dg\test.d3 f 500000d f:\dg\test.d4 f 500000d f:\dg\test.d4 f 500000d f:\dg\test.d5 f 500000d f:\dg\test.d5 f 500000d f:\dg\test.d6 f 500000d f:\dg\test.d6 f 500000d f:\dg\test.d7 f 500000d f:\dg\test.d7 f 500000d f:\dg\test.d8 f 500000d f:\dg\test.d8 f 500000

b f:\dg\test.b1b f:\dg\test.b1

扩展名一定要为扩展名一定要为 STST

单位为单位为 KK ,大概,大概 500M500M 容容量量

D—D— 数据文件数据文件B—BIB—BI 文件文件

Page 87: Progress Training         MFG/PRO

www.softspeed.com.hk

9.2 多卷数据库的创建

• 9.2.2 CHAR下的命令:– 假如 ST文件在 /app/test.db下– Prostrct create /app/test.db 或者– Prostrct create /app/test.db /app/test.st

• 9.2.3 Windows下的命令:– 假如 ST文件在 d:\test.db下– Prostrct create d:\test.db 或者– Prostrct create d:\test.db d:\test.st

Page 88: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十 > Database的备份及恢复 10.1 Procopy语句 10.2 Backup语句 10.3 Restore语句

Page 89: Progress Training         MFG/PRO

www.softspeed.com.hk

10.1 Procopy 语句

• Copies an existing database. Use this utility to do any of the following:

• -- Copy a single-volume database to create another single- volume database.

• -- Convert a single-volume database to a multi-volume database structure.

• -- Convert a multi-volume database to a different multi- volume structure.

Page 90: Progress Training         MFG/PRO

www.softspeed.com.hk

10.1 Procopy 语句

• UNIX, Windows:• -----------------------------------------------------------• procopy source-db-name target-db-name • -----------------------------------------------------------

• Example:• -----------------------------------------------------------• procopy d:\testold.db d:\testnew.db • -----------------------------------------------------------

Page 91: Progress Training         MFG/PRO

www.softspeed.com.hk

10.2 Probkup 语句

• Backs up a PROGRESS database (the database and BI files).

• UNIX, Windows:• -----------------------------------------------------------

• probkup [on-line] db-name [incremental] device-name

• -----------------------------------------------------------

Page 92: Progress Training         MFG/PRO

www.softspeed.com.hk

10.2 Probkup 语句

• Sample:– Probkup online d:\test.db d:\bkup\onlinetest1027.db

– Probkup d:\test.db d:\bkup\offlinetest1027.db

此时要在此时要在 test.dbtest.db 在多模式启动在多模式启动下,也就是下,也就是 ERPERP 在正常使用的在正常使用的

情况下才能操作成功情况下才能操作成功

此时要在此时要在 test.dbtest.db 没有没有被启动下才能执行操被启动下才能执行操

作成功作成功

Page 93: Progress Training         MFG/PRO

www.softspeed.com.hk

10.3 Prorest 语句• Restores a full backup of a database.

• UNIX, Windows:• -----------------------------------------------------------• prorest db-name device-name

• Example:– Prorest d:\test.db d:\onlinetest1027.db– Prorest d:\test.db d:\offlinetest1027.db

Page 94: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十一 > Database的启动及常用的实用工具 11.1 Shutdown Database 11.2 Startup Database 11.3 Shutdown Parameter的详解 11.4 Startup Parameter的详解 11.5 Promon实用工具

Page 95: Progress Training         MFG/PRO

www.softspeed.com.hk

11.1 Shutdown Database11.1.1 Proshut.exe d:\test _mprshut.exe d:\test -B 800 -L 500 -pf mfglang.pf –by11.1.2 promon d:\test 回车后

选择 选择 8 8

Page 96: Progress Training         MFG/PRO

www.softspeed.com.hk

11.1 Shutdown Database 选择 选择 2 2 等用户的指令已等用户的指令已全部写入数据库然后就全部写入数据库然后就DownDown掉,这样能保证用户掉,这样能保证用户的数据完整性。 的数据完整性。 选择 选择 3 3 不管用户在做什不管用户在做什么,强制性么,强制性 DownDown掉数据库。掉数据库。

Page 97: Progress Training         MFG/PRO

www.softspeed.com.hk

11.2 Startup Database

11.2.1 _mprosrv.exe d:\test -B 5000 -L 3000 -pf mfglang.pf -S erptest -H hostname -N TCP

Page 98: Progress Training         MFG/PRO

www.softspeed.com.hk

11.3 Shutdown Database 参数详解

_mprshut.exe d:\test.db_mprshut.exe d:\test.db -B 800 -L 1000 -pf mfglang.pf -by-B 800 -L 1000 -pf mfglang.pf -by

Shutdown Shutdown 数据数据库所用的库所用的 Buffer Buffer

大小大小800800 实际大小是实际大小是

800 * 4 K = 800 * 4 K = 3.2KK = 3.2M3.2KK = 3.2M

Shutdown Shutdown 数据数据库所用的库所用的 LOG LOG

大小大小10001000 实际大小是实际大小是

1000 * 4 K = 1000 * 4 K = 4KK = 4M4KK = 4M

代表后面要调代表后面要调用用 .PF.PF 文件作为文件作为参数引入参数引入

Page 99: Progress Training         MFG/PRO

www.softspeed.com.hk

11.4 startup Database 参数详解

_mprosrv.exe d:\test.db _mprosrv.exe d:\test.db -B 5000 -L 3000 -pf mfglang.pf -S erptest -H Hostname -N TCP _-B 5000 -L 3000 -pf mfglang.pf -S erptest -H Hostname -N TCP _

startup startup 数据库数据库所用的所用的 Buffer Buffer

大小大小50005000 实际大小是实际大小是

5000 * 4 K = 5000 * 4 K = 20KK = 20M20KK = 20M

startup startup 数据库数据库The number of entries in The number of entries in the record locking table. the record locking table.

If you specify a value If you specify a value that is not a multiple of that is not a multiple of 32, Progress rounds the 32, Progress rounds the value you specify to the value you specify to the next highest multiple of next highest multiple of

32.32.

代表后面要调代表后面要调用用 .PF.PF 文件作为文件作为参数引入参数引入

主机名主机名

数据库的数据库的服务名服务名

Page 100: Progress Training         MFG/PRO

www.softspeed.com.hk

11.5 Promon 实用工具Starts the database monitor that displays database information.UNIX, Windows:-----------------------------------------------------------promon db-name-----------------------------------------------------------

Page 101: Progress Training         MFG/PRO

www.softspeed.com.hk

• 1用户控制• 2等待和锁定的状态显示• 3块访问情况• 4正被锁定的表及记录• 5数据库活动日志• 6数据库共享资料情况• 7数据库状态情况• 8Shutdown数据库相关

11.5 Promon 实用工具

Page 102: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十二 > Cimload的使用1 . CIMLOAD 文件编写 @@batchload 程序名 /*必要的开头格式,指明要 CIMLOAD的程

序 */ “aaaaa” - - - - “bbb” /*输入字符类型 aaaaa,再同一 UPDATE

的内容情况下再输入四个默认的值,然后再输入字符类型 bbb*/ “ccc” /*在更改了 UPDATE范围的情况下,再输入字

符类型 ccc*/ . /* . 表示退出 */ @@end

Page 103: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十二 > Cimload的使用2 . CIMLOAD 的查错方法与步骤 a. 已执行 36.15.2后,进 36.16.3查看含错误信息 b. 假如有就表示一定含有错误,但显示为 0 也不代表完全正常 c. 当我们看见错误时要查看相对应的组表志,然后对

CIMLOAD 的内容用手工在 MFGPRO 中再输入一次,看错误是否可 以从演,通常的错误是: (1) CIMLOAD 内容含系统不认的字体和符号

(2) 所输入内容的长度超出系统字段的限制 (3) 所输入内容不符系统的规限的,譬如所输入的栏位 要输入合法的通用代码, 但实际输入栏 位输入了 不合法的通用代码,此时我们要先维护好数据库, 加入所必须的内容

Page 104: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十二 > Cimload的使用 d. 当我们没看见错误信息时,则需要对 CIMLOAD 的内容与已

CIMLOAD 的内容作对比,步骤如下: (1)(1) 连接连接 CIMLOADCIMLOAD 的数据库,获得的数据库,获得 CIMLOADCIMLOAD 的的 TABLETABLE 名与名与 UNIQUEINDEXUNIQUEINDEX 的字段名,进入的字段名,进入 PROGRESSPROGRESS 的编辑器键的编辑器键 ””select count(*) from table_nameselect count(*) from table_name ””, , 得到已得到已 CIMLOADCIMLOAD 的数据数目,对比要的数据数目,对比要 CIMLOADCIMLOAD 的条数,假如符合就表示没的条数,假如符合就表示没 错误,假如不符则要做下面动作错误,假如不符则要做下面动作

(2)(2) 在在 PROGRESSPROGRESS 编辑器中键入编辑器中键入”” output tooutput to 文件名文件名

for each table_name:for each table_name: display field_name1 field_name2 field_name.display field_name1 field_name2 field_name. end.”end.” (( 注意:注意:

field_name1+field_name2+field_name=table_namefield_name1+field_name2+field_name=table_name 的的 UNIQUE INDEXUNIQUE INDEX 字段字段 ))

Page 105: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十二 > Cimload的使用 (3) 获取刚才产生的文件,用 EXCEL 打开,并将必要字段进行合

并成一个字段,对要 CIMLOAD 的内容也作相对应的字段合并工作,然后用 EXCEL 的 VLOOKUP 函数对此进行比较得出非相同的内容,就可查出 CIMLOAD 失败的内容

3. 下面讲解一个实例: Sample: for each vp_mstr where (vend = "" or vp_vend >= vend) and (vend1 = "" or vp_vend <= vend1 ) and (part = "" or vp_part >= part) and (part1 = "" or vp_part <= part1 ) : usection = TRIM ( string(year(TODAY)) + string(MONTH(TODAY)) + string(DAY(TODAY))) + trim(STRING(TIME)) + trim(string(RANDOM(1,100))) .

Page 106: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十二 > Cimload的使用 << 接上页 >>output to value( trim(usection) + ".txt") . v_price1 = vp_q_price .v_price = vp_q_price *(100 + v_percent) / 100 .v_price = v_price + v_values . /* + - Price */v_price = rounttook ( v_price ,v_decimal ).display if trim(vp_part) = "" then " - " else " " + """" + trim(vp_part) + """" format "x(21)" if trim(vp_vend) = "" then " - " else " " + """" + trim(vp_vend) + """" format "x(11)" if trim(vp_vend_part) = "" then " - " else " " + """" + trim(vp_vend_part) + """" format "x(33)" skipskip if trim(vp_um) = "" then " - " else " " + """" + trim(vp_um) + """" + " " format "x(5)"if trim(vp_um) = "" then " - " else " " + """" + trim(vp_um) + """" + " " format "x(5)" vp_vend_leadvp_vend_lead if vp_tp_use_pct = yes then " Y " else " N " if vp_tp_use_pct = yes then " Y " else " N " vp_tp_pctvp_tp_pct

Page 107: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十二 > Cimload的使用 << 接上页 >>if trim(vp_curr) = "" then " - " else " " + """" + trim(vp_curr) + """" format "x(6)"v_pricev_effdatevp_q_qtyif trim(vp_pr_list) = "" then " - " else " " + """" + trim(vp_pr_list) + """" format "x(11)"if trim(vp_mfgr) = "" then " - " else " " + """" + trim(vp_mfgr) + """" format "x(11)"if trim(vp_mfgr_part) = "" then " - " else " " + """" + trim(vp_mfgr_part) + """" format "x(21)"if trim(vp_comment) = "" then " - " else " " + """" + trim(vp_comment) + """" format "x(43)"skip"." with no-box no-labels width 300.output close. input from value ( usection + ".txt") .input from value ( usection + ".txt") . output to value ( usection + ".cim") .output to value ( usection + ".cim") . {gprun.i ""ppvpmt.p""}{gprun.i ""ppvpmt.p""} input close.input close. output close.output close. unix silent value("rm -rf " + trim(usection) + ".txt"). unix silent value("rm -rf " + trim(usection) + ".txt"). unix silent value("rm -rf " + trim(usection) + ".cim").unix silent value("rm -rf " + trim(usection) + ".cim").

Page 108: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十三 > 举例讲解标准的报表、维护、查询程序

12.1 标准的报表程序 参见 ppptrp08.p 库存明细 12.2 标准的查询程序 参见 ppptiq04.p 零件数据查询

Page 109: Progress Training         MFG/PRO

www.softspeed.com.hk

< 十四 > Progress 的实用编程技巧 (Creating Alert Boxes)(Creating Alert Boxes)

Syntax:

Sample:

MESSAGE msg-string [VIEW-AS ALERT-BOX][BUTTONS YES-NO/YES-NO-CANCEL/OK/OK-CANCEL][TITLE string] [UPDATE] field AS LOGICAL/LIKE field ]

Message " Save file" VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO-CANCEL Title "SAVE AS" Update aa as logical . display aa.

MessageMessageQuestionQuestionInformationInformationErrorErrorWarningWarning

MESSAGE msg-string

Page 110: Progress Training         MFG/PRO

www.softspeed.com.hk

(Exercise 1 ) (Exercise 1 )

Question 1:

Sample:

Answer:

Allow the user to enter their full name, Create a monogramAnd display it to the user.

First Name Last Name Middle Name Monogram---------- ---------- ----------- -----------Jane Doe X JXD

J DX

Define variable lname as char format "x(15)" label "Last Name".Define variable fname as char format "x(25)" label "First Name".Define Variable mi as char format "x(15)" label "Middle Name".Define variable monogram as char format "x(3)".Set fname lname mi.Assign monogram = CAPS (substring(fname,1,1) + substring(mi,1,1) + substring(lname ,1,1)).Display monogram .

How To Use FunctionHow To Use FunctionCAP / SubstringCAP / Substring

Page 111: Progress Training         MFG/PRO

www.softspeed.com.hk

(Exercise 2 ) (Exercise 2 )

Question:

Sample:

Answer:

User input a date , Calculate last date of this month.

Input : 10/23/01 02/10/01 12/04/01Output : 31 28 31

Define variable aa as date label "Date".

Define variable lastdate as integer label "Last Date".

Aa = today.

update aa .

If month(aa) = 12 then

LastDate = Day( Date( 1,1,Year(aa) + 1 ) - 1).

Else

LastDate = Day( Date(month(aa) + 1,1,Year(aa)) - 1).

Display Lastdate.

How To Use FunctionHow To Use FunctionDate / Today /Month Date / Today /Month Year / Day / +Year / Day / +

Page 112: Progress Training         MFG/PRO

www.softspeed.com.hk

(Exercise 2 ) (Exercise 2 )

Question:

Answer:

User input a date , display day of week.

Define variable aa as date init today label "Date" .

Define variable bb as char .

Update aa.

case weekday(aa).

when 1 then bb = "Sunday" .

when 2 then bb = "Monday".

when 3 then bb = "Tuesday".

when 4 then bb = "Wednesday".

when 5 then bb = "Thursday".

when 6 then bb = "Friday".

otherwise bb = "Saturday".

end case.

display bb label "Week".

How To UseHow To UseCaseCase

Page 113: Progress Training         MFG/PRO

www.softspeed.com.hk

((Sql Sql 标准语法 标准语法 VS ProgressVS Progress 语法语法 )) 1. 1. SELECT table1.field1, table1.field2, table2.field1, table2.field2, table3.field1, table3.field2 SELECT table1.field1, table1.field2, table2.field1, table2.field2, table3.field1, table3.field2 FROM table1, table2, table3 FROM table1, table2, table3 WHERE table1.field1=table2.field1 and table2.field1=table3.field1WHERE table1.field1=table2.field1 and table2.field1=table3.field1 and (table1.field2 > 1000 or table2.field2 like '%abc%' or table3.field2 in (1,5,8,9)) and (table1.field2 > 1000 or table2.field2 like '%abc%' or table3.field2 in (1,5,8,9)) ORDER BY table1.field1ORDER BY table1.field1

for each table1,for each table1, each table2,each table2, each table3 where table1.field1=table2.field1 and table2.field1=table3.field1each table3 where table1.field1=table2.field1 and table2.field1=table3.field1 and (table1.field2 > 1000 or table2.field2 matches "*" + "abc" + "*" or and (table1.field2 > 1000 or table2.field2 matches "*" + "abc" + "*" or (table3.field2 = 1 or table3.field2 = 5 or table3.field2 = 8 or table3.field2 = 9 ) )(table3.field2 = 1 or table3.field2 = 5 or table3.field2 = 8 or table3.field2 = 9 ) ) no-lock break by table1.field1 :no-lock break by table1.field1 : display display table1.field1table1.field1 table1.field2table1.field2 table2.field1table2.field1 table2.field2table2.field2 table3.field1table3.field1 table3.field2 .table3.field2 . end. /* for each table1 */end. /* for each table1 */

Page 114: Progress Training         MFG/PRO

www.softspeed.com.hk

(Sql (Sql 标准语法 标准语法 VS Progress VS Progress 语法语法 ))<<example:>><<example:>>

for each pt_mstr,for each pt_mstr, each prh_hist,each prh_hist, each tr_hist where pt_part = prh_part and prh_part = tr_parteach tr_hist where pt_part = prh_part and prh_part = tr_part and pt_desc1 matches '*' + '°×' + '*' and pt_desc1 matches '*' + '°×' + '*' no-lock :no-lock : dispdisp pt_partpt_part pt_desc1pt_desc1 prh_nbrprh_nbr prh_receiverprh_receiver prh_rcvdprh_rcvd tr_nbrtr_nbr tr_trnbrtr_trnbr tr_typetr_type tr_qty_chgtr_qty_chg ..end .end .

Page 115: Progress Training         MFG/PRO

www.softspeed.com.hk

((SqlSql 标准语法 标准语法 VS ProgressVS Progress 语法语法 )) 2.2. 分组分组 SELECT table1.field1, table2.field1, SUM(table1.field2), AVG(table2.field2) SELECT table1.field1, table2.field1, SUM(table1.field2), AVG(table2.field2) FROM table1, table2FROM table1, table2 WHERE table1.field1=table2.field1WHERE table1.field1=table2.field1 GROUP BY table1.field1, table2.field1GROUP BY table1.field1, table2.field1

for each table1,for each table1, each table2 where table1.field1=table2.field1 each table2 where table1.field1=table2.field1 no-lockno-lock break by table1.field1 by table2.field1 :break by table1.field1 by table2.field1 : ACCUM table1.field2 (TOTAL BY table1.field1 by table2.field1 ).ACCUM table1.field2 (TOTAL BY table1.field1 by table2.field1 ). ACCUM table2.field2 (AVG BY table1.field1 by table2.field1 ).ACCUM table2.field2 (AVG BY table1.field1 by table2.field1 ). if last-of(table2.field1) then do:if last-of(table2.field1) then do: display display table1.field1 table1.field1 table2.field1table2.field1 (accumulate total by table2.field1 by table1.field2 ) label "SUM"(accumulate total by table2.field1 by table1.field2 ) label "SUM" (accumulate avg by table2.field1 by table2.field2 ) label "AVG" .(accumulate avg by table2.field1 by table2.field2 ) label "AVG" . end . end . end .end .

Page 116: Progress Training         MFG/PRO

www.softspeed.com.hk

((SqlSql 标准语法 标准语法 VS ProgressVS Progress 语法语法 ))<< Sample >>:<< Sample >>:for each pt_mstr,for each pt_mstr, each prh_hist,each prh_hist, each tr_hist where pt_part = prh_part and prh_part = tr_parteach tr_hist where pt_part = prh_part and prh_part = tr_part and tr_part = '0001-0000'and tr_part = '0001-0000' no-lockno-lock break by prh_receiver by tr_nbr :break by prh_receiver by tr_nbr :

ACCUM prh_rcvd (TOTAL BY prh_receiver by tr_nbr ).ACCUM prh_rcvd (TOTAL BY prh_receiver by tr_nbr ). ACCUM tr_qty_chg (AVG by prh_receiver by tr_nbr ).ACCUM tr_qty_chg (AVG by prh_receiver by tr_nbr ). if last-of( tr_nbr ) then do :if last-of( tr_nbr ) then do : dispdisp

prh_receiverprh_receiver tr_nbrtr_nbr (accumulate total by tr_nbr prh_rcvd ) label "SUM"(accumulate total by tr_nbr prh_rcvd ) label "SUM" (accumulate avg by tr_nbr tr_qty_chg ) label "AVG" .(accumulate avg by tr_nbr tr_qty_chg ) label "AVG" . .. end.end.end .end .

Page 117: Progress Training         MFG/PRO

Add Month 2000

Thank you !

SoftSpeed Consultant SoftSpeed Consultant LtdLtd

Page 118: Progress Training         MFG/PRO

www.softspeed.com.hk