Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Substitution Within String

Status
Not open for further replies.

Sean466

Programmer
Mar 27, 2003
12
0
0
CA
Hi,

Is there a mechanism/function in WebFocus to substitute all occurrences of a character to a string? I know that CTRAN can replace a character 1-for-1, but I want to replace one character with 2 characters. Specifically, I want to replace all occurrences of double-quote for backslash plus double-quote (" -> \"). Also note that I don't know in advance the location(s) of this character within the string.

Thanks for any help!

Sean
 
At what level does this need to be done? Is it something like DEFINE and TABLE, or is it Dialogue Manager? I don't know of any routines which do this, but the logic can be built using, for example, POSIT and SUBSTR. POSIT to find the character, and SUBSTR to break the string apart to allow a concatenation.

This can be done fairly easily in Dialogue Manager, MODIFY, or MAINTAIN.
 
Thanks for the reply kiddpete!

Ideally, I would like to be able to do this within a DEFINE FILE. I looked at POSIT, but it appears to me that I can only find the position of the first occurrence, so that was a non-starter. So I have been unsure whether this can be accomplished using POSIT or SUBSTR (or OVRLAY).

Any pointers would be appreciated!

Thanks,
Sean
 
That is right, you only find the first occurance with POSIT, but that's all you need. You structured this question as an unknown number of occurances in unknown positions. That means my strategy is to find the first one, replace it, and check for another. When I can't find any more, I'm done.

This means I must loop until all are replaced. As I said, Dialogue Manager, MODIFY, or MAINTAIN can support this kind of procedural logic. I don't think DEFINE can, but maybe someone else will see how to do this and we'll both learn something. I am certainly not aware of anything in Focus which will replace all occurances simultaneously which is what DEFINE would need to do.
 
There may be a solution to your problem.

I've never done this, but I know it's possible to create your own fuctions with the language of your choice. You could write something in C that does what you need, put it on your WebFOCUS server, then call the function inside your DEFINE FILE.

The WebFOCUS manual "Using Functions" mentions this. Appendix A goes into a bit of detail with a FORTRAN example.

Good luck!
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top