×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Character Substitution Within String

Character Substitution Within String

Character Substitution Within String

(OP)
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

RE: Character Substitution Within String

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.

RE: Character Substitution Within String

(OP)
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

RE: Character Substitution Within String

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.

RE: Character Substitution Within String

(OP)
kiddpete,

Ok, thanks for the info!

RE: Character Substitution Within String

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close