ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » SUBSTRING

Post new topic  Reply to topic
 SUBSTRING « View previous topic :: View next topic » 
Author Message
wmqiadmin
PostPosted: Tue Mar 06, 2007 7:48 am    Post subject: SUBSTRING Reply with quote

Disciple

Joined: 19 Jun 2005
Posts: 163
Location: epping UK

I am trying to substring an incomming string....my code is

DECLARE msgLen INT;
DECLARE msgFinLen INT;
SET msgLen = LENGTH(myChar);
SET msgFinLen = msgLen-19;
SET myChar = SUBSTRING(myChar FROM 18 FOR msgFinLen);

the substring function doesn't trucate the last 19 characters its only trucating last 2 charactes....

Can any buddy explain me what I am doing wrong or is some thing wrong with the code.

thanks
wmqiadmin
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 06, 2007 7:50 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Your substring is going to start reading at the 18th character.

It will then take however many characters are left, but not more than msgFinLen.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wmqiadmin
PostPosted: Tue Mar 06, 2007 8:00 am    Post subject: Reply with quote

Disciple

Joined: 19 Jun 2005
Posts: 163
Location: epping UK

jefflowrey wrote:
Your substring is going to start reading at the 18th character.

It will then take however many characters are left, but not more than msgFinLen.


That is true I want to remove first 18 char and last 18 char from the string.... but this code is removing the first 18 char that is working fine but not removing the last 19 char... its just truncating last 2 char...

any idea why??
Back to top
View user's profile Send private message
wmqiadmin
PostPosted: Tue Mar 06, 2007 8:01 am    Post subject: Reply with quote

Disciple

Joined: 19 Jun 2005
Posts: 163
Location: epping UK

last 19 char...sorry
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 06, 2007 8:05 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

jefflowrey wrote:
It will then take however many characters are left, but not more than msgFinLen.

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
special_agent_Queue
PostPosted: Tue Mar 06, 2007 9:23 am    Post subject: Reply with quote

Centurion

Joined: 27 Jul 2006
Posts: 102

Quote:
I am trying to substring an incomming string....my code is

DECLARE msgLen INT;
DECLARE msgFinLen INT;
SET msgLen = LENGTH(myChar);
SET msgFinLen = msgLen-19;
SET myChar = SUBSTRING(myChar FROM 18 FOR msgFinLen);

the substring function doesn't trucate the last 19 characters its only trucating last 2 charactes....

Can any buddy explain me what I am doing wrong or is some thing wrong with the code.


Let's say you have a 10 character string, but you only want characters 4,5,6, and 7.

The length of the string is 10.
You don't want the last 3.
So you set the length to go for to 10-3 = 7.
Then you start at character 4.
So from 4, for a length of 7.
And that equals ----> 4,5,6,7,8,9,10.

As you can see, you only wanted 4 characters, but ended up with 7.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Mar 06, 2007 10:03 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

special_agent_Queue wrote:
As you can see, you only wanted 4 characters, but ended up with 7.


I'd say "asked for" not "ended up with".
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Lisa
PostPosted: Tue Mar 06, 2007 10:33 am    Post subject: Reply with quote

Master

Joined: 07 Jun 2002
Posts: 287
Location: NJ

special_agent_Queue wrote:
Quote:
I am trying to substring an incomming string....my code is

DECLARE msgLen INT;
DECLARE msgFinLen INT;
SET msgLen = LENGTH(myChar);
SET msgFinLen = msgLen-19;
SET myChar = SUBSTRING(myChar FROM 18 FOR msgFinLen);

the substring function doesn't trucate the last 19 characters its only trucating last 2 charactes....

Can any buddy explain me what I am doing wrong or is some thing wrong with the code.


Let's say you have a 10 character string, but you only want characters 4,5,6, and 7.

The length of the string is 10.
You don't want the last 3.
So you set the length to go for to 10-3 = 7.
Then you start at character 4.
So from 4, for a length of 7.
And that equals ----> 4,5,6,7,8,9,10.

As you can see, you only wanted 4 characters, but ended up with 7.


It should read You don't want the first 3., not last 3.
Back to top
View user's profile Send private message Send e-mail
special_agent_Queue
PostPosted: Tue Mar 06, 2007 11:32 am    Post subject: Reply with quote

Centurion

Joined: 27 Jul 2006
Posts: 102

jefflowrey wrote:
special_agent_Queue wrote:
As you can see, you only wanted 4 characters, but ended up with 7.


I'd say "asked for" not "ended up with".

Good point.

Lisa wrote:

It should read You don't want the first 3., not last 3.


It SHOULD be both, but I was going through the process that wmqiadmin went through, and attempting to lead him to that conclusion.
Back to top
View user's profile Send private message
wmqiadmin
PostPosted: Tue Mar 06, 2007 12:56 pm    Post subject: Reply with quote

Disciple

Joined: 19 Jun 2005
Posts: 163
Location: epping UK

Thanks Guys,

special_agen_queue is correct.

After doing finalLeng = Orig-35 i was able to get the actual message what i was looking for. Where initially i was just removing the last characters not the initial ones.

Thanks once again guys for all your support.

wmqiadmin
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » SUBSTRING
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.