Topic: Scan string handling function

With the simple program:

    program main
    implicit none
   
    integer:: i, j, k, l
   
    character*13:: text2 = '&&&&45678.2&3'
    character*13:: text3 = '123445678.2&3'
    character*1:: blk = '&'
   
    open(10, file='output.txt', status = 'unknown')
   
    i = scan(blk,text2,back=.true.)
    j = scan(blk,text2,back=.false.)
    write(10,*)'i,j=',i,j
   
    k = scan(blk,text3,back=.true.)
    l = scan(blk,text3,back=.false.)
    write(10,*)'k,l=',k,l
   
    close (10)
   
    end program main

I read in my outpufile output.txt the following values: i = 1, j = 1, k = 1, l = 1. So it looks that scan does not return the position of "blk" in text2 and text3 as I understand it should be. Thx in advance and sorry for the trivial question.

Re: Scan string handling function

You misunderstand position of set and string in scan definition. Invert blk and text2 or text3.

Re: Scan string handling function

Yes, your arguments are backwards in the calls to scan.

Jeff Armstrong
Approximatrix, LLC