Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need some Improvement (STRTRAN Function)
Message
De
13/11/2017 05:08:39
 
 
À
12/11/2017 19:54:16
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:
01655531
Vues:
50
>>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
>
>Hi Harsh,
>
>1) Can you describe what "fails" means, in particular? Is there an error message? Is the substitution done incorrectly? Does it crash the system?
>
>2) How long is a string that is "too long"?
>
>Hank


Yes The Substitution is Incorrect as I have Limit the Length to 47. So if the length is around say 100, it does not substitute it properly.

My Requirement is Just to find out the starting position of _123456789_123456789 and Starting Position of Mediabox 'M' for every such type of strings in a File.
There can be N Number of such strings in the entire File. 'Mediabox' will always be after _123456789_123456789.

Example of my string in Text File

'KUMRA1521521_123456789_123456789_Ym30251_7jgu92l02klk414_5268YYU**1HnY_/Mediabox OPLOHT&@JWFK_IWKWM' && I need 13 for _123456789_123456789_ and 73 for 'M' (Mediabox).

Ultimately I am looking to Replace '_123456789_123456789_Ym30251_7jgu92l02klk414_5268YYU**1HnY_/Mediabox' with my desired string.
Harsh
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform