|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
diana.g
Joined: 22 Jan 2013 Posts: 2
|
Posted: Tue Jan 22, 2013 4:48 pm Post subject: error program |
|
|
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 |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Jan 22, 2013 5:17 pm Post subject: |
|
|
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:
Code: |
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. |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Jan 22, 2013 5:55 pm Post subject: |
|
|
Code: |
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
|
|
|
Back to top |
|
|
diana.g
Joined: 22 Jan 2013 Posts: 2
|
Posted: Fri Jan 25, 2013 10:07 am Post subject: |
|
|
thank you so much! now it's perfect! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|