The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Arguments in substring notation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Jose

Netherlands
93 Posts

Posted - 05/10/2000 :  8:38:00 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Some days ago I posted a new topic to the old server (www.microcal.com) that I can not find anywhere now, so I'll try to repeat it.

The documented use of the substring notation is as follows:

If I command

%a=John Smith;
type %[%a,"it"];

I get

John Sm

as "John Sm" is the part of the string %a that comes before the first occurrence of "it" substring.

But if I command


%a=John Smith;
%m="it";
type %[%a,%m];

I get nothing! This would be interesting if I want, for instance, to ask the user for the substring %m to look for, and in many other cases. But it seems impossible to me to get the desired result! Any idea?

jose.

Jose

Netherlands
93 Posts

Posted - 05/10/2000 :  3:04:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Complicated, but it does what I want. Thank you very much!

jose.

Go to Top of Page

greg

USA
1380 Posts

Posted - 05/10/2000 :  12:42:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The argument to the substring notation can not be a string; it must be a literal.

You could write a script along the lines of:

%A=This is test text.;
%M=tes;
for(ii=1;ii<=%[%A]-%[%M]-1;ii++) {
if("%[%A,ii:$(ii+%[%M]-1)]"=="%M") {
type -a Found \x22%M\x22 in \x22%A\x22 at position $(ii);
}
};

to do what you propose.
Go to Top of Page

Jose

Netherlands
93 Posts

Posted - 05/25/2001 :  07:59:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have this file name:

%a=V(t) 2001-05-23 110731 [sample2].dat;


The following instruction works fine to find the position of the "]" character:

loop (ii,1,%[%a]) {if (%[%a,ii:ii]=="]") type $(ii);};

It returns 32.

But if I want to do the same with the "[" charater, it doesn't work!

It seems a conflict with closing brakets in instructions, but I don't know how to overcome it.

I've tried to changed double quotes with simple ones, and even using no quotes at all, but that also doesn't work.

I am using Origin 6.0 SR2.

Any alternative suggestion?

j.

Go to Top of Page

Jose

Netherlands
93 Posts

Posted - 05/25/2001 :  11:03:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Well, after thinking a little bit more, I've changed my IF condition into

if (asc(%[%a,ii:ii])==91)

as the ASCII for "[" is 91. And this works, so everything is alright.

j.

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000