Category : Files from Magazines
Archive   : DDJ0492.ZIP
Filename : LORENZ.ASC

 
Output of file : LORENZ.ASC contained in archive : DDJ0492.ZIP
_WINDOWS PROGRAMMING WITH BASIC_
by Raymond J. Schneider


[LISTING ONE]

/* Lorenz Equations in GFA BASIC
/* Copyright 1991 Raymond J. Schneider
XEND=0,YEND=0,ZEND=0 //Initializes end of plot run variables
/* Configure and Open Parent Window
pstyle%= WS_OVERLAPPEDWINDOW
OR pstyle%, WS_CLIPCHILDREN
OR pstyle%, WS_VISIBLE
TITLEW #1, "Lorenz Equations"
PARENTW #1,0,0,_X,_Y,pstyle% //Open full window

/* Configure three child windows
cstyle%=0
cstyle%= WS_SYSMENU

/* Title the windows
TITLEW #2, "Lorenz XY-View"
TITLEW #3, "Lorenz YZ-View"
TITLEW #4, "Lorenz ZX-View"

/* Initalize Menu Structure
DIM m$(15)
m$(0)="&Views" //First Menu Item
m$(1)="&XY-View" // Sub-Menu Items
m$(2)="&YZ-View"
m$(3)="&ZX-View"
m$(4)="" // Null-string terminates sub-menus
m$(5)="&Control"
m$(6)="&Set Parameters"
m$(7)="&GO"
m$(8)=""
m$(9)=""
MENU m$( )

/* Main Program
cww%=_X/2-30,chh%=_Y/2-30
ON MENU MESSAGE GOSUB HandleMessage( )
DO
GETEVENT
IF MENU(1)=20 //Then a Menu Selection Has been Pressed
/* Process Menu Selection
SWITCH MENU(0)
CASE 1 // Open XY-View
CHILDW #2,1,5,5,cww%,chh%,cstyle%
CASE 2 // Open YZ-View
CHILDW #3,1,cww%+8,5,cww%,chh%,cstyle%
CASE 3 // Open ZX-View
CHILDW #4,1,5,chh%+8,cww%,chh%,cstyle%
CASE 6 //Set-Parameters
EXIT IF DLGRV&<>0
SetDialog()
DO
SLEEP
UNTIL DLGRV&
TEXT 0,0,"Sigma="+STR$(SIGMA)
TEXT 0,12,"Rho= "+STR$(RHO)
TEXT 0,24,"B= "+STR$(B)
CASE 7 // Calculate Lorenz and Plot in Windows
TOPW #2
IF XEND=0 //Initialization of starting conditions X,Y,Z
X=1
ELSE
X=XEND
ENDIF
IF YEND=0
Y=1
ELSE
Y=YEND
ENDIF
IF ZEND=0
Z=1
ELSE
Z=ZEND
ENDIF
PlotLorenz(X,Y,Z,100,1)
TOPW #3
PlotLorenz(X,Y,Z,100,2)
TOPW #4
PlotLorenz(X,Y,Z,100,3)
ENDSWITCH
ENDIF
IF MENU(1)=4
SWITCH MENU(14)
CASE 2
CLOSEW #2
CASE 3
CLOSEW #3
CASE 4
CLOSEW #4
ENDSWITCH
ENDIF
EXIT IF MENU(1)=4 && MENU(14)=1
LOOP
CLOSEW #1
END

PROCEDURE HandleMessage( )
IF DLG(1)=MENU(15)
ENDIF /*Discard General Messages
DLGRV&=0
hw%=GetParent(MENU(15))
IF hw%=DLG(1)
SWITCH MENU(6)
CASE 100
IF MENU(1)=30
GetText(1,101,SIGMA$)
GetText(1,102,RHO$)
GetText(1,103,B$)
SIGMA=VAL(SIGMA$),RHO=VAL(RHO$),B=VAL(B$)
DLGRV&=MENU(6)
ENDIF
ENDSWITCH
ENDIF
RETURN

PROCEDURE GetText(d|,di&,VAR a$)
LOCAL buffer$
buffer$=SPACE$(100)
IF GetWindowText(DLGITEM(d|,di&),V:buffer$,LEN(buffer$))>0
a$=CHAR{V:buffer$}
ELSE
a$=""
ENDIF
RETURN

PROCEDURE SetDialog()
s%=WS_TABSTOP
sb%=s%
sb%|=BS_DEFPUSHBUTTON
seb%=s%
seb%|=WS_BORDER
seb%|=ES_UPPERCASE
~SetFocus(DLGITEM(1,100))
DLGRV&=0
DIALOG #1,325,175,300,160,"Set Parameters"
DLGBASE UNIT
DEFPUSHBUTTON "OK",100,80,65,14,12,sb%
EDITTEXT "",101,80,10,40,12,seb%
EDITTEXT "",102,80,30,40,12,seb%
EDITTEXT "",103,80,50,40,12,seb%
RTEXT "SIGMA",104,10,10,55,12
RTEXT "RHO",105,10,30,55,12
RTEXT "B",106,10,50,55,12
ENDDIALOG
SHOWDIALOG #1
RETURN

PROCEDURE PlotLorenz(X,Y,Z,N%,I%)
/* SIGMA, RHO, B assumed Global
LOCAL LX,LY,LZ,LX1,LY1,LZ1,DT,j%
LOCAL DX,DY,DZ
PX=_X/4+50,PY=_Y/4+10 // Plot Offsets
LX=X,LY=Y,LZ=Z,DT=.01
FOR j%=1 TO N%
DX=SIGMA*(LY-LX)*DT
DY=(-LX*LZ+RHO*LX-LY)*DT
DZ=(LX*LY - B*LZ)*DT
LX1=LX+DX
LY1=LY+DY
LZ1=LZ+DZ
SWITCH I%
CASE 1 //PLOT XY
LINE LX+PX,LY+PY,LX1+PX,LY1+PY
CASE 2 //PLOT YZ
LINE LY+PX,LZ+PY,LY1+PX,LZ1+PY
CASE 3 //PLOT ZX
LINE LZ+PX,LX+PY,LZ1+PX,LX1+PY
ENDSWITCH
LX=LX1,LY=LY1,LZ=LZ1 // Update function
NEXT j%
XEND=LX,YEND=LY,ZEND=LZ
RETURN







  3 Responses to “Category : Files from Magazines
Archive   : DDJ0492.ZIP
Filename : LORENZ.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/