Silverfrost Forums

Welcome to our forums

error program

22 Jan 2013 3:48 #11441

hi, I'm a university student of engineering and I need to learn how to use clearwin because I have to create a program for my final graduation! then I found the guide of clearwin+ and I started to learn but the program give me an error and I don't understand what I have to do!

the guide writes: 1 WINAPP 0,0,'CWP_ICO.RC' 2 3 PROGRAM factor1 4 IMPLICIT NONE 5 INCLUDE <windows.ins> 6 INTEGER ans,number 7 number=1 8 ans=winio@('%ca[Number Factoriser]&') 9 ans=winio@('%il&%',1,2147483647) 10 ans=winio@('Number to be factorised: %rd',number) 11 END

silverfrost answer me:error 28 - PROGRAM cannot be declared inside PROGRAM block (perhaps missing CONTAINS or END statement?)

where is the problem? please help me and sorry for my terrible english! Diana

22 Jan 2013 4:17 #11443

Tutorial inside the guide is horribly dated using Fortran77 syntax. I would probably rewrite it in Fortran90, use modules and get rid of common blocks...

Following should compile and run fine:

WINAPP
program factor1
  use mswin
  implicit none

  integer :: ans, number
  number=1
  ans=winio@('%ca[Number Factoriser]&')
  ans=winio@('%il&',1,2147483647)
  ans=winio@('Number to be factorised: %rd',number)
end program factor1

By the way... Your english is just fine.

22 Jan 2013 4:55 #11444
module factor
  use mswin
  implicit none

  integer :: number = 1
  character (len=50) :: str = ''

  contains

    function factoriser()
      integer :: factoriser
      integer :: n, k
      character (len=50) :: val

      write(val,'(i11)') number
      call trim@(val)
      str='The factors of '//val(1:LENG(val))//' are: 1'
      n=number
      1 do k=2,n
          if((n/k)*k==n) then
            write(val,'(i11)')k
            call trim@(val)
            call append_string@(str,', '//val)
            n=n/k
            if(n>1) goto 1
          endif
        end do
      call window_update@(str)
      factoriser = 1
    end function factoriser


    function about()
      integer :: about
      integer :: ans

      ans=winio@('%ca[About Number Factoriser]&')
      ans=winio@('%fn[Times New Roman]%ts%bf%cnTutorial&',2.0D0)
      ans=winio@('%ts%4nl&',1.0D0)
      ans=winio@('%cnProgram written to demonstrate%2nl&')
      ans=winio@('%ts%tc%cn%bfClearWin+&',1.5D0,RGB@(255,0,0))
      ans=winio@('%tc%sf%2nl%cnby&',-1)
      ans=winio@('%2nl%cnSalford Software&')
      ans=winio@('%2nl%cn%9`bt[OK]')
      about=1
    end function about
    
end module factor


winapp
program factor6
  use factor
  implicit none

  integer :: ans
  ans=winio@('%ca[Number Factoriser]&')
  ans=winio@('%mn[&File[E&xit]]&','EXIT')
  ans=winio@('%mn[&Help[&About Number Factoriser]]&',about)
  ans=winio@('%il&',1,2147483647)
  ans=winio@('Number to be factorised: %rd&',number)
  ans=winio@('%ta%`^bt[Fac&torise]&',factoriser)
  ans=winio@('%2nl%ob%42st%cb',str)
end program factor6
25 Jan 2013 9:07 #11486

thank you so much! now it's perfect!

Please login to reply.