Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Attempted the correction..however...
Message
De
16/08/2001 11:13:50
N. Lea
Nic Cross Enterprises
Valencia, Californie, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00544703
Message ID:
00544731
Vues:
13
After thinking about it, I have seen the error of my ways! I should have not even issued the -1 because of the scan filter, regardless of the RECNO()<>nRecordNo.

I should have just issued the following command:


WITH THISFORM
lContinue = .F.

&& STORES INFO FROM DATABASE
nNewPrintOrder = ROUND(VAL(SPACE(5)),0)
nOldValue = report1.printorder
nRecordNo = RECNO()

DO FORM gl_pnl_neworder

GOTO nRecordNo
REPLACE report1.printorder WITH nNewPrintOrder

IF lContinue = .T.

IF nNewPrintOrder >= nOldValue
SELECT report1
nResetPrintOrder = 1
SCAN FOR printorder <= nNewPrintOrder AND RECNO()<>nRecordNo
REPLACE printorder WITH nResetPrintOrder
nResetPrintOrder = nResetPrintOrder + 1
ENDSCAN
ELSE
SELECT report1
nResetPrintOrder = nNewPrintOrder + 1
SCAN FOR printorder >= nNewPrintOrder AND RECNO()<>nRecordNo
REPLACE printorder WITH nResetPrintOrder
nResetPrintOrder = nResetPrintOrder + 1
ENDSCAN
ENDIF


.grdPnLChart.Refresh()
ENDIF

THISFORM.mRecalculateForm()
GO TOP
ENDWITH


>As I noticed from your code, you are not using REPLACE with IN myAlias clause. Your problem may be related to that.
>Try do your replaces like:
>
>REPLACE report1.printorder WITH -1 IN report1
>
>
>>I attempted the correction with the REPLACE FOR command; however, it did not seem to work. It seems as if I do need the SCAN....ENDSCAN code. My printorder still is still off.
>>
>>>>I am running into a problem with my code. It works, but it does not work. This code seems to be fine when I need to move any printorder # < 8. However, when I attempt to move anything greater than that, it works like this. I move 13 and change it's number to 10.
>>>>
>>>>8
>>>>9
>>>>10
>>>>11
>>>>12
>>>>13
>>>>
>>>>8
>>>>9
>>>>10
>>>>11
>>>>12
>>>>12
>>>>13
>>>>
>>>>I just do not understand why it only works under certain condition. Any suggestions? Thanks for any help!
>>>>
>>>>
>>>>
>>>Two obvious observations: you don't need to use FILTER command in your replace. Just do replace FOR.
>>>You probably don't need to use scan at all too, just use REPLACE FOR syntax again. It would be faster, easier to follow and would not contain problems...
>>>Or at least don't use recno() in scan condition.
>>>
>>>
>>>
>>>>

>>>>WITH THISFORM
>>>> lContinue = .F.
>>>>
>>>> **--STORES INFO FROM TABLE--**
>>>> nNewPrintOrder = ROUND(VAL(SPACE(3)),0) && Stores new value
>>>> nOldValue = report1.printorder
>>>> nRecordNo = RECNO()
>>>>
>>>> ** MARKS RECORD TO MOVE **
>>>> REPLACE report1.printorder WITH -1
>>>>
>>>> ** THIS FORM BRINGS OVER nNewPrintOrder INTO SPACE VARIABLE **
>>>> DO FORM gl_pnl_neworder
>>>>
>>>> ** REPLACES -1 RECORD WITH NEW VALUE FROM nNewPrintOrder **
>>>> SELECT report1
>>>> SET FILTER TO printorder = -1
>>>> REPLACE ALL printorder WITH nNewPrintOrder
>>>> SET FILTER TO
>>>>
>>>> IF lContinue = .T.
>>>> ** IF NEW # IS GREATER THAN OLD # DO SCAN 1 **
>>>> IF nNewPrintOrder > nOldValue
>>>> SELECT report1
>>>> nResetPrintOrder = 1
>>>> SCAN FOR printorder <= nNewPrintOrder AND RECNO()<>nRecordNo
>>>> REPLACE printorder WITH nResetPrintOrder
>>>> nResetPrintOrder = nResetPrintOrder + 1
>>>> ENDSCAN
>>>> ELSE
>>>> ** IF NEW # IS LESS THAN OLD # DO SCAN 1 **
>>>> SELECT report1
>>>> nResetPrintOrder = nNewPrintOrder + 1
>>>> SCAN FOR printorder >= nNewPrintOrder AND RECNO()<>nRecordNo
>>>> REPLACE printorder WITH nResetPrintOrder
>>>> nResetPrintOrder = nResetPrintOrder + 1
>>>> ENDSCAN
>>>> ENDIF
>>>> .grdPnLChart.Refresh()
>>>> GO TOP
>>>> ENDIF
>>>>
>>>>ENDWITH
>>>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform