Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
STRTRAN Function (Whats Wrong With This)
Message
From
11/11/2017 13:58:40
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
STRTRAN Function (Whats Wrong With This)
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01655504
Message ID:
01655504
Views:
64
Hi,

I have Taken the contents of a File using FIletoSTR in cFile.

Now I am trying to Replace some Strings using STRTRAN but the same is not being done. Here is what I am Doing
Select Missingobject 

SCAN

IF RECNO()=1
cReplacedText=ALLTRIM(STR(FObjectno))+" 0 obj <</Type /Page /Parent 2 0 R /MediaBox"
nObjectPosition=ATC('_123456789_123456789_123456789__0 R /MediaBox',cFile,RECNO())
STRTRAN(cFile,'_123456789_123456789_123456789__0 R /MediaBox',cReplacedText,nObjectPosition,RECNO())
*STRTRAN(cFIle,'_123456789_123456789_123456789__0 R /MediaBox',cReplacedText)
ENDIF

IF RECNO()>1
cReplacedText=ALLTRIM(STR(FObjectno))+" 0 obj <</Type /Page /Parent 2 0 R /MediaBox"
nObjectPosition=ATC('_123456789_123456789_123456789__ 0 R /MediaBox',cFile,RECNO())
*STRTRAN(cFile,'_123456789_123456789_123456789__ 0 R /MediaBox',cReplacedText,RECNO())
STRTRAN(cFile,'_123456789_123456789_123456789__ 0 R /MediaBox',cReplacedText,nObjectPosition,RECNO())
Endif
Endscan

STRTOFILE(cFile,'D:\1024729126-WMCCC.PDF')


I need to Replace Two types of Strings in cFile  i.e '_123456789_123456789_123456789__0 R /MediaBox' and ''_123456789_123456789_123456789__ 0 R /MediaBox'  with  ALLTRIM(STR(FObjectno))+" 0 obj <</Type /Page /Parent 2 0 R /MediaBox.
The value of ALLTRIM(STR(FObjectno)) will Change to next record With Each next occurrence of the above _123456789 string.

I am Not getting the changed output file with my above code used. Whats wrong in this ? There can be any more simple code to do this ?

Regards
Harsh
Next
Reply
Map
View

Click here to load this message in the networking platform