forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

calcul a integrale with FTN95 and winio+

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Dič



Joined: 21 Sep 2008
Posts: 3
Location: french

PostPosted: Sat Dec 13, 2008 5:30 pm    Post subject: calcul a integrale with FTN95 and winio+ Reply with quote

Saved :: Message
From: Dič
To:
Posted: Sun Oct 05, 2008 10:27 am
Subject: Calcul integrale with WINIO+ and FORTRAN95
Good morning
Can you help me
I have this program
WINAPP
DOUBLE PRECISION A,B,somme
INCLUDE<windows.ins>
CHARACTER*50 F,s
COMMON A,B,somme,F
INTEGER i,w,N
EXTERNAL TRAP
A=0.0D0
B=0.0D0
somme=0.0D0
N=0

i=winio@('%ca[Calcule une ihtegrale]&')
s='{integral A;B}F(X)dx=somme'
w=winio@('%ob%eq@%cb&',s,0,0)
w=winio@('&')
i=winio@('%fn[Times New Roman]%ts%bf%cnF(X)=(COS(X))**2+(SIN(X))**2&',1.0D0)
i=winio@('%5tl&',1,2,3,4,5)
i=winio@('%ffA=%ta&')
i=winio@('%^rf&',A,TRAP)
i=winio@('%ffB=%ta&')
i=winio@('%^rf&',B,TRAP)

i=winio@('%ffsomme=%ta&')
i=winio@ ('%^rf&',somme,TRAP)
i=winio@('%ffN=%ta&')
i=winio@('%^rd&',N,TRAP)
i=winio@('F=%rs(COS(X))**2+(SIN(X))**2&',F)
i=winio@('%ta %`^12bt[INTEGRATION]',TRAP)


END




FUNCTION TRAP(A,B,F,N)

REAL (KIND=2) A,B,somme


INTEGER I,N
COMMON somme

READ*,A,B
READ*,N
READ( F,*)
DX=(B-A)/N
TRAP=(F(A)+F(B))/2
X=A
DO 10 I=1,N-1
X=X+DX
TRAP=TRAP+F(X)
10 CONTINUE
TRAP=TRAP*DX

somme=TRAP
WRITE(*,*)somme
RETURN
END

Is it possible to read values A,B,N in winio+ edit box after calcul integrale with program and write result (somme) in winio edit box
your very truly
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Dec 13, 2008 6:33 pm    Post subject: Reply with quote

There are several issues with your skeleton. Firstly, you must decide if you want the program to recalculate the integral when you change the values of A, B or N, OR when the user presses the INTEGRATION button. (You can do both things if you want).

If you want the process of integration to proceed when you update the values, then you do need a callback function associated with each %rf box. If you don't want this, then you don't need the callback. Of course, if you want the update when the values are changed, then why have the button? (it is pointless, as the recalculation is done when the values are changed).

The callback function TRAP needs to be an INTEGER FUNCTION, and it can't have any parameters, just (), so that affects how you pass A and B to it, and get back the result somme (use COMMON).

Next, you have a function F. You can't simply put this in a character string and invoke it in a subprogram, Fortran doesn't work like that. You could define a function in a subprogram, or code the function in TRAP. Once you have evaluated the numeric result for somme, then CALL WINDOW_UPDATE@(somme) and the window containing somme will update. Your %rf box is user-editable: I suggest that you make it not editable and remove the callback, as you would need a lot more code to recover the parameters from a user-defined result!

The Integer function TRAP doesn't return the result of the calculation, but 0 or 1 which is a success or failure code. The result needs to come back through COMMON (or using MODULEs)

If you want to be able to write the function to be integrated, and then let your program parse that at run-time, you have a huge programming job. I have seen code to do the job, but I can't find it now on the web.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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