cyberchief Posted September 27, 2005 Report Share Posted September 27, 2005 Ok, I'm stumped on this one. I need to find the position of specific text but not from the beginning of the string variable. In the below example, I need to copy the /TN and Data just prior to the /PIC text... not the first /TN, but the second one. Basically, I need to find /PIC and then find the /TN that is just before it. The position of the /TN can vary before the /PIC text. So I cannot just subtract a specific number off the interger. I need to find /PIC, then find the first previous /TN. text text text /TN 111 111-1111 text text text text text /TN 222 222-2222 text text text text /PIC text text text. End result, I need to copy /TN 222 222-2222 to a seperate variable. I am sure there is a way to do this... but it is escaping me somehow. Any Guidance? Quote Link to comment Share on other sites More sharing options...
joe Posted September 27, 2005 Report Share Posted September 27, 2005 Hello Cyberchief! Refresh my memory ... do you have the PGM Functions Library? If so, then this can be done in a couple of steps. If not then it will take a Repeat Loop and some extra steps. Quote Link to comment Share on other sites More sharing options...
cyberchief Posted September 27, 2005 Author Report Share Posted September 27, 2005 Hey Joe. I have it on 1 machine.. but honestly, I haven't had any use for it. This could change in the future... but as of now, I can't get the company to pay for it if I do not have an immediate and drastic need for it. Also, fyi... we are finally setting up a lab... so we will be ordering probably about 5 or so more licsense. Quote Link to comment Share on other sites More sharing options...
cyberchief Posted September 27, 2005 Author Report Share Posted September 27, 2005 Ok, this may be crude... but I think it will work. What I am attempting is to set all text up to the /PIC to variable T10. I already have N4 set to the position of /PIC. I have set N1 and N2 to the length of characters in that new varaible (should be the same as N4). I set a repeat loop starting from the end of that new copied text and copy 1 character. I set that character to T11, then append to T12. I then delete the last character of the string (the one that was just sent to T12) and repeat loop. The end result would be reversing the entire text string. Clipboard Copy Variable Set String %T10% from Clipboard Variable Set Integer %N1% from Length of Variable %T10% Variable Set Integer %N2% from Length of Variable %T10% Repeat with Variable using %N1% Variable Modify String: Copy Part of %T10% to %T11% Variable Modify String: Append %T11% to %T12% Variable Modify String: Delete Part of %T10% Variable Modify Integer: %N2% = %N2% - 1 Repeat End Text Type: %T12% <CLIPC><TVAR2:10:03:><IVAR2:01:12:10><IVAR2:02:12:10><REP3:05:000001:000001:0001:0:01:><TMVAR2:10:11:10:N02:001:><TMVAR2:08:12:11:000:000:><TMVAR2:11:10:00:N02:001:><NMVAR:02:02:1:0000002:2:0000001><ENDREP><TEXTTYPE:%T12%> So this text "The red fox jumps over the lazy dog" would be converted to "god yzal eht revo spmuj xof der ehT". What I will do next is, get the position of NT/. Set that to N5. I then subtract N5 from N4, and that should give me the position of /TN in the main string variable. Probably have some tweaking to do... but I think this may work. Any suggestions or critisisms? Quote Link to comment Share on other sites More sharing options...
joe Posted September 27, 2005 Report Share Posted September 27, 2005 Here is another solution Cyberchief: // Delete everything from "/PIC" and to the right. Variable Set String %T11% "text text text /TN 111 111-1111 text text text text text /TN 222 222-2222 text text text text /PIC text text text" Variable Set Integer %N1% from Position of Text in Variable %T11% Variable Modify Integer: Dec (%N1%) Variable Modify String: Copy Part of %T11% to %T11% // Find the last occurence of "/TN". Repeat Until %N1% = 0 Variable Set Integer %N1% from Position of Text in Variable %T11% If Variable %N1% > 0 Variable Modify Integer: Copy %N1% to %N2% End If Replace "/TN" with "~~~" in %T11% Repeat End // Delete everything to the left of the last "/TN". Variable Modify Integer: Dec (%N2%) Variable Modify String: Delete Part of %T11% // Replace the first 3 characters in what is left with "/TN". Replace "~~~" with "/TN" in %T11% <REM2:Delete everything from "/PIC" and to the right.><TVAR2:11:01:text text text /TN 111 111-1111 text text text text text /TN 222 222-2222 text text text text /PIC text text text><IVAR2:01:13:11:/PIC><NMVAR:09:01:0:0000001:0:0000000><TMVAR2:10:11:11:001:N01:><REM2:><REM2:Find the last occurence of "/TN".><REP3:08:000001:000002:0001:0:01:0><IVAR2:01:13:11:/TN><IFVAR2:2:01:4:0><NMVAR:07:01:0:0000002:0:0000000><ENDIF><TMVAR2:21:11:00:000:000:/TN~~~><ENDREP><REM2:><REM2:Delete everything to the left of the last "/TN".><NMVAR:09:02:0:0000001:0:0000000><TMVAR2:11:11:00:001:N02:><REM2:><REM2:Replace the first 3 characters in what is left with "/TN".><TMVAR2:21:11:00:000:000:~~~/TN> Quote Link to comment Share on other sites More sharing options...
cyberchief Posted September 27, 2005 Author Report Share Posted September 27, 2005 Thanks Joe. Looks great. not quite sure I understand it completely... but I will look closer and figure it out. Appreciate the help!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.