New User Question 
Author Message
 New User Question


then in REXX you would do something like:

IF POS('%40',STRING)>0 THEN DO
   PARSE VALUE STRING WITH PRE'%40'SUFF

END


the variables 'PRE' & 'SUFF' are not defined anywhere else in the program.
This may cause problems if they are.

The PARSE command has several different ways of being coded. I recommend you
look over the command if you try anything else with it. If you don't have a
manual at work, try http://www.*-*-*.com/
somewhere on this site are the REXX manuals for MVS/OS390 mainframes, among
others.



Sun, 21 Oct 2001 03:00:00 GMT  
 New User Question

Quote:

>IF POS('%40',STRING)>0 THEN DO
>   PARSE VALUE STRING WITH PRE'%40'SUFF

>END

Will the parse really work like that?    Even if it will, it might be
better (for purposes of self-documentation) to write it as

      parse var string    pre  '%40'   suff

Then he needs to iterate until there are no more "%40" substrings:

    do forever
       if Pos("%40" , string) = 0 then leave
       parse var string   pre "%40"  suff

    end  /* forever */

Frank Clarke
Tampa Area REXX Programmers' Alliance (TARPA)
Member of the REXX Language Assn
  Join us at http://www.rexxla.org
(remove currency symbol when replying)



Mon, 22 Oct 2001 03:00:00 GMT  
 New User Question

:>I was recently given the responsibility of fixing a problem with a REXX
:>script in use by my company.  The problem is that I have never seen REXX
:>before.  It seems to be pretty self-explanitory, but I cannot find the answer
:>for what I would like to do.  I have searched numerous tutorials and the REXX
:>FAQ (only 10 or so questions?!?) to no avail.

:>As it stands is, there is a  Perl script on the web server that is calling
:>the REXX script which resides on the mainframe.  One of the arguments that it
:>passes is an email address that must be stored in the database that REXX
:>talks to.  The problem is that the HTTP request to the REXX script urlencodes

:>that it only happens sometimes anyway (ugh!).

:>There are two possible solutions to my problem that I can think of: One is
:>that REXX is smart enough that I can simply tell it that the string was
:>urlencoded and it will fix if for me.  Not likely, I am guessing.  The other
:>is that I would like to simply add another line that would look something
:>like this:


:>...but from what I understand the translate() function only handles one
:>character at a time.  So, that's not too much help either!

:>If there is someone out there who knows the answer to this problem, I would
:>love to hear from you.

The following code fragment will do the job.

   jj = POS('%40',instring)                                              
   DO  WHILE  jj > 0                                                      

       jj = POS('%40',instring)                                          
       END

Would this be a lot easier in Perl?

How would you do it in Perl?

--


http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel



Mon, 22 Oct 2001 03:00:00 GMT  
 New User Question

a = 'ballen fruit.com'
say a
ballen fruit.com

say b

Is that what you want?

Bill

Quote:


> :>I was recently given the responsibility of fixing a problem with a REXX
> :>script in use by my company.  The problem is that I have never seen REXX
> :>before.  It seems to be pretty self-explanitory, but I cannot find the answer
> :>for what I would like to do.  I have searched numerous tutorials and the REXX
> :>FAQ (only 10 or so questions?!?) to no avail.

> :>As it stands is, there is a  Perl script on the web server that is calling
> :>the REXX script which resides on the mainframe.  One of the arguments that it
> :>passes is an email address that must be stored in the database that REXX
> :>talks to.  The problem is that the HTTP request to the REXX script urlencodes

> :>that it only happens sometimes anyway (ugh!).

> :>There are two possible solutions to my problem that I can think of: One is
> :>that REXX is smart enough that I can simply tell it that the string was
> :>urlencoded and it will fix if for me.  Not likely, I am guessing.  The other
> :>is that I would like to simply add another line that would look something
> :>like this:


> :>...but from what I understand the translate() function only handles one
> :>character at a time.  So, that's not too much help either!

> :>If there is someone out there who knows the answer to this problem, I would
> :>love to hear from you.

> The following code fragment will do the job.

>    jj = POS('%40',instring)
>    DO  WHILE  jj > 0

>        jj = POS('%40',instring)
>        END

> Would this be a lot easier in Perl?

> How would you do it in Perl?

> --


> http://www.dissensoftware.com

> Director, Dissen Software, Bar & Grill - Israel

  vcard.vcf
< 1K Download


Mon, 22 Oct 2001 03:00:00 GMT  
 New User Question

Quote:
>>IF POS('%40',STRING)>0 THEN DO
>>   PARSE VALUE STRING WITH PRE'%40'SUFF

>>END

>Will the parse really work like that?    Even if it will, it might be
>better (for purposes of self-documentation) to write it as

>      parse var string    pre  '%40'   suff

honestly, I am not familiar with the VAR flavor of the PARSE statement. I do
not put spaces in the VALUE flavor because I assumed it would try to find
the spaces in between the pre,'%40', and suff in your example. As far as
self-documentation is concerned, I don't use the VAR flavor so what I wrote
looks self documenting to me. A good example of how the same thing can be
done in different ways. I also use the VALUE clause because it allows me to
fit more PARSE'ing clauses on one line. I don't like to split the PARSE over
many lines. Thus I am forced to break the parsing down into smaller simpler
statements....but that is neither here nor there.

Quote:

>Then he needs to iterate until there are no more "%40" substrings:

I made an assumption that there would only be one e-mail address in the URL,
if this was a false assumption then I agree with you.


Mon, 22 Oct 2001 03:00:00 GMT  
 New User Question

Quote:

>:>is that I would like to simply add another line that would look something
>:>like this:


>:>...but from what I understand the translate() function only handles one
>:>character at a time.  So, that's not too much help either!

>:>If there is someone out there who knows the answer to this problem, I would
>:>love to hear from you.

>The following code fragment will do the job.

>   jj = POS('%40',instring)                                              
>   DO  WHILE  jj > 0                                                      

>       jj = POS('%40',instring)                                          
>       END

>Would this be a lot easier in Perl?

>How would you do it in Perl?


Regards,
    Tjerk.

--
Tjerk Santegoeds
Basingstoke - UK



Mon, 22 Oct 2001 03:00:00 GMT  
 New User Question


...

Quote:
>As it stands is, there is a  Perl script on the web server that is calling
>the REXX script which resides on the mainframe.  One of the arguments that it
>passes is an email address that must be stored in the database that REXX
>talks to.  The problem is that the HTTP request to the REXX script urlencodes

>that it only happens sometimes anyway (ugh!).
...


>...but from what I understand the translate() function only handles one
>character at a time.  So, that's not too much help either!

You have learned the lesson well. Unfortunately, TRANSLATE didn't help
here. However, let me give my 2ct in...

  Do While Pos('%40',string) > 0; /* do I find the %40 in string ? */
    Parse Var string head '%40' tail; /* yes, so split the thing */

  End; /* Do While */
  /* come here, if nothing found or replaced all */

-wolfram



Tue, 23 Oct 2001 03:00:00 GMT  
 New User Question

[...]
% for what I would like to do.  I have searched numerous tutorials and the REXX
% FAQ (only 10 or so questions?!?) to no avail.

There's a FAQ?

[...]

% talks to.  The problem is that the HTTP request to the REXX script urlencodes

% that it only happens sometimes anyway (ugh!).

Any character could end up being encoded this way.  While you can do a
search and replace on %40, you might be better off looking for % and
converting the next two characters to their ascii values (unless you're
running on an ebcdic machine, in which case just ignore me):
  i = pos('%', string)
  /* comment: this didn't work with regina .08f -- I had to use while i \= 0 */
  do until i = 0
    leftbit = substr(string,1,i-1)
    rightbit = substr(string,i+3)
    char = x2c(substr(string,i+1,2))
    string = leftbit || char || rightbit
    i = pos(string, '%')
    end

% There are two possible solutions to my problem that I can think of: One is
% that REXX is smart enough that I can simply tell it that the string was
% urlencoded and it will fix if for me.

In place of smart, I'd put `specialised'. Smart is when the language can
easily do things it wasn't designed to do.

[...]


translate does transliteration. I heard of a proposal for a replace function,
but I don't know if that went to the ANSI committee or it was just a lot of
talk.

--

Patrick TJ McPhee
East York  Canada



Wed, 24 Oct 2001 03:00:00 GMT  
 New User Question


: [...]
: % for what I would like to do.  I have searched numerous tutorials and the REXX
: % FAQ (only 10 or so questions?!?) to no avail.

: There's a FAQ?

Been one for years :-)

: [...]

: % talks to.  The problem is that the HTTP request to the REXX script urlencodes

: % that it only happens sometimes anyway (ugh!).

: Any character could end up being encoded this way.  While you can do a
: search and replace on %40, you might be better off looking for % and
: converting the next two characters to their ascii values (unless you're
: running on an ebcdic machine, in which case just ignore me):
:   i = pos('%', string)
:   /* comment: this didn't work with regina .08f -- I had to use while i \= 0 */
:   do until i = 0
:     leftbit = substr(string,1,i-1)
:     rightbit = substr(string,i+3)
:     char = x2c(substr(string,i+1,2))
:     string = leftbit || char || rightbit
:     i = pos(string, '%')
:     end
:    
: % There are two possible solutions to my problem that I can think of: One is
: % that REXX is smart enough that I can simply tell it that the string was
: % urlencoded and it will fix if for me.

: In place of smart, I'd put `specialised'. Smart is when the language can
: easily do things it wasn't designed to do.

: [...]


: translate does transliteration. I heard of a proposal for a replace function,
: but I don't know if that went to the ANSI committee or it was just a lot of
: talk.

There is now the changestr() BIF; part of the ANSI standard and implemented
by most interpreters that are being actively maintained (including Regina).
countstr() BIF is also defined.

: Patrick TJ McPhee
: East York  Canada

--
Cheers, Mark
---------------------------------------------------------------------------

* PO Box 203, Bellara, QLD 4507, AUSTRALIA
* Author of THE, a Free XEDIT/KEDIT editor and, Rexx/SQL
* Maintainer of PDCurses: Public Domain Curses and, Regina Rexx interpreter
* Use Rexx? join the Rexx Language Association: http://www.rexxla.org



Fri, 26 Oct 2001 03:00:00 GMT  
 New User Question

Quote:


>: [...]
>: % for what I would like to do.  I have searched numerous tutorials and the REXX
>: % FAQ (only 10 or so questions?!?) to no avail.

[snip]

Quote:
>: % talks to.  The problem is that the HTTP request to the REXX script urlencodes

>: % that it only happens sometimes anyway (ugh!).

>: Any character could end up being encoded this way.  While you can do a
>: search and replace on %40, you might be better off looking for % and
>: converting the next two characters to their ascii values (unless you're
>: running on an ebcdic machine, in which case just ignore me):

[snip]

Just caught this now.

In this situation, it's best to handle the '%##' characters generally.  That
makes changestr(), or something similar, inappropriate.  The following will
work just fine:

do while pos('%',thestring)>0
    parse var thestring before '%' hexval +3 after
    thestring=before||x2c(right(hexval,2))||after
end

That will replace any '%##' sequence with the appropriate ASCII character.

For an EBCDIC system, one would have to map the characters.  Don't have an
EBCDIC machine or table handy, so can't give an example.

--
 - Mike

Remove 'spambegone' to send e-mail.



Sat, 27 Oct 2001 03:00:00 GMT  
 New User Question

Quote:



>>: [...]
>>: % for what I would like to do.  I have searched numerous tutorials and the
> REXX
>>: % FAQ (only 10 or so questions?!?) to no avail.
>[snip]

>>: % talks to.  The problem is that the HTTP request to the REXX script
> urlencodes

> seems
>>: % that it only happens sometimes anyway (ugh!).

>>: Any character could end up being encoded this way.  While you can do a
>>: search and replace on %40, you might be better off looking for % and
>>: converting the next two characters to their ascii values (unless you're
>>: running on an ebcdic machine, in which case just ignore me):
>[snip]

]
]Just caught this now.
]
]In this situation, it's best to handle the '%##' characters generally.  That
]makes changestr(), or something similar, inappropriate.  The following will
]work just fine:
]
]do while pos('%',thestring)>0
]    parse var thestring before '%' hexval +3 after
]    thestring=before||x2c(right(hexval,2))||after
]end
]
]That will replace any '%##' sequence with the appropriate ASCII character.
]
]For an EBCDIC system, one would have to map the characters.  Don't have an
]EBCDIC machine or table handy, so can't give an example.
]

Speaking from (bad) experience, the method used above has a flaw in it that
will eventually reach out and bite you in the behind.  Specifically, if the
character that is 'percent encoded' turns out to be a percent sign, the
routine will in all likelyhood blow up when you try use the x2c function
because you're inserting the decoded percent sign back into the original
string, which POS will find the next time through the loop.  It's fairly easy
to code around:

        OutData = ""
        Do while Pos("%",Data) > 0
           Parse var Data Before "%" +1 Char +2 Data
           OutData = OutData || Before || X2C(Char)
        End
        OutData = OutData || Data
        Data = Translate(OutData," ","+")

I would also recommend that if you plan on passing the decoded string to a
command processor of some sort that you translate out the characters that can
cause problems (above I only removed the + signs, which represent spaces, the
example below will also get rid of the piping and conditional execution
characters):

        Data = Translate(OutData,"     ","&|<>+")

Wayne

Standard Disclaimer: I said it, they didn't so blame me, not them!
Spam Avoidance: My reply address is invalid to confuse the spambots.
You can reach me at 'Wayne dot Tilton at Nike dot Com'



Sat, 27 Oct 2001 03:00:00 GMT  
 New User Question

Quote:





>>>: [...]
>>>: % for what I would like to do.  I have searched numerous tutorials and the
>> REXX
>>>: % FAQ (only 10 or so questions?!?) to no avail.
>>[snip]

>>>: % talks to.  The problem is that the HTTP request to the REXX script
>> urlencodes

>> seems
>>>: % that it only happens sometimes anyway (ugh!).

>>>: Any character could end up being encoded this way.  While you can do a
>>>: search and replace on %40, you might be better off looking for % and
>>>: converting the next two characters to their ascii values (unless you're
>>>: running on an ebcdic machine, in which case just ignore me):
>>[snip]
>]
>]Just caught this now.
>]
>]In this situation, it's best to handle the '%##' characters generally.  That
>]makes changestr(), or something similar, inappropriate.  The following will
>]work just fine:
>]
>]do while pos('%',thestring)>0
>]    parse var thestring before '%' hexval +3 after
>]    thestring=before||x2c(right(hexval,2))||after
>]end
>]
>]That will replace any '%##' sequence with the appropriate ASCII character.
>]
>]For an EBCDIC system, one would have to map the characters.  Don't have an
>]EBCDIC machine or table handy, so can't give an example.
>]

>Speaking from (bad) experience, the method used above has a flaw in it that
>will eventually reach out and bite you in the behind.  Specifically, if the
>character that is 'percent encoded' turns out to be a percent sign, the
>routine will in all likelyhood blow up when you try use the x2c function
>because you're inserting the decoded percent sign back into the original
>string, which POS will find the next time through the loop.  It's fairly easy
>to code around:

>        OutData = ""
>        Do while Pos("%",Data) > 0
>           Parse var Data Before "%" +1 Char +2 Data
>           OutData = OutData || Before || X2C(Char)
>        End
>        OutData = OutData || Data
>        Data = Translate(OutData," ","+")

>I would also recommend that if you plan on passing the decoded string to a
>command processor of some sort that you translate out the characters that can
>cause problems (above I only removed the + signs, which represent spaces, the
>example below will also get rid of the piping and conditional execution
>characters):

>        Data = Translate(OutData,"     ","&|<>+")

I knew there'd be something I neglected to account for.

Using your method also makes the operation faster, as the string to be tested
becomes continually smaller.

Of course, to make it really bullet-proof, one would have to either trap a
syntax error, or determine beforehand that the string passed to x2c() is a
valid hexidecimal number.

--
 - Mike

Remove 'spambegone' to send e-mail.



Sat, 27 Oct 2001 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. New User Question

2. Q: new user questions

3. Screen load order? -- New user question

4. New User Question

5. new user questions

6. New user questions

7. New user question: py2exe with Pmw

8. New User Question: extension types and python 2.2/class/type

9. New user questions ... be gentle

10. New User Question

11. Basic new user questions

12. 2 Basic questions from a new user

 

 
Powered by phpBB® Forum Software