Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
STRTRAN Function (Whats Wrong With This)
Message
De
11/11/2017 20:39:35
 
 
À
11/11/2017 13:58:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01655504
Message ID:
01655508
Vues:
66
J'aime (1)
Hi Harsh.

Like normal VFP functions, StrTran doesn't change a string, rather it returns a changed string. All you need to do is assign the return value e.g. cFile = StrTran(.....

Ian Simcock.


>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform