include -- ファイルの読み込み2015年03月14日 10:28

以前、ファイル関連のモジュールを作成したとき、ファイルの読み込み機能"include"を使いました。これは 、Watcom Fortran77のソースプログラム中にファイルを読み込むものでした。これ以外の用途には使えません。 汎用的に使えると便利そうです。include -- ファイルの読み込みを紹介します。

テキストファイル中に、別ファイルを取り込みます。

RATFOR版は下記の通り。

# include.r4 -- replace include file by contents of file
      character line(MAXLINE), str(MAXLINE)
      integer equal, getlin, getwrd, fopen
      integer infile(NFILES), len, level, loc
      string incul "include"

      infile(1) = STDIN
      for (level = 1; level > 0; level = level - 1) {
          while (getlin(line,infile(level)) != EOF) {
              loc = 1
              len = getwrd(line,loc,str)

              if (equal(str,incul) .ne. 1)
                  call putlin(line,STDOUT)
              else {
                  level = level + 1
                  if (level .gt. NFILES)
                      call error('includes nested deeply.')
                  len = getwrd(line,loc,str)
                  if (fopen(infile(level),str,READ) .eq. ERR)
                      call cant(str)
                  }
              }
          if (level .gt. 1)
              call fclose(infile(level))
          
          }
      stop
      end

Watcom Fortran版は下記の通り。

c include.for -- replace include file by contents of file
      program include
      integer*1 line(82),str(82)        ! MAXLINE(82)
      integer*1 getlin
      integer getwrd
      integer equal,fopen
      integer infile(10),len,level,loc  ! NFILES(10)
      integer*1 incul(8)
      data incul /'i','n','c','l','u','d','e',-2/ ! EOS(-2)

      call initfile

      infile(1) = 5                     ! STDIN(5)
      level = 1
      while (level .gt. 0) do
          while (getlin(line,infile(level)) .ne. -1) do ! EOF(-1)
              loc = 1
              len = getwrd(line,loc,str)

              if (equal(str,incul) .ne. 1) then
                  call putlin(line,6)      ! STDOUT(6)
              else
                  level = level + 1
                  if (level .gt. 10) then ! NFILES(10)
                      call error('includes nested deeply.')
                  end if
                  len = getwrd(line,loc,str)
                  if (fopen(infile(level),str,82) .eq. -1) then ! READ(82) ERR(-1)
                      call cant(str)
                  endif
              end if
          end while
          if (level .gt. 1) then
              call fclose(infile(level))
          end if
          level = level - 1
      end while

      stop
      end

下請けルーチン、getwrd()は下記の通り。

# getwrd.r4 -- get non-blank word from in(i) into out, increment j
      integer function getwrd(in,i,out)
      character in(ARB),out(ARB)
      integer i,j
      
      while (in(i) == BLANK | in(i) == TAB) 
          i = i + 1

      j = 1
      while (in(i) != EOS & in(i) != BLANK
          & in(i) != TAB & in(i) .ne. NEWLINE) {
          out(j) = in(i)
          i = i + 1
          j = j + 1
          }
      out(j) = EOS
      getwrd = j - 1
      return
      end

Watcom Fortran77版は下記の通り。

c getwrd.for -- get non-blank word from in(i) into out, increment j
      integer function getwrd(in,i,out)
      integer*1 in(*),out(*)            ! ARB(*)
      integer i,j
      
      while ((in(i) .eq. 32) .or. (in(i) .eq. 9)) do ! BLANK(32) TAB(9)
          i = i + 1
      end while

      j = 1
      while (in(i) .ne. -2 .and. in(i) .ne. 32       ! EOS(-2) BLANK(32)
     1    .and. in(i) .ne. 9 .and. in(i) .ne. 10) do ! TAB(9) NEWLINE(10)
          out(j) = in(i)
          i = i + 1
          j = j + 1
      end while
      out(j) = -2                       ! EOS(-2)
      getwrd = j - 1
      return
      end

コメント

_ luidji ― 2015年04月13日 05:49

_ Plenty Of Fish Ottawa ― 2015年10月18日 05:12

I read this post completely regarding the difference of latest and earlier technologies, it's amazing article.

_ quest bars nutritional information ― 2015年10月18日 21:06

Please let me know if you're looking for a article author for your site. You have some really good posts and I feel I would be a good asset. If you ever want to take some of the load off, I'd really like to write some content for your blog in exchange for a link back to mine. Please blast me an email if interested. Many thanks!

_ Match.com Free Trial ??? ― 2015年10月21日 08:07

Hello, I want to subscribe for this web site to get hottest updates, therefore where can i do it please help.

_ match free trial promo code 2015 ― 2015年10月23日 12:49

I enjoy what you guys tend to be up too. Such clever work and reporting! Keep up the terrific works guys I've included you guys to blogroll.

_ promo code for match free trial ― 2015年10月23日 14:53

Hello, i think that i noticed you visited my blog so i came to return the want?.I am trying to find things to enhance my web site!I assume its ok to use a few of your ideas!!

_ pure forskolin' ― 2015年11月04日 00:18

I was more than happy to find this web site. I wanted to thank you for ones time for this
particularly wonderful read!! I definitely savored every little bit of it and I
have you saved to fav to look at new stuff in your web site.

_ nutra forskolin reviews ― 2015年11月04日 10:26

Hi there colleagues, how is everything, and what you desire
to say on the topic of this paragraph, in my view its genuinely remarkable designed for me.

_ forskolin belly buster ― 2015年11月05日 16:34

Amazing things here. I am very glad to look your post.
Thanks a lot and I'm looking forward to touch you.
Will you please drop me a e-mail?

_ plenty of fish dating site of free dating ― 2015年11月06日 09:02

Your style is really unique compared to other folks I've read
stuff from. Thanks for posting when you have the opportunity, Guess I will
just book mark this page.

_ plenty of fish dating site of free dating ― 2015年11月06日 17:47

Hello! Quick question that's completely off topic. Do you
know how to make your site mobile friendly? My weblog looks weird when browsing from my
apple iphone. I'm trying to find a template or plugin that
might be able to fix this problem. If you have any
recommendations, please share. Thank you!

_ plenty of fish dating site of free dating ― 2015年11月07日 01:36

Wow, marvelous blog layout! How long have you
been blogging for? you made blogging look easy.
The overall look of your web site is magnificent,
let alone the content!

_ Justin bieber Dating ― 2015年11月09日 06:57

Saved as a favorite, I really like your site!

_ kroger feedback ― 2015年11月13日 07:28

These are actually wonderful ideas in concerning blogging.
You have touched some pleasant things here. Any way keep up wrinting.

_ Kroger Log In Digital Coupons ― 2015年11月15日 17:27

If you want to increase your knowledge simply keep visiting this web page and be updated with the hottest news posted here.

_ quest protein bars ― 2015年11月17日 20:25

Hey there! Someone in my Myspace group shared this website with us so I came to look it over.
I'm definitely loving the information. I'm
book-marking and will be tweeting this to my followers! Great blog and wonderful design.

_ plenty of fish ― 2015年11月21日 17:52

I’m not that much of a online reader to be honest but your sites really nice, keep it up!
I'll go ahead and bookmark your website to come back later on. Cheers

_ plenty of fish ― 2015年11月27日 07:01

What's Taking place i am new to this, I stumbled upon this I've discovered It absolutely
helpful and it has helped me out loads. I am hoping to give a contribution & assist different users like its aided me.

Great job.

_ plenty of fish dating site of free dating ― 2015年11月29日 02:41

This article is genuinely a fastidious one it assists
new web people, who are wishing in favor of
blogging.

_ quest bars ― 2015年11月29日 22:26

Asking questions are genuinely fastidious thing if you are not understanding something fully,
except this article presents good understanding yet.

_ quest Bar nutrition ― 2015年11月29日 22:29

I was recommended this web site by my cousin. I'm not sure whether this post is written by him as no one else know such detailed about my problem.

You're amazing! Thanks!

_ plenty of fish ― 2015年12月01日 01:52

I was recommended this website by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty.
You are amazing! Thanks!

_ plenty of fish dating site of free dating ― 2015年12月03日 01:21

It is in reality a nice and useful piece of information. I am satisfied that you just shared this helpful information with us.
Please keep us informed like this. Thanks for sharing.

_ www.krogerfeedback.com ― 2015年12月05日 09:12

This is the perfect web site for everyone who really wants to understand this
topic. You know so much its almost tough to argue with you
(not that I actually would want to…HaHa). You certainly put a brand new spin on a topic which has been written about for many years.
Excellent stuff, just great!

_ krogerfeedback.com ― 2015年12月06日 15:40

Excellent article. I'm facing some of these issues as well..

_ www.krogerfeedback.com ― 2015年12月08日 02:51

Hello I am so grateful I found your website, I really found you by accident, while I was researching
on Yahoo for something else, Anyways I am here now and would just like to say
thank you for a remarkable post and a all round interesting blog (I
also love the theme/design), I don’t have time to read it all
at the moment but I have saved it and also added your RSS feeds, so when I have time I will be back to read a great deal more,
Please do keep up the superb b.

_ tinyurl.com ― 2015年12月08日 03:55

If you are going for finest contents like me, simply visit this site all the time for the reason that it presents quality contents, thanks

_ www.krogerfeedback.com ― 2015年12月12日 18:51

I know this if off topic but I'm looking into
starting my own blog and was wondering what
all is required to get setup? I'm assuming having a blog like yours would cost a pretty penny?
I'm not very internet smart so I'm not 100% positive. Any tips or advice would
be greatly appreciated. Cheers

_ bajar facebook ― 2015年12月18日 18:35

Awesome things here. I'm very happy to look your article.
Thank you so much and I am taking a look ahead
to touch you. Will you please drop me a mail?

_ Krogerfeedback.com ― 2015年12月31日 17:15

Nice post. I learn something totally new and challenging on sites I stumbleupon everyday.
It's always exciting to read through articles from other
authors and practice a little something from other sites.

_ Quest Bars ― 2016年02月09日 10:18

Fantastic post however , I was wanting to know if you could write a litte more on this subject?
I'd be very thankful if you could elaborate a little bit further.
Kudos!

_ quest bars ― 2016年02月09日 17:27

Thank you for the auspicious writeup. It in reality used to
be a entertainment account it. Look complicated to more added
agreeable from you! By the way, how could we communicate?

_ quest bars ― 2016年02月19日 18:14

For hottest news you have to pay a quick visit internet and
on world-wide-web I found this web page as a best site for hottest
updates.

_ bernie sanders ― 2016年04月01日 02:16

Asking questions are actually nice thing if you are not understanding anything totally,
except this post presents pleasant understanding even.

_ krogerfeedback ― 2016年06月06日 02:50

Hello! This is kind of off topic but I need some advice from an established blog.

Is it very difficult to set up your own blog? I'm not very
techincal but I can figure things out pretty quick. I'm thinking about setting up my own but I'm not sure where to
start. Do you have any tips or suggestions? Many thanks

_ quest bars cheap ― 2016年06月13日 08:32

I constantly spent my half an hour to read this
weblog's content all the time along with a cup of coffee.

_ Mincraft ― 2016年07月03日 01:57

Excellent post. I used to be checking continuously this weblog and
I am inspired! Extremely helpful information specially the final
part :) I take care of such information a
lot. I was looking for this certain information for a long time.
Thanks and good luck.

_ j.mp ― 2016年07月09日 14:09

Hi there to all, how is all, I think every one is getting more from this website, and
your views are fastidious for new people.

_ www.krogerfeedback.com ― 2016年07月14日 18:51

Hi, yup this paragraph is truly pleasant and I have learned lot of things from it
regarding blogging. thanks.

_ www.krogerfeedback.com ― 2016年07月26日 04:07

naturally like your website however you have to take
a look at the spelling on several of your posts. Several
of them are rife with spelling problems and I in finding it very bothersome to inform the truth however I will certainly
come back again.

_ kroger digital coupons ― 2016年07月28日 04:58

Hello to every one, the contents existing at this web page are genuinely awesome
for people experience, well, keep up the good work fellows.

_ kroger digital coupons ― 2016年07月29日 15:17

When I initially commented I clicked the "Notify me when new comments are added" checkbox and now each
time a comment is added I get several emails with the
same comment. Is there any way you can remove me from that service?
Many thanks!

_ www.krogerfeedback.com ― 2016年07月30日 18:05

I love reading an article that will make men and women think.
Also, many thanks for allowing for me to comment!

_ Mincraft ― 2016年08月12日 14:36

We're a group of volunteers and opening a new scheme in our community.
Your web site offered us with valuable info to work on. You've done a formidable job and our entire community will be thankful
to you.

_ fix connections to bluetooth audio devices and wireless displays in windows 10 ― 2016年08月19日 06:24

You made some good points there. I looked on the web for
more info about the issue and found most individuals will go along with your views
on this web site.

_ Mincraft ― 2016年08月25日 22:54

It is appropriate time to make a few plans for the long run and it's time to be happy.
I've read this submit and if I may I wish to suggest you few fascinating issues or advice.
Maybe you could write next articles regarding this
article. I wish to read even more things approximately it!

_ Mincraft ― 2016年08月28日 15:41

This is my first time go to see at here and i am genuinely happy to read all at one place.

_ Mincraft ― 2016年08月31日 09:05

I all the time emailed this webpage post page to all my associates,
for the reason that if like to read it next my links will too.

_ Windows 10 Free Upgrade ― 2016年09月17日 11:23

Hi, I do think this is a great website. I stumbledupon it ;) I may return yet again since I bookmarked it.
Money and freedom is the best way to change,
may you be rich and continue to guide others.

_ quest bars ― 2016年09月25日 00:04

After exploring a few of the articles on your site, I seriously appreciate your technique of blogging.
I added it to my bookmark site list and will be checking back soon. Please check out my web site as well and let me know
what you think.

※コメントの受付件数を超えているため、この記事にコメントすることができません。

トラックバック

このエントリのトラックバックURL: http://kida.asablo.jp/blog/2015/03/14/7590253/tb