Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need some Improvement (STRTRAN Function)
Message
De
13/11/2017 10:02:32
Frank Cazabon (En ligne)
Samaan Systems Ltd
St Augustine, Trinidade
 
 
À
12/11/2017 14:12:05
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:
01655516
Message ID:
01655542
Vues:
61
>Using FILETOSTR() I have Taken the extract of a file in a String.
>
>I Need to Replace certain strings in the entire file with my New String.
>
>The string which I need to Replace starts with '_123456789_123456789' and Ends with 'MediaBox' i.e the starting point of the string will always be
>_123456789_123456789 followed by some Variable Part and the last words in the will always be 'MediaBox'. The Length of the string could be any.
>
>Example of such string are
>
>'_123456789_123456789_Ym30251_414_5268YYUHnY_/Mediabox
>
>Or
>
>'_123456789_123456789_Ym30251_7jgu92l02klk414_5268YYU**1HnY_/Mediabox
>
>
>I am using the Following code, which is working fine where the Length of String is Not too Long
>
>
>Select StringobjectNo
>SCAN
>cReplacedText=ALLTRIM(STR(FObjectno))+" 0 obj <</Type /Page /Parent 2 0 R /MediaBox"
>nMissingObjectStartPosition=AT('_123456789_123456789',cFile,1)
>cFindMissingText=SUBSTR(cFile,nMissingObjectStartPosition,47)
>
>* Here I Have Taken Length as 47 assuming that the 1st Word of 'Mediabox' will be included within the span of 47, However, this is not always the case as there can be Strings whose Length can be Far far more than 47. So I need some Logical Improvement on This part particularly. 
>
>*My overall Object is to Extract the String which is  '_123456789_123456789.....Mediabox' and replace it with cReplacedText.
>
>nMissingObjectEndPosition=AT('MediaBox',cFindMissingText,1)+8
>
>cMissingText=SUBSTR(cFile,nMissingObjectStartPosition,nMissingObjectEndPosition)
>
>cFile=STRTRAN(cFIle,cMissingText,cReplacedText,1,1)
>ENDSCAN
>
>
>The above code is working fine for short length of strings but if the length of string is too long, it fails to perform.
>
>Kindly Suggest How to do this.
>
>Thanks

Harsh,

this might help you:
CLEAR 
MyLongString = "_123456789_123456789_Ym30251_414_5268YYUHnY_/Mediabox"
MyStartString = "_123456789_123456789"
MyEndString = "Mediabox"
MyStringToGetReplaced = SUBSTR(m.MyLongString, AT(m.MyStartString, m.MyLongString, 1) + LEN(m.MyStartString), AT(m.MyEndString, m.MyLongString, 1) - LEN(m.MyStartString) - 1)
* should be "_Ym30251_414_5268YYUHnY_/"
?m.MyStringToGetReplaced

MyLongString = "_123456789_123456789_Ym30251_7jgu92l02klk414_5268YYU**1HnY_/Mediabox"
MyStartString = "_123456789_123456789"
MyEndString = "Mediabox"
MyStringToGetReplaced = SUBSTR(m.MyLongString, AT(m.MyStartString, m.MyLongString, 1) + LEN(m.MyStartString), AT(m.MyEndString, m.MyLongString, 1) - LEN(m.MyStartString) - 1)
* should be "_Ym30251_7jgu92l02klk414_5268YYU**1HnY_"
?m.MyStringToGetReplaced
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform