Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help on Code Required
Message
De
12/03/2013 15:50:59
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Help on Code Required
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01568116
Message ID:
01568116
Vues:
55
I am tring to write a VFP code that Could merge two or more pages of post Script files. I have lots of White blank space left on each page of my PS file, so there is lot of paper wastage.

My idea is , I am appending text inside a PS file to a VFP table and will re-process it finally again to a PS file.

The 'U1' command Shows/Display the PS page and '0 -72 6 mul translate' is used to merge the page.

Hence, if page Number 2 &3 are to be merged, U1 at the end of Page Number 2 shall be removed(in VFP table) and '0 -72 6 mul translate' shall be inserted. This will merge page 2 and 3 in one page. Same action is required for further pages.

My code, Need & Problem.

I dont want to disturb Page Number 1, want to keep it as it is.

In the code below mentioned, I have calculated the occoupied space(Based on Row Position) and unoccoupied space (Based on Row Position) of post script Data/image for Each Page.

So, if the Unoccoupied space or free/blank space at page Number 2 is greater than Occoupied space at page Number 3, Page 3 will Merge in 2 and Program shall jump to page 4. Else if page 3 is not merged with 2 as page 3 space may be greater than page 2 space. The program shall next check for page 3 and 4.

MY PROBLEM
If the Unocoupied space or free/blank space at page Number 2 is greater than Occoupied space at page Number 3, Page 3 will Merge in 2 , however if there is still space left in page 2 so that it can further accommodate page 4,5,6 etc, this I am Not able to Do. Some Little Bit alteration is requied , but I am not able to Do it.

Some DO While...Enddo loop may work, but I am not able to do it.

Kinldy Help

Here is the very small PS file , if you need to download

https://www.dropbox.com/s/6x5an3dyg8syvmx/1021337392.ps


MY code
Clear
SET DELETED ON

lcStr = filetostr('1021337392.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 = [1021337392.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)) = [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

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>30 INTO ARRAY X
SELECT MAX(Pos) FROM Dummy WHERE Pageno=I INTO ARRAY Y
STORE Y-X+1 TO Occoupiedrange(I)
STORE (x-30) TO unoccoupiedrange(I)
ENDF                                                                                                                                                                                                                                                  


FOR I=2 TO (lnPageCount-1)
IF unoccoupiedrange(I)> occoupiedrange(I+1)
NeXTTEXT='%%Page: '+ALLTRIM(STR(I+1))+" "+ALLTRIM(STR(I+1))
LOCATE FOR ps=NeXTTEXT
Skip-1 
Replace ps WITH NeXTTEXT
SKIP
Replace ps WITH '0 -72 6 mul translate'
I=I+1
ENDIF
ENDFOR
ENDIF

SELECT Dummy
set textmerge On
SET TEXTMERGE TO myfile.ps noshow 
scan
\\ << tRIM(pS) >>
\
endscan
set textmerge To
set textmerge off
Harsh
Répondre
Fil
Voir

Click here to load this message in the networking platform