Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: 'find and replace' code  (Read 5796 times)

0 Members and 1 Guest are viewing this topic.

anah

  • Guest
'find and replace' code
« on: September 17, 2008, 05:40:05 AM »
Hello! I'm using Fortran for the first time and I need to write a program which find  all ',' in a text file and replace them with ' '. I can't do it just using 'replace' in 'edit' because I need to produce an .exe file in order to automate its execution.
Thanks a lot in advance!

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: 'find and replace' code
« Reply #1 on: September 17, 2008, 06:28:47 AM »
Fortran has a replace function you can use. Once again Google has all the messy details.

Code: [Select]
REPLACE(string,target,substring,every,back)

Quote
the copy of string is searched for occurrences of target. The search is done in the backward direction if the argument back is present with the value true, and in the forward direction otherwise. If target is found, it is replaced by substring. If every is present with the value true, the search and replace is continued from the character following target in the search direction specified until all occurrences of target in the copy string are replaced; otherwise only the first occurrence of target is replaced.
Source

This should work:

var = replace(string, ',', ' ', True)

Couldn't tell if the replacement is a space or a null. Fix if necessary.

 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein