50
Chapter 6: Programming Examples
RunDate [ 1 ] : =
1 2 ;
RunDate [ 2 ] : =
2 4 ;
{ W r i t e new d a t e
t o r u n t o SG
−
L o c k w i t h p r o d u c t ABC }
RC: = S g l W r i t e D a t a ( PROD_ABC_ID , RUN_DATE_ADR,
RUN_DATE_CNT , Addr ( RunDate ) ;
i f ( RC <> SGL_SUCCESS ) t h e n
b e g i n
{ no SG
−
L o c k f o u n d ! ! }
Memo1 . T e x t : =
’ S g l W r i t e D a t a :
E r r o r !
’ +
c h a r ( $0D ) + c h a r ( $0A ) ;
end ;
{ new d a t e
s u c c e s s f u l l y
w r i t t e n ,
l e t s do t h e
n e x t
t h i n g . . .
}
end ;
6.5.3 Visual Basic
’ The
f i l e SGLW32 . BAS h a s t o b e i n c l u d e d
i n
t h e
p r o j e c t
’ t o e n s u r e
t h a t
a l l SG
−
L o c k f u n c t i o n s and c o n s t a n t s
’ a r e d e c l a r e d
! ! !
’ I n t h e c a s e a SG
−
L o c k u s e r
p r o t e c t s more t h a n 1
’ a p p l i c a t i o n / p r o d u c t , h e s h o u l d g i v e e a c h o f
i t a
’ u n i q u e
p r o d u c t ID . Then
i t s
v e r y e a s y t o
d i s t i n g u i s h
’ t h e SG
−
L o c k s
f o r e a c h p r o d u c t .
P u b l i c C o n s t PROD_ABC_ID As Long = 1
’ a d d r e s s e w h e r e d a t e
i s
s t o r e d
i n SG
−
L o c k
P u b l i c C o n s t RUN_DATE_ADR As Long = 10
’ d a t e
s t o r e d
a s y e a r / m o n t h / d a y ( 3 DWords )
P u b l i c C o n s t RUN_DATE_CNT As Long = 3
P r i v a t e Sub B u t t o n S e a r c h S G L o c k _ C l i c k ( )
Dim Rc As Long
’ R e t u r n C o d e
Dim RunDate ( 0 t o 2 ) As Long
’ d a t e
s t o r a g e
RunDate ( 0 ) = 2005
’ new r u n d a t e
RunDate ( 1 ) = 12
RunDate ( 2 ) = 24
’ W r i t e new d a t e
t o r u n t o SG
−
L o c k w i t h p r o d u c t ABC
Rc = S g l W r i t e D a t a ( PROD_ABC_ID , RUN_DATE_ADR,
RUN_DATE_CNT , RunDate ( )
)
S e l e c t Case Rc
Содержание SG-Lock
Страница 2: ......
Страница 22: ......
Страница 60: ......
Страница 62: ...56 Chapter 7 Technical Data Notes ...
Страница 63: ...Chapter 7 Technical Data 57 ...