Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error Subscript is outside defined Range
Message
De
14/03/2013 13:19:13
 
 
À
14/03/2013 11:46:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01568322
Message ID:
01568397
Vues:
40
>Following line Generates Error, when I take the PS File (The PS file is attached). It is working fine when the Value of lnPageCount is 6, but when i take the Sample file attached with this mail , which has lnPageCount=3. It gives error at
>
>Filled=Filled+occoupiedrange(I+1) (Second Instance)

And what does the Debugger tell you the value of I is when that happens? Use the Debugger to figure this out.

Tamar

>
>
>T1=TIME()
>Clear
>SET DELETED ON
>lcStr = filetostr('1021165156.ps')
>lnPOS = At("%%Pages:",lcStr)
>lcPageCount = alltrim(substr(lcStr, lnPOS, 12))
>lnPageCount = VAL(STRTRAN(lcPageCount,'%%Pages:',''))
>
>IF lnPageCount>2
>DIMENSION occoupiedrange(lnPageCount)
>DIMENSION unoccoupiedrange(lnPageCount)
>
>Local lcFile, lcText
>m.lcFile = [1021165156.ps]
>Create Cursor Dummy (PS c(254), pos i,pageno n(2))
>Append From (m.lcFile) Sdf
>
>SCAN
>IF Getwordnum(PS, Getwordcount(PS)) = [x] .OR. ;
>Getwordnum(PS, Getwordcount(PS)) = [y] .OR. ;
>Getwordnum(PS, Getwordcount(PS)) = [L] .OR. ;
>Getwordnum(PS, Getwordcount(PS)) = [w]
>
>m.lcText = Getwordnum(PS, Getwordcount(PS) - 1) && The second last word
>IF Len(Chrtran(m.lcText, [1234567890], [])) = 0 && lcText contains only digits
>Replace pos With Val(m.lcText)
>Endif
>ENDIF
>ENDSCAN
>   
>   
>   
>FOR I= 1 TO lnPageCount
>CURTEXT='%%Page: '+ALLTRIM(STR(I))+' '+ALLTRIM(STR(I))
>NeXTTEXT='%%Page: '+ALLTRIM(STR(I+1))+" "+ALLTRIM(STR(I+1))
>
>LOCATE FOR ALLTRIM(PS)=curtext
>SCAN WHILE ALLTRIM(ps)<>nexttext OR EOF()=.T.
>REPLACE pageno WITH I
>ENDSCAN
>SELECT MIN(Pos) FROM Dummy WHERE Pageno=I AND Pos>20 INTO ARRAY X
>SELECT MAX(Pos) FROM Dummy WHERE Pageno=I INTO ARRAY Y
>
>STORE Y-X+1 TO Occoupiedrange(I)
>STORE (x) TO unoccoupiedrange(I)
>STORE (x-20) TO unoccoupiedrange(I)
>ENDFor                                                                                                                                                                                                                                                 
>
>
>FOR I=2 TO (lnPageCount-1)
>Blank=unoccoupiedrange(I)
>Filled=occoupiedrange(I+1)
>
>DO WHILE Blank>=Filled
>NEXTTEXT='%%Page: '+ALLTRIM(STR(I+1))+" "+ALLTRIM(STR(I+1))
>LOCATE FOR ps=NeXTTEXT
>Skip-1 
>Replace ps WITH NeXTTEXT
>SKIP
>Prefixmul= ALLTRIM(STR((Occoupiedrange(I)/68.7),18,2))
>Replace ps WITH '0 -72 &Prefixmul mul translate'
>WAIT WINDOW I
>Filled=Filled+occoupiedrange(I+1) && Generates Error
>WAIT WINDOW I
>I=I+1
>ENDDO
>ENDFOR
>ENDIF
>SELECT Dummy
>set textmerge On
>>>SET TEXTMERGE TO myfile.ps noshow 
>>>scan
>>>\\ << tRIM(pS) >>
>>>\
>>>endscan
>>>set textmerge To
>>>set textmerge off
>>>
>>>T2=TIME()
>>>WAIT WINDOW T2
>>>WAIT WINDOW t1
>>>
>
>
>
>
>
>
>Kinldy Help
>
>
>
>>>Using the following code i am getting error as Error Subscript is outside defined Range.
>>>
>>>Not able to solve it, kinldy Correct
>>>
>>>
>>>T1=TIME()
>>>Clear
>>>SET DELETED ON
>>>
>>>lcStr = filetostr('1021165156.ps')
>>>lnPOS = At("%%Pages:",lcStr)
>>>lcPageCount = alltrim(substr(lcStr, lnPOS, 12))
>>>lnPageCount = VAL(STRTRAN(lcPageCount,'%%Pages:',''))
>>>
>>>IF lnPageCount>2
>>>DIMENSION occoupiedrange(lnPageCount)
>>>DIMENSION unoccoupiedrange(lnPageCount)
>>>
>>>Local lcFile, lcText
>>>m.lcFile = [1021165156.ps]
>>>Create Cursor Dummy (PS c(254), pos i,pageno n(2))
>>>Append From (m.lcFile) Sdf
>>>
>>>SCAN
>>>IF Getwordnum(PS, Getwordcount(PS)) = [x] .OR. ;
>>>Getwordnum(PS, Getwordcount(PS)) = [y] .OR. ;
>>>Getwordnum(PS, Getwordcount(PS)) = [L] .OR. ;
>>>Getwordnum(PS, Getwordcount(PS)) = [w]
>>>
>>>m.lcText = Getwordnum(PS, Getwordcount(PS) - 1) && The second last word
>>>IF Len(Chrtran(m.lcText, [1234567890], [])) = 0 && lcText contains only digits
>>>Replace pos With Val(m.lcText)
>>>Endif
>>>ENDIF
>>>ENDSCAN
>>>   
>>>    
>>>   
>>>FOR I= 1 TO lnPageCount
>>>CURTEXT='%%Page: '+ALLTRIM(STR(I))+' '+ALLTRIM(STR(I))
>>>NeXTTEXT='%%Page: '+ALLTRIM(STR(I+1))+" "+ALLTRIM(STR(I+1))
>>>
>>>*DELETE FROM dummy WHERE ps like "%(of%" AND pageno>1
>>>*DELETE FROM dummy WHERE ps like "%(Page%" AND pageno>1
>>>*DELETE FROM DUMMY where Ps LIKE '%BHARAT SANCHAR%' AND Pageno>1
>>>LOCATE FOR ALLTRIM(PS)=curtext
>>>SCAN WHILE ALLTRIM(ps)<>nexttext OR EOF()=.T.
>>>REPLACE pageno WITH I
>>>ENDSCAN
>>>SELECT MIN(Pos) FROM Dummy WHERE Pageno=I AND Pos>20 INTO ARRAY X
>>>SELECT MAX(Pos) FROM Dummy WHERE Pageno=I INTO ARRAY Y
>>>
>>>STORE Y-X+1 TO Occoupiedrange(I)
>>>STORE (x) TO unoccoupiedrange(I)
>>>STORE (x-20) TO unoccoupiedrange(I)
>>>ENDFor                                                                                                                                                                                                                                                  
>>>
>>>
>>>FOR I=2 TO (lnPageCount-1)
>>>Blank=unoccoupiedrange(I)
>>>Filled=occoupiedrange(I+1)
>>>
>>>DO WHILE Blank>=Filled
>>>NEXTTEXT='%%Page: '+ALLTRIM(STR(I+1))+" "+ALLTRIM(STR(I+1))
>>>LOCATE FOR ps=NeXTTEXT
>>>Skip-1 
>>>Replace ps WITH NeXTTEXT
>>>SKIP
>>>Prefixmul= ALLTRIM(STR((Occoupiedrange(I)/68.7),18,2))
>>>Replace ps WITH '0 -72 &Prefixmul mul translate'
>>>WAIT WINDOW I
>>>Filled=Filled+occoupiedrange(I+1)
>>>WAIT WINDOW I
>>>I=I+1
>>>ENDDO
>>>ENDFOR
>>>ENDIF
>>>
>>>SELECT Dummy
>>>set textmerge On
>>>SET TEXTMERGE TO myfile.ps noshow 
>>>scan
>>>\\ << tRIM(pS) >>
>>>\
>>>endscan
>>>set textmerge To
>>>set textmerge off
>>>
>>>T2=TIME()
>>>WAIT WINDOW T2
>>>WAIT WINDOW t1
>>>
>>>
>>>Sample File Used for the above code can be downloaded from
>>>https://www.dropbox.com/s/7reg69thb5i13fq/1021165156.ps
>>>
>>>Regards
>>
>>Which line generates the error?
>>
>>Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform