Alaska Software Inc. - can a :datalink "lock" a field ?
Username: Password:
AuthorTopic: can a :datalink "lock" a field ?
AUGE_OHRcan a :datalink "lock" a field ?
on Wed, 29 Aug 2007 18:24:44 +0200
hi,

i have a strange Problem with SLEpic :datalink.

on a XbpDialog i have some SLEpic.
*** snip ***
 this Windows hold some SLEpic with :datalink

oDLGEDIT := MARKEDIT(oDlg,aoChild,aDLGOWNER)
AADD(aDLGOWNER,oDLGEDIT)
....
FUNCTION MARKEDIT(oMainDlg,aoChild,aDLGOWNER)
oXbp              := SLEPIC():new(oXbp2 ....)
oXbp:bufferLength := 12
oXbp:picture      := "99:99:99:999"
oXbp:tabStop      := .T.
oXbp:dataLink := {| x | IF(PCOUNT() == 0,;
                                         SEC2HMS(WM9MARK->SNIPIN),;
                                         WM9MARK->SNIPIN := HMS2SEC(x))}
oXbp:create()   //:setData()
AADD(aEditControls,oXbp)
*** eof ***

In same Thread on other place i do a "normal" REPLACE
on some fields, but they are not all filled?
*** snip ***
   APPEND BLANK
   nMarkRec := WM9MARK->(RECNO())        STATIC

   IF WM9MARK->(DBRLOCK(nMarkRec))
 works
        WM9MARK->W9VIDEO  := cFile

 WHY does this not(?) work ?! ... "blocked" by :datalink ???
 DBF = 0
*       WM9MARK->SNIPIN   := INT(nPosi)
        REPLACE WM9MARK->SNIPIN WITH INT(nPosi)
 works
         WM9MARK->DURATION := SP_Duration()
 now unlock
         WM9MARK->(DBRUNLOCK(nMarkRec))
          SKIP 0
          GOTO(nMarkRec)
 seem to be ok, but DBF is not
MSGBOX("Posi IN "+cPosi+" "+STR(nPosi))
*** eof ***
only those field where i have a SLEpic :datalink are not filled ?!

greetings by OHR
Jimmy
James Loughner Re: can a :datalink "lock" a field ?
on Wed, 29 Aug 2007 13:00:12 -0400
Never saw this. SLEPic does no locking of any kind. It is up to the
Programmer to assure a lock is in place before executing a :GetData() on
a data linked field. This is just like the XBPSLE class in this regard.
Setting a datalink is simply assigning a code block to the datalink
ivar. There are no side effects.

Jim

AUGE_OHR wrote:
> hi,
> 
> i have a strange Problem with SLEpic :datalink.
> 
> on a XbpDialog i have some SLEpic.
> *** snip ***
>  this Windows hold some SLEpic with :datalink
> 
> oDLGEDIT := MARKEDIT(oDlg,aoChild,aDLGOWNER)
> AADD(aDLGOWNER,oDLGEDIT)
> ....
> FUNCTION MARKEDIT(oMainDlg,aoChild,aDLGOWNER)
> oXbp              := SLEPIC():new(oXbp2 ....)
> oXbp:bufferLength := 12
> oXbp:picture      := "99:99:99:999"
> oXbp:tabStop      := .T.
> oXbp:dataLink := {| x | IF(PCOUNT() == 0,;
>                                          SEC2HMS(WM9MARK->SNIPIN),;
>                                          WM9MARK->SNIPIN := HMS2SEC(x))}
> oXbp:create()   //:setData()
> AADD(aEditControls,oXbp)
> *** eof ***
> 
> In same Thread on other place i do a "normal" REPLACE
> on some fields, but they are not all filled?
> *** snip ***
>    APPEND BLANK
>    nMarkRec := WM9MARK->(RECNO())        STATIC
> 
>    IF WM9MARK->(DBRLOCK(nMarkRec))
>  works
>         WM9MARK->W9VIDEO  := cFile
> 
>  WHY does this not(?) work ?! ... "blocked" by :datalink ???
>  DBF = 0
> *       WM9MARK->SNIPIN   := INT(nPosi)
>         REPLACE WM9MARK->SNIPIN WITH INT(nPosi)
>  works
>          WM9MARK->DURATION := SP_Duration()
>  now unlock
>          WM9MARK->(DBRUNLOCK(nMarkRec))
>           SKIP 0
>           GOTO(nMarkRec)
>  seem to be ok, but DBF is not
> MSGBOX("Posi IN "+cPosi+" "+STR(nPosi))
> *** eof ***
> only those field where i have a SLEpic :datalink are not filled ?!
> 
> greetings by OHR
> Jimmy
> 
> 
>
AUGE_OHRRe: can a :datalink "lock" a field ?
on Wed, 29 Aug 2007 21:24:41 +0200
hi,

> Never saw this. SLEPic does no locking of any kind. It is up to the
> Programmer to assure a lock is in place before executing a :GetData() on
> a data linked field. This is just like the XBPSLE class in this regard.
> Setting a datalink is simply assigning a code block to the datalink
> ivar. There are no side effects.

here more code :
*** snip ***
 this Windows hold some SLEpic with :datalink

oDLGEDIT := MARKEDIT(oDlg,aoChild,aDLGOWNER)
AADD(aDLGOWNER,oDLGEDIT)
....
FUNCTION MARKEDIT(oMainDlg,aoChild,aDLGOWNER)
oXbp              := SLEPIC():new(oXbp2 ....)
oXbp:bufferLength := 12
oXbp:picture      := "99:99:99:999"
oXbp:tabStop      := .T.
oXbp:dataLink := {| x | IF(PCOUNT() == 0,;
                             SEC2HMS(WM9MARK->SNIPIN),;
                             WM9MARK->SNIPIN := HMS2SEC(x))}
oXbp:create()   //:setData()
AADD(aEditControls,oXbp)
*** eof ***

i try to use REPLACE in SNAPMARK() before MARKREFESH()
all are in same Thread and DBF is on SELECT 5 and proper open.

*** snip ***
CASE nKey == xbeK_F5                                   "mark" IN
   IF aoChild[CH_WMP]:PlayState >= wmppsPaused
      
       APPEND new record
      
      IF SNAPMARK(aoChild,.T.,.F.,aDLGOWNER)
         SELECT 5                                      WM9MARK

 it works only if i enable (visible := .T.) Window, WHY ???

         IF aDLGOWNER[DI_DLGEDIT]:isvisible()          oDLGEDIT
            
             refresh data and show it
            
            MARKREFESH(aDLGOWNER[DI_DLGEDIT]:cargo[2][IOE_SLE])
         ENDIF

*************************************************************.
PROCEDURE MARKREFESH(editcontrols)
   WM9MARK->(DBGOTO(nMarkRec))   fieldwide STATIC
   REF2GETS(editcontrols)   refresh data
RETURN

PROCEDURE REF2GETS(editcontrols)
LOCAL n
LOCAL LenGets := LEN(editcontrols)
   FOR n := 1 TO LenGets
      editcontrols[n]:setdata()
      editcontrols[n]:show()
   NEXT
RETURN

FUNCTION SNAPMARK(aoChild,lIn,lOut,aDLGOWNER)
LOCAL Retvar  := .F.
LOCAL nPosi
LOCAL cPosi
LOCAL OldSele := SELECT()
LOCAL cFile     := FILEONLY(SP_Playlast())
LOCAL aSize   := aoChild[CH_WMP]:currentsize()

STATIC lInflag  := .F.
STATIC lOutflag := .T.

   nPosi := aoChild[CH_WMP]:Controls:CurrentPosition
   IF nPosi < 1
      Retvar := .F.
      MSGBOX("Position wrong "+STR(nPosi))
   ENDIF
   cPosi := SEC2HMS(nPosi)
 all ok
MSGBOX("Posi "+cPosi+" "+STR(nPosi))

   DO CASE
      CASE lIn .AND. .NOT. lOut
         IF lInflag
         ELSE
            IF lOutflag
               SELECT 5                                      WM9MARK
               APPEND BLANK

               nMarkRec := WM9MARK->(RECNO())  fieldwide STATIC
               IF WM9MARK->(DBRLOCK(nMarkRec))
                   works
                  WM9MARK->W9VIDEO  := cFile

 WHY does this not(?) work ?! ... "blocked" by :datalink ???

*                  WM9MARK->SNIPIN   := INT(nPosi)
                  REPLACE WM9MARK->SNIPIN WITH INT(nPosi)

                   works
                  WM9MARK->DURATION := SP_Duration()
                   now unlock
                  WM9MARK->(DBRUNLOCK(nMarkRec))

                   be shure it is writtento DBF
                  COMMIT
                  SKIP 0
                  GOTO(nMarkRec)

 variable seem to be ok, but DBF not ???
MSGBOX("Posi IN "+cPosi+" "+STR(nPosi)+" "+STR(WM9MARK->SNIPIN))

               ELSE
                  MSGBOX("can NOT lock "+LTRIM(STR(nMarkRec)))
                  Retvar := .F.
               ENDIF
...
*** eof ***
i can see Value in Msgbox() but i can not find them in DBF ?
only these :datalink fields are empty(), other are working !!!

it will be in DBF if i show() (visible := .T.) "Editwindow" which
hold the SLEpic and the :datalink in aDLGOWNER[DI_DLGEDIT]
(= oDLGEDIT )

while i do only a :setdata() in REF2GET() i do not understand
what is going wrong here with REPLACE / :datalink ?

greetings by OHR
Jimmy
James Loughner Re: can a :datalink "lock" a field ?
on Wed, 29 Aug 2007 17:52:14 -0400
Move you msgbox to before the goto. You have changed record.

By the way why do you use SELECT 5 SELECT ("WM9MARK") is much safer.

You really need to get away from numbered areas.

Jim

AUGE_OHR wrote:
> hi,
> 
>> Never saw this. SLEPic does no locking of any kind. It is up to the
>> Programmer to assure a lock is in place before executing a :GetData() on
>> a data linked field. This is just like the XBPSLE class in this regard.
>> Setting a datalink is simply assigning a code block to the datalink
>> ivar. There are no side effects.
> 
> here more code :
> *** snip ***
>  this Windows hold some SLEpic with :datalink
> 
> oDLGEDIT := MARKEDIT(oDlg,aoChild,aDLGOWNER)
> AADD(aDLGOWNER,oDLGEDIT)
> ....
> FUNCTION MARKEDIT(oMainDlg,aoChild,aDLGOWNER)
> oXbp              := SLEPIC():new(oXbp2 ....)
> oXbp:bufferLength := 12
> oXbp:picture      := "99:99:99:999"
> oXbp:tabStop      := .T.
> oXbp:dataLink := {| x | IF(PCOUNT() == 0,;
>                              SEC2HMS(WM9MARK->SNIPIN),;
>                              WM9MARK->SNIPIN := HMS2SEC(x))}
> oXbp:create()   //:setData()
> AADD(aEditControls,oXbp)
> *** eof ***
> 
> i try to use REPLACE in SNAPMARK() before MARKREFESH()
> all are in same Thread and DBF is on SELECT 5 and proper open.
> 
> *** snip ***
> CASE nKey == xbeK_F5                                   "mark" IN
>    IF aoChild[CH_WMP]:PlayState >= wmppsPaused
>       
>        APPEND new record
>       
>       IF SNAPMARK(aoChild,.T.,.F.,aDLGOWNER)
>          SELECT 5                                      WM9MARK
> 
>  it works only if i enable (visible := .T.) Window, WHY ???
> 
>          IF aDLGOWNER[DI_DLGEDIT]:isvisible()          oDLGEDIT
>             
>              refresh data and show it
>             
>             MARKREFESH(aDLGOWNER[DI_DLGEDIT]:cargo[2][IOE_SLE])
>          ENDIF
> 
> *************************************************************.
> PROCEDURE MARKREFESH(editcontrols)
>    WM9MARK->(DBGOTO(nMarkRec))   fieldwide STATIC
>    REF2GETS(editcontrols)   refresh data
> RETURN
> 
> PROCEDURE REF2GETS(editcontrols)
> LOCAL n
> LOCAL LenGets := LEN(editcontrols)
>    FOR n := 1 TO LenGets
>       editcontrols[n]:setdata()
>       editcontrols[n]:show()
>    NEXT
> RETURN
> 
> FUNCTION SNAPMARK(aoChild,lIn,lOut,aDLGOWNER)
> LOCAL Retvar  := .F.
> LOCAL nPosi
> LOCAL cPosi
> LOCAL OldSele := SELECT()
> LOCAL cFile     := FILEONLY(SP_Playlast())
> LOCAL aSize   := aoChild[CH_WMP]:currentsize()
> 
> STATIC lInflag  := .F.
> STATIC lOutflag := .T.
> 
>    nPosi := aoChild[CH_WMP]:Controls:CurrentPosition
>    IF nPosi < 1
>       Retvar := .F.
>       MSGBOX("Position wrong "+STR(nPosi))
>    ENDIF
>    cPosi := SEC2HMS(nPosi)
>  all ok
> MSGBOX("Posi "+cPosi+" "+STR(nPosi))
> 
>    DO CASE
>       CASE lIn .AND. .NOT. lOut
>          IF lInflag
>          ELSE
>             IF lOutflag
>                SELECT 5                                      WM9MARK
>                APPEND BLANK
> 
>                nMarkRec := WM9MARK->(RECNO())  fieldwide STATIC
>                IF WM9MARK->(DBRLOCK(nMarkRec))
>                    works
>                   WM9MARK->W9VIDEO  := cFile
> 
>  WHY does this not(?) work ?! ... "blocked" by :datalink ???
> 
> *                  WM9MARK->SNIPIN   := INT(nPosi)
>                   REPLACE WM9MARK->SNIPIN WITH INT(nPosi)
> 
>                    works
>                   WM9MARK->DURATION := SP_Duration()
>                    now unlock
>                   WM9MARK->(DBRUNLOCK(nMarkRec))
> 
>                    be shure it is writtento DBF
>                   COMMIT
>                   SKIP 0
>                   GOTO(nMarkRec)
> 
>  variable seem to be ok, but DBF not ???
> MSGBOX("Posi IN "+cPosi+" "+STR(nPosi)+" "+STR(WM9MARK->SNIPIN))
> 
>                ELSE
>                   MSGBOX("can NOT lock "+LTRIM(STR(nMarkRec)))
>                   Retvar := .F.
>                ENDIF
> ...
> *** eof ***
> i can see Value in Msgbox() but i can not find them in DBF ?
> only these :datalink fields are empty(), other are working !!!
> 
> it will be in DBF if i show() (visible := .T.) "Editwindow" which
> hold the SLEpic and the :datalink in aDLGOWNER[DI_DLGEDIT]
> (= oDLGEDIT )
> 
> while i do only a :setdata() in REF2GET() i do not understand
> what is going wrong here with REPLACE / :datalink ?
> 
> greetings by OHR
> Jimmy 
> 
>
Pablo BotellaRe: can a :datalink "lock" a field ?
on Wed, 29 Aug 2007 23:25:21 +0200
Hi Jimmy,

I suspect the trouble can be that the SLE have the previous value in the buffer and is overwritting 
the value assigned from your SNAPMARK() , maybe you will need to reload the buffer of the SLE just after call or inside SNAPMARK() 

Can you see the value 2 times in this MsgBox inside SNAPMARK()?
MSGBOX("Posi IN "+cPosi+" "+STR(nPosi)+" "+STR(WM9MARK->SNIPIN))

If  Yes, the SLE is overwritting your value with a previous buffer, if No something horrible seems to be happening 

Regards,
Pablo Botella