Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need some Improvement (STRTRAN Function)
Message
From
13/11/2017 05:38:03
 
 
To
13/11/2017 05:12:03
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01655516
Message ID:
01655534
Views:
52
Have you checked the Stuff() function? If that doesn't help, please provide some realistic samples of what you have, and what you want it replaced with.

>Sir,
>The problem is not related to Size. The may be long but not that much that it will be a file Size.
>
>There is a Substitution problem 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). Or 13 & 80 ('x' Mediabox) so that I can get the desired string between using SUBSTR()
>
>Ultimately I am looking to Replace '_123456789_123456789_Ym30251_7jgu92l02klk414_5268YYU**1HnY_/Mediabox' with my desired string which I need to Replace.
>
>Thanks
>
>
>>If the file is to big, you may have to read it in smaller chunks using low level file functions. Check Fread() in Help, and the other functions mentioned on that topic. It may also be much faster.
>>
>>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform