ब्लॉग कोशिश कर रहा है بلاگز کی ک*Trying Blogs
Trying Blogs ब्लॉग कोशिश कर रहा है ബ്ലോഗുകൾ ശ്രമിക്കുന്നു
بلاگز کی کوشش کر رہے
The purpose of this Thread is the following:
इस धागे के उद्देश्य निम्नलिखित है:
ഈ ത്രെഡ് ഉദ്ദേശ്യം പിന്തുടരുന്നു:
:یہاں مقصد مندرجہ ذیل ہے
Codes and Information is here.
संहिताओं और सूचना यहाँ हैं।
കോഡുകൾ സമവാക്യങ്ങളേയും വിവരങ്ങൾ ഇവിടെ ഉണ്ട്.
کوڈز اور معلومات یہاں پایا جائے.
1)
To be referenced in this web site
इस वेब साइट में संदर्भित किया जा करने के लिए
ഈ വെബ് സൈറ്റിൽ പരാമർശിച്ചിരിക്കുന്ന ലഭിക്കണമെങ്കിൽ
ان خطوط اس ویب سائٹ سے محولہ کیا جائے گا
2)
Also to be referenced from other web sites
इसके अलावा अन्य वेब साइटों से संदर्भित किया जा करने के लिए
മറ്റ് വെബ് സൈറ്റുകളിൽ നിന്നുള്ള പരാമർശിച്ചിരിക്കുന്ന ചെയ്യുവാൻ
اس کے علاوہ دیگر ویب سائٹس سے محولہ کیا جا کرنے
_...........
This has been agreed with the Administrator
यह व्यवस्थापक द्वारा सहमति व्यक्त की है
ഈ അഡ്മിനിസ്ട്രേറ്റർ സമ്മതിച്ചു ഉണ്ടായിരുന്നു
یہ ایڈمنسٹریٹر کی طرف سے اس بات پر اتفاق کیا ہے
http://www.excelfox.com/forum/showth...eded#post10071
http://www.excelfox.com/forum/showth...age2#post10082
There are no restrictions on posting here
यहां पोस्टिंग पर कोई प्रतिबंध नहीं कर रहे हैं
ഇവിടെ പോസ്റ്റുചെയ്യുന്നതിന് നിയന്ത്രണങ്ങൾ ഒന്നുമില്ല
یہاں پوسٹنگ پر کوئی پابندی نہیں ہے
There is no time limit on Editing ( Only here in Test Sub Forum )
संपादन पर कोई समय सीमा नहीं है ( केवल परीक्षण उप फोरम में )
എഡിറ്റിംഗ് യാതൊരു സമയ പരിധിയുമില്ല ( മാത്രം ഉപ ഫോറം ടെസ്റ്റ് )
ترمیم پر کوئی وقت کی حد نہیں ہے
( صرف ذیلی فورم ٹیسٹ )
I will re use some posts. By Editing. There is no time limit on Editing
मैं फिर से उपयोग होगा कुछ पदों . बदलें संपादन . संपादन पर कोई समय सीमा नहीं है.
ഞാൻ ചില ഭാഗങ്ങളിൽ പുനരുപയോഗിക്കാൻ ചെയ്യും. എഡിറ്റ് സാധ്യമാണു് . എഡിറ്റിംഗ് യാതൊരു സമയ പരിധിയുമില്ല
ترمیم پر کوئی وقت کی حد نہیں ہے میں ترمیم کو استعمال کرتے ہوئے I ادلیکھت کبھی کبھی کریں گے بنانے کے.
Alan
:)
_.________________________________________________ _______________________
Quick links
Variable definitions : http://www.excelfox.com/forum/showth...0192#post10192
VBA Remove BB Code Code Tags in text
VBA Remove BB Code Code Tags in text
In the next post is a code to remove BB Code Code Tags in text
This code is slightly redundant since I was given a simpler one ,
http://www.eileenslounge.com/viewtop...202145#p202122
which probably is more Full proof !
But I include it here with description for future reference. I may use it in a following code or codes to cross check the results given.
The code is intended to remove valid BB Code Code Tag sections from a Text string.
In this case, valid means in terms of the syntax, which is basically as follows
[TagWord=Some]Any text[/TagWord] or [B]Any text[/b]
An arbitrary string is given initially in code section Rem 1)
"gggg[d=fg]2[/d]45[/8]x[ddd[Cl=XYZ][/Cl][B]Any text[/b]"
Then the main code is as follows
Rem 2 Brief Code description
The code works backwards 100 through the whole string. It looks at a character at a time.
120 __ On If finding a ] , it notes the position of it,
140 BcrdEEnd, then keeps going back.
160___If it finds another it notes that as the ] position and carries on going back.
170 It determines the position of a [ , BcrdESt, by looking for a [\
It starts looking again for the next ] ,
250 _____If a ] is found, it checks
260 _____If the next character back is another ], Then it keeps going back. If the next character back was Not a ] , then the position of the ], BcrdSEnd, is
270 noted
A new last loop 290 starts going further back to look for a [
300 ________If it finds a [ , it notes that, BcrdSSt.
320 ________If in the unlikely event that it is a start of an end , like [\ then we have found a second End BB Code Code Tag so we do like_..
BcrdEEnd = BcrdSEnd:
BcrdESt = BcrdSSt:
BcrdSEnd=0:
( BcrdSSt=0 )
_..and go back and start again looking for the start tag. Otherwise the start position of the start tag, BcrdSSt, is noted, then it is finally time to go and think about getting rid of the code tag pair whose positions have now been determined....
430 FkOffCrd:
_..So I come to a point, aptly named, Rem 3) "I think we come here with a complete set of 4 positions". So I try to take the BB Code Code Tags out. As I am going backwards, the new string with the missing Code Tag pair does not mess up me going through the characters as I took off stuff “behind me”
450 I overdo the use of variables here because I can and do, but also because a development of the code might be to look through a list of available BB Code Code Tags to check I have them . I do one quick validity check: I check that the word after the / in the End BB Code code tag is the same as the word in the start BB Code code tag ( that before an = , if there is an = ) . Only
500____ If this condition ( which must be met for a valid BB Code code tag ) is met are the pair of tags removed by replacing them with , . Another condition is also checked: a / in second character of the stop tag.
Either from going through a code section search with possible removal, or ,
540 Else not , we are at the Next posCurrent of the main going backward Loop,
580 , so keep going back looking for another, or a first possible start ( looking from the back ).
Hopefully, for example at line 340, posCurrent would have been reduce to allow for the inner Loops going back in a code tag section search.
_................................
The code returns the string:
gggg245[/8]x[ddd[B]Any text[/b]
Wild Things. You make my heart sing. They make everything..... Groovy
The VBA code in the last few posts is a bit of a long way around of doing what can be done in a Word Dialogue box type thing using Wild things:
http://www.gmayor.com/replace_using_wildcards.htm
http://imgur.com/4Nqj1HP
The problem is getting at the Wild Things needed in the Wild Find String.
I can’t do it. But Hans and Paul did it for me here:
http://www.eileenslounge.com/viewtop...=26030#p202107
Here is my attempt at an ‘ExPlanation of the solution:
Wild Things. You make my heart sing. They make everything….. Groovy
Wild Things. You make my heart sing. They make everything….. Groovy
http://listenonrepeat.com/watch/?v=H...s_-_Wild_Thing
Wild things…. I think I hate you .. But I wanna know for sure… so
A Summary :)
As example. We want to remove the start and stop tags in a sample string containing a start and stop tag such as this_..
[color=Green]This is green[/color] This ‘aint matey
_.. What we finally want is this:
This is green This ‘aint matey
We use a combination of Wild things , or like a pattern to search for [ Find ] any bits like _..
[color=Green]This is green[/color]
_.. and [ Replace ] that “Find”ed with
This is green
We can do, it Wildly, man, as follows:
As always the search is done from left to right
The way I do it below is probably not the most efficient way, in fact it is probably pretty stupid, but is just to demo the idea
Optional use of ( ) in the Wild thing search string
We can use brackets ( ) , optionally , to identify, ( for later use ) , the exact string parts found by the constituent Wild things in the ( ) in which they are in:
So in this example we will use a ( ) for
_ the Wild things that find the color so that the actual word color can be used again in the same wild stuff string, so as to make sure that we find in the end tag the matching word to that in the start tag.
_ Also we need a ( ) to identify the wild things that Find This is green , as we want to use that in , or rather for the complete, Replace string.
A bracket is identified by , for example, \2 if I want to reference the actual string found by the wild things we enclose in the second ( )
Build up final Wild thing Replace string, left to right, by breaking string we want up into bits. Each bit will be found by a Wild thing or things
So we are looking to break the to search for Wild [ Find ] Thing string down thus:
Code:
[ & ( AnythingWithout=or] ) & anything & ] & (Anything) & [\ & \1 & ]
So I am breaking it down in to 8 bits. So I need 8 sections of wild stuff to Find those.
\1 is at the 7th position and refers to what is actually found by the search for ( AnythingWithout=or] ) at position 2 ( which is bracket ( ) number 1 )
Excel starts at the left. What no literature really states clearly ( and is only obvious once you know it ) is this:
_ For most sections, Excel keeps going to the right until it Finds what the Wild thing tells it to. That is then stored, but only if that found string also has joined to it the string type in the next section’s Wild thing. Those two sections are then stored ( as well as storing separately if either of those two sections are enclosed in ( ) ), but only if that found string also has joined to it the string type in the next section’s Wild thing. That is then stored, but only if that found string also has joined to it the string type in the next section’s Wild thing. ……..etc.
A common Wild thing is * . This means anything characters and any amount. This will only include, however, anything up to if and when the next Wild thing is satisfied.
The 7th Wild thing I already have which is \1 which is referring to the 1st bit enclosed in a ( ) , which is the second bit in the broken up string , ( which is anything without a = or a ] . In our example this will be color) . Note: The number refers to the number from the left of any ( ) that I may have included, not the actual sections.
Just to make that last point clear, and to demonstrate another, I will do this_..
Code:
[ & ( AnthingWithout=or] ) & ( Anything & ] ) & (Anything) & [/ & \1 & ]
_.. so my Replace is then \3 . I do not need the second ( ___ ) , which I could reference by \2, ( and it can help to result in an “expression too complex” error ! ).
I put the second ( ___ ) in also to demo that a ( __ ) can include more than one wild bit
So here is one example Find sting with Wild things that “works” ( I added spaces to show better the 8 sections, but in use those spaces must be removed ). There are three optional ( ) sections. The second ( ) section encloses two Wild thing sections: Those are the third and forth counting from the left.
Code:
[\[] ([!\]=]@) (* \]) (*) \[/ (\1) \]
This is the actual Wild Find string
___ [\[]([!=\]]@)(*\])(*)\[/(\1)\]
To '_- ExPlain the 8 parts:
Part 1 [\[]
Excel start “looking” from the left to find a [
As a general rule Wild things are enclosed in a [ ] pair to identify them as such. So a [ ] is a Wild thing. They do not always have to be enclosed in a [ ], as is the case here. Here we are effectively looking to Find a single simple character, [.
( In the final Find string, only the second Wild section needs to be enclosed partly in a [ ] pair ).
So this section written as \[ instead is just as good. I suspect my use of the extra [ ] here does not have any bad effects, as it might be that the final string would be at compile or whatever reduced to \[ in either use of \[ or [\[]
We need to use the Wild thing, \ , quite a bit , in our total string for the same reason that we do here: This is because the \ has another use in Wild things in addition to the already discussed way like \7 ( where 7 would be for the 7th ( ) ). This other use of \ is to allow us to use characters as simple text which have a specific use in Wild things, so that Excel knows that we want to use them as their literal text string, rather than as Wild thing. Here it is needed for the first [ which we want to find.
( It follows that if we were looking for a \, then we would need to use \\ )
In our example string we find with this first Wild thing section the first [
Part 2 ([!\]=]@)
As noted the ( ) allows the string actually found in this Wild bit to be used later to the right via the reference \1.
As for this:
[!\]=]@ ( which could just as well be written [!=\]]@ )
We need a [ ] pair here, as within that is part of the Wild instructions for what to search for , and that has a further Wild instruction, @ , applied to that.
So in such a [ ] pair we would normally expect some specific wild stuff
Here the Wild thing, ! , means we search for any character other than those after included up to the closing tag ]. In our sample string , our first Wild bit found the first [ which now has added on any string at the next character if it is not a = or a ]
So this part of the second wild bit will find c in our sample string. If we had no other wild instructions here, then Excel would be content/ satisfied with that c. That would be joined on to the first [ found, so our result so far would be [c . In effect Excel stops going to the right when it is satisfied, and goes on to the next Wild bit. But we have another wild instruction here: The @ instructs to look for any amount of characters meeting the conditions before it, in this case the conditions in the [ ]. So the “Find” will stop finding characters when it no longer has a not = or a not ]. In our sample string the characters meeting the conditions are tacked on to a [ so will be will be [color. What [!\]=]@ has actually found and what the brackets ([!\]=]@) can be thought of as “holding” is color.
An alternative for @ would be {1,} which looks for between 1 and any amount of what is before it.
If we had used {1,4} or {2,4} instead of @ we would have so far for the complete found string [colo
If we had used {5,5} we would not have found a matching code tag word with less than 5 characters.
Parts 3 and 4 (*\])
This is unnecessarily in ( ) . *\] will do
The literature says * looks for any amount of anything. I think that is not strictly correct, or at least, explains it badly. It would appear to look for any amount of anything only until the next wild condition is met. That is why I chose to put it in ( ) just to demo the dependence, as it were. But this (*)(\]) or this *\] would work just as well (*)(\]).
Once again the \ is required for telling Excel that we want it to recognise ] as a string rather than a specific Wild thing. For this section , with my example string, I get from this complete 2 part Wild section
=green]
If our code tags were of the form like: [b]SomeBoldText[/b] , then the search would have “stopped before it started”, as it were, as the ] would have “stopped” it
The combination of the 2 part Wild sections in this case would return just the single text character ]
Parts 5 and 6 (*)\[/
I contradict what I said in the last section slightly by using a ( ) around the * . Once again the * does nothing useful without the next wild bit to “stop” it. But what it does Find before it “stops” is what we actually need for Replace string. Hence I need a ( ) to reference what it Finds. This total Part 5 and part 6 section returns in our example
This is green[/
and the part referenced inside the ( ) is
This is green
Part 7 (\1)
As discussed already here the Wild thing, \1 , instructs to Find a string equal to that actual text found in the first ( ) if it is just before the next to be found ( which we will see in the next Part is the last character pair found, [/ ). The actual string found by [!\]=]@ in Part 2 , was , in our example the text color
Part 8 \]
Finally only a complete final Find attempt is successful if the last character is a ] , that is to say if the character after the text, in our example, the second color, is a ]
_...
The Final “Find”ed String for our example would be
[ & color & =Green & ] & This is green & [/ & color & ]
Full Code "Belt and Braces” in Word Find Replace & String Manipulation of initial Text String in Clipboar
Full Code "Belt and Braces" in Word Find Replace & String Manipulation of initial Text String in Clipboard
This code is simply doing the two ways to remove BB Code code tag pairs from a copied to the clipboard Text from a Word document.
A check is then done Finally to see if the two raped from tags strings are the same.
I would not be surprised if a fail in the strings match just means that the second method, ( my long string manipulation way ) is getting it wrong.. Lol.. but never mind :) ***
***Edit: - like I just did: It will not work for nested BBCode code tags like
[CENTER][B]Issue Forum for Issues suggestions for improvement Forum for Issues obfuscation[/B][/CENTER]
This is OK
[B]Issue Forum for Issues suggestions for improvement Forum for Issues obfuscation[/B]
:rolleyes:
That will do for this one, I guess I will have to do a recursion wonk to get a version working with nested BB Code Tag code tags,
_.____________-
:rolleyes:
Ok. Here we go:
This code _..
Sub BBCodeCodeTagsWegDaMit2AlanHansPaul2()
_.. is mostly just splicing together codes
Sub WegDaMitHansPaulAlan()
and
Sub LongWayOfDoingIt()
along with adding a short section, Rem 10a) to check that the strings are the same. That is to say the
Full Story selection text from the modified ( removed BB Code code tags ), NewWordText for Code Part 1)
is
compared with the final RapedText from the long string manipulation Code part 2)
The code is all one code and broken down into this and the next three posts
Code part 1 of 4 parts ( all following parts to be copied directly under the preceding part in the same code module.
Code:
Sub BBCodeCodeTagsWegDaMit2AlanHansPaul2() ' http://www.excelforum.com/development-testing-forum/1086445-forum-tools-test-no-reply-needed-4.html#post4586680
' === Code assumes you have a Word File open, and have selected some Text
' One way is automating doing it in Word. "Wild Things. You make my heart sing. They make everything….. Groovy" '_- http://www.eileenslounge.com/viewtopic.php?f=26&t=26030#p202322
Rem 0) ' Just mucking about a bit with refering to Word documents
' Documents.Item("eileenslounge.docm").Activate
'Dim DocNme As String ' ' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
' Let DocNme = ActiveDocument.Name ' ' '_-So A variable in VBA is like the Link to the part of a URL string reducing size site where a few things about the actual Final site is informed about. This area in that site, like a pigion Hole to which the variable refers, ( the "pigeon hole" location address, and all its contents would be defined as the "Pointer". Amongst other things it has a link, a "Pointing part", pointing to actually where all the stuff is
Dim Doc As Document 'A variable in VBA is like the Link to the part of a URL string reducing size site where a few things about the actual Final site is informed about. This area in that site, like a pigion Hole to which the variable refers, ( the "pigeon hole" location address, and all its contents would be defined as the "Pointer". Amongst other things it has a link, a "Pointing part", pointing to actually where all the stuff is
Set Doc = ActiveDocument 'EP Set: Fill or partially Fill: Setting to a Class will involve the use of an extra New at this code line. I will then have an Object referred to as an instance of a Class. At this point I include information on my Pointer Pigeon hole for a distinct distinguishable usage of an Object of the Class. For the case of something such as a Workbook this instancing has already been done, and in addition some values are filled in specific memory locations which are also held as part of the information in the Pigeon Hole Pointer. We will have a different Pointer for each instance. In most excel versions we already have a few instances of Worksheets. Such instances Objects can be further used., - For this a Dim to the class will be necessary, but the New must be omitted at Set. I can assign as many variables that I wish to the same existing instance
Rem Code Part 1) make two temporary Word Files with and without BB Code
Recursion Wonk. To remove BB Code tag pairs incuding nested ones missus
One problem noted in the previous codes was that the case of nested BB Code tag pairs, the codes did not work. At many forums such nesting of this form is permitted in BB codes.
[color=Green]Comments [color=Red]Highlight[/color] Comments[/color]
The returned result is
Comments Highlight Comments
None of the codes discussed so far will work for such a case.
Should the Code tag type be dissimilar, such as_..
[CENTER][B]Title[/B][/CENTER]
_..then at least the Find Replace Wildcard Code will work for that by virtue of matching in the String first, for example, in the above example, _..
__ CENTER __ __ __ __ CENTER __
_.. then
__ B __ __ __ __ B __
However my Long string manipulation code will not even work for that.
I have done a Long string manipulation code to be discussed in this and the following posts which , I think, work for all situations.
Brief Descriptions is:
The entire string is held in a variable, strBBCode. This is declared in a Subroutine. Something similar to that was done for the last code )
change 1) Minor to last code:
Unlike the previous codes, ( which sequentially removed BB Code code tags ( by replacing with "" )), the code tags are replaced by some arbitrary character ( This is simply chosen as any not likely to be used as text in the main initial string https://www.mrexcel.com/forum/excel-...ml#post4214083 )
change 2) Minor
This itself is not such a major change in the code format, but it facilitates the main change, 3) below. This change is that bulk of the code is within a Function, (Function LongWayOfDoingIt2ReCurseCyClops(__ ) . It is “Called” and needs to be given_..
_.. the string, strBBCode, By Referral to that variable, rather than its By its Value contents
and_..
_.. a Value for the current character position, which initially will be the end ( or length in characters ) position of strBBCode.
But those are not the main changed characteristic to the code.
To recap: All my long string manipulation codes, including this Function, have the general characteristic that they loop backwards in the complete string until a ] is found. An attempt is made then to find a [/ . Once this is found an attempt is made to find a ] and then a [ .
At this point a possible code pair requirement , looking backwards, of ] [/ ] [ is achieved
( Reversing that to the correct order shows that clearly more clearly,
[ _ ] __ [/ _ ],
or
[codeText] AnyText [/CodeText] .
Or
[Color=red] AnyText [/color]
_.. etc...)
Having found a code tag pair, a check is made for its validity ( the same matching work, such as, codetext, color, for example ) , before the adjustments are made to the main string. After that , the code then moves on and steps further “back” in search of another pair_..
_.. But just before it does that check, all codes, including this new Function, at the last found [ , do a check to see if in fact the next character after the last found [ is a / , indicating that in fact the assumed start tag, [codeText], was in fact another end tag, [/Codetext_b]. Action is then taken should that be the case.
At this point the codes are very different. The action taken is different
In the previous code, it was assumed that in such an event, the first found “end tag” was a rouge text looking like an end tag , but invalid, and not matched to a start code tag. The first found “end tag” was then ignored, and another search made for a matching start tag to the second found end tag.
This results in an error situation for a valid nested BB Code tags situations.
The new code works therefore much differently.
Main change 3):
In the new code, this point is around lines
430 – 460, Rem If [/ Then Oh dear time for a wonk.
Recursion is the name given for the general technique which at this point is used. It is whereby within a routine an instruction is given to run the routine.
:rolleyes: ... In other words the Routine “Calls itself”.
So what is all that about? :
‘_- I will tell you, Matey boy:
Any Function or Sub routine we write, is just a set of instructions. Like a piece of paper which is a Print out of the typed code instructions. It tells VBA what to do when it is run or called. I does not really physically go along or through the code lines: We just find that easy to visualise, or “look at “ when “stepping” through to debug a code. The code is just a set of instructions that VBA understands.
So imagine you are VBA and you are given a set of instructions ( on a piece of paper ) to do a job, (for example you are given a written copy of the instructions to read and follow).
You start doing the instructions.
Now, say, before you are finished, you are given a set of identical instructions and are told to do that by the boss. What do you do, ( apart from swear at him ) ?
The logical progression is, ( and that is what VBA does ), it stops what it is doing, so like freezes the initial running through the instructions , and starts again with the new ( duplicate as it happens in the case of “recursion”) set of instructions.
Once finished it goes back and picks up the first job where you / it left off. Within reason, there is no limit to how often you can do that in VBA. If a code makes a Function or Sub routine keep “Calling” itself , then it “stacks” up in order in a “waiting list” the stopped set of instructions. As each set of instructions is completed, the last are continued at the point where they were interrupted and “frozen”. That point is code line 450
It follows, ( although may not be immediate obvious as the same names are used) that all variables used in each run of the Function within the function are unique to that run of the function so do not influence the values of the similarly named variables in the other Function runs. An exception here is our main full string, strBBCode. This is because we have deliberately chosen to carry it over By such a way as to indicate it should be Referenced to within each Function. So in this case, changes made in any Function run to strBBCode will be Reflected in the main ( unique ) variable, strBBCode, which is initially “held” / declared in the initial calling code.
So what is all that to do with the main change to this code version ??
‘_- I will tell you, Matey boy:
Initially the Function is called the first time by a small Sub routine which passes to the Function two things
_(i) the variable strBBCode. It is indicated via the use of ByRef in the Function signature ( first ) line, that specifically that variable is to be Referenced. ( You may effectively take a variable “into” the Function ( ByRef ) , or alternatively a Value. If an actual value is given, then giving it ByRef is just the same as By Value. If you pass a Variable ByValue the value at the time of the Call in the variable will be taken, and that variable will become local to the Function and so any changes to it made in the function will not be reflected in the variable “held” in the initial calling routine ........ )
_...(ii) a number .......Value... is given which will be the start position to work back from when looping backwards through the characters in strBBCode. For this first Call, that will be the length of / or character count of , strBBCode.
The Function code then transgresses as described and very similar to the previous code. It can go to completion in one run should no end code tag be encountered after an initial one is found and before a start tag is found.
____If a second end tag in sequence is found the "recursion wonk" kicks in.....
450 _____ Call LongWayOfDoingIt2ReCurseCyClops(strBBCode, BcrdSEnd)
So _ If this line is done, the current run freezes. A New Function begins. This is instructed to Refer to the unique main string strBBCode “held” in the original Calling routine. As Value for the current position in the backward stepping search is this time not the main string strBBCode length, but rather the position of the end ] in the currently found second sequential end code tag.
The only thing that is certain at this point is that the new Function run will immediately find this second end cote tag as its first end code tag. This is probably inefficient as it repeats some steps done. ( A more complicated Function could be envisaged to carry across an Offset to be applied to “jump” this search and pass the end code tag )
With no more nested code tag pairs, the second Function will complete the entire string, other than the possible code tag pair search “frozen” in the first Function.
When the first function resumes, the initial code tag pair search is completed.
There are many other scenarios including a further nested code tags section the second function finds and results in a third Function starting. That third Function would complete all but the two pairs searches “frozen” . At completion of the third Function, the second and then the first Functions with their respective code tag pair search would be completed.
Another scenario would be a double nesting such that there are three sequential end code tags. Once again a second followed by a third Function would be started. Once again, the third Function would complete all but the two pairs searches “frozen”. At completion of the third Function, the second and then the first Functions with their respective code tag pair search would be completed.
One can imaging many more scenarios
One common factor is that all but the final function will be searching through the replaced replacement characters. This probably makes the code a bit inefficient
Final usage of Function
Initial code to Call the Function for the first time. ( The function may Call itself one or more times further )
The Function will not run itself.
It needs to be Called with the initial parameters passed, the main string, strBBCode, along initially with the length of that string as the start point from which to step back.
A routine is needed for that.
Additionally, once the initial Function run , ( which is set off by this routine ) is finished, we will have the original string, strBBCode , returned in a modified form with the replacement character in place of all found code tags. These need to be removed, which can be easily achieved by replacing them with zero length strings.
An example code is given in the next post.
A few minor last thoughts..
This second solution for manipulating a long string text does not require stepping backwards. It was simply developed on from the last code. That code was easier to do backwards as in the code parts were deleted whilst stepping through the string: It was easier to deal with such a code in a backward loop, as things “behind me” are deleted. The problem with going forward is that “deleting in front of me” can require adjusting “where I am”, and the count to, or “final point of where I am going to”. – Think of it as you tripping up, or effecting where the end is, if you chop out the path in front of you: VBA can get messed up in Looping if you remove points in a progression that have not yet been considered.
Another way of thinking about that:
If I take bits out, then things shift back or down to fill the space. If I take things out in front of me, then by shifting back, things which I have not yet considered will change their position. This will likely mess up some order of progression.
If I go backwards, and delete things behind me, then any order changes will only affect things which I have already considered. My original progression plan and order of things not yet considered is still valid.