Silverfrost Forums

Welcome to our forums

How to find if a short string is present in a long string?

26 Apr 2011 12:46 #8127

Is there a brief subroutine or function in FTN95 that can take two strings as arguments, and tell me if String A is present in String B?

If I have:

CHARACTER5 StringA CHARACTER250 StringB StringA='Hello' StringB='Is Jim writing yet another Hello World program?'

Is there a function or something, that can return a positive integer value (or a logical .TRUE.) if StringA is present in StringB, as it is in this example?

SCAN won't quite do it - I believe it tells me if any single character from StringB is present in StringA. (correct?)

26 Apr 2011 12:48 #8128

Whoops! Found it! INDEX is the function.

26 Apr 2011 11:24 #8132

I always find that finding the error in a program is best carried out by asking any random person the question and by the time you have asked it you will have found the answer yourself. Ian

26 Apr 2011 2:05 #8133

Not only are there lots of functions in Fortran-90/95, Silverfrost FTN95 contains all (I think) of the additional functions from the Salford FTN77 compiler, which are documented in the FTN77 Library Reference manual, provided online in the documentation section of this website.

Eddie

26 Apr 2011 4:05 #8134

Quoted from IanLambley I always find that finding the error in a program is best carried out by asking any random person the question and by the time you have asked it you will have found the answer yourself.

This is true - what my esteemed programmer ex-colleague Roger Staff used to refer to as deployment of 'the man on the Clapham omnibus'. Except he didn't say deployment - dear me, no, such words had mercifully not yet been hijacked into a software context. He did say words like recursive and re-entrant, though, sometimes in conjunction. That used to scare me even more than <whispers> C++</whispers> (sorry, Ian), and still does. The re-entrant word, anyway.

Please login to reply.