DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Dplot with HTBasic

 
Post new topic   Reply to topic    DPlot Forum Index -> Basic
View previous topic :: View next topic  
Author Message
Lolo15



Joined: 23 Sep 2015
Posts: 3
Location: France

PostPosted: Wed Sep 23, 2015 11:14 am    Post subject: Dplot with HTBasic Reply with quote

Hi,
I start to try DPLOT with HTbasic software (without the Techsoft Add-Ins)
Unfortunately there are no sample code to download on Dplot.com
So please find my code bellow ...

It’s working well for [XY] and [XYXY] data command Laughing
But not really for the [XYZ] command Crying or Very sad
Dplot send me : "Wrong data type"
and
"Error processing this command [XYZ(4,1,2,3,1,20,0,10,2,0,10,20,30)]"

Somebody for help me ?

Regards,
Lolo

!***********************
! HTBASIC/DPLOT SOFTWARE TEST
!***********************
!
CLEAR SCREEN
KEY LABELS OFF
PRINTER IS CRT
DLL UNLOAD ALL
DEG
OPTION BASE 1
!
DIM Disque1$[80]! HTBasic program location
DIM Disque2$[80]! DPLOT DLL location
!
DIM C$[32767]! DPLOT limit --> 1000 Points de Trace
DIM C1$[80]
DIM Title$[80]
!
LONG Retour1 ! DLL Return type Integer/Longbool
REAL Retour2 ! DLL Return type Double
LONG Doc_num ! DDE document index
!
ALLOCATE D1$[80],D2$[80],D3$[80]
!
Npoint=2
ALLOCATE REAL Data_xy1(1:Npoint,1:2)
ALLOCATE REAL Data_xy2(1:Npoint,1:2)
ALLOCATE REAL Data_xyz(1:Npoint,1:Npoint,1:3)
!
!***********************
! Storage Area Definition : HTBasic & DPLOT DLL
!***********************
Disque1$=SYSTEM$("MSI")! Actual HTBasic Program location
!
Bit64: ON ERROR GOTO Bit32
Disque2$="C:\Program Files (x86)"
MASS STORAGE IS Disque2$
OFF ERROR
Bit=64
GOTO Bit
!
Bit32: OFF ERROR
Bit=32
!
Bit: SELECT Bit
CASE 32
Disque2$="C:\Program Files\DPlotJr\dplotlib"
CASE 64
Disque2$="C:\Program Files (x86)\DPlotJr\dplotlib"
END SELECT
!
!***********************
Dll1: ! Load DLL DPLOT : dplotlib
!***********************
DLL UNLOAD ALL
MASS STORAGE IS Disque2$
DISP "---> DPLOT DLL Loading in progress ..."
DLL LOAD "dplotlib"
MASS STORAGE IS Disque1$
DISP
!
!
!***********************
Start: ! HTBasic/DPLOT Start Here
!***********************
GOSUB Version
GOSUB Min_ver
GOSUB Start_dp
!
!-----------------------------------------
! Open DPlot Session
!-----------------------------------------
Doc_num=0
C$="[FileNew()]"
GOSUB Command
!
!-----------------------------------------
! Curve Type Selection
!-----------------------------------------
FOR J=1 TO 8
ON KEY J LABEL "" GOTO Nextj1
Nextj1: NEXT J
ON KEY 1 LABEL "XY curves " GOTO Choice1
ON KEY 2 LABEL "XYXY curve " GOTO Choice2
ON KEY 3 LABEL "XYZ curve " GOTO Choice3
KEY LABELS ON
Wait1: WAIT .1
GOTO Wait1
!
Choice1:Choix=1 ! Courbe XY = pts/pts (Real time application)
GOTO Trace
Choice2:Choix=2 ! Courbe XY = pts>1000
GOTO Trace
Choice3:Choix=3 ! Courbe XYZ
GOTO Trace
!
!
Trace: KEY LABELS OFF
!
!-----------------------------------------
! DPLOT : Back to Front
!-----------------------------------------
C$="[AppHide()]"
GOSUB Command
C$="[AppShow()]"
GOSUB Command
!
SELECT Choix
CASE 1
!
!-----------------------------------------
! 2D curve Definition
!-----------------------------------------
Npoint=500
GOSUB C2d
!
!-----------------------------------------
! Definition Number of Curve & Points
!-----------------------------------------
Maxc=2
Maxp=Npoint*Maxc
C$="[FileArrays("&VAL$(Maxc)&","&VAL$(Maxp)&")]"
GOSUB Command
!
!-----------------------------------------
! Curve Selection & Trace
!-----------------------------------------
Curve=1
C1$="[SelectCurve("&VAL$(Curve)&")]"
GOSUB Xy1
!
!-----------------------------------------
! Curve Selection & Trace [XY]
!-----------------------------------------
Curve=2
C1$="[SelectCurve("&VAL$(Curve)&")]"
GOSUB Xy1
!
CASE 2
!
!-----------------------------------------
! 2D curve Definition
!-----------------------------------------
Npoint=3500
GOSUB C2d
!
!-----------------------------------------
! Definition Number of Curve & Points
!-----------------------------------------
Maxc=1
Maxp=Npoint
C$="[FileArrays("&VAL$(Maxc)&","&VAL$(Maxp)&")]"
GOSUB Command
!
!-----------------------------------------
! Curve Selection & Trace [XYXY]
!-----------------------------------------
Curve=1
C1$="[SelectCurve("&VAL$(Curve)&")]"
GOSUB Xy2
!
CASE 3
!
!-----------------------------------------
! 3D curve Definition
!-----------------------------------------
GOSUB C3d
!
!-----------------------------------------
! Definition Number of Curve & Points
!-----------------------------------------
Maxc=1
Maxp=Npoint
C$="[FileArrays("&VAL$(Maxc)&","&VAL$(Maxp)&")]"
GOSUB Command
!
!-----------------------------------------
! Curve # Selection & Trace [XYZ]
!-----------------------------------------
Curve=1
C1$="[SelectCurve("&VAL$(Curve)&")]"
GOSUB Xyz
!
END SELECT
GOTO Scale
!
!
!-----------------------------------------
Xy1: ! XY Exportation Data to DPLOT
!-----------------------------------------
! C$="[XY(X,Y)]"
!-----------------------------------------
FOR I=1 TO Npoint
SELECT Curve
CASE 1
X=Data_xy1(I,1)
Y=Data_xy1(I,2)
CASE 2
X=Data_xy2(I,1)
Y=Data_xy2(I,2)
CASE ELSE
RETURN
END SELECT
C$=C1$&"[XY("&VAL$(X)&","&VAL$(Y)&")]"
GOSUB Command
NEXT I
RETURN
!
!
!-----------------------------------------
Xy2: ! XYXY Exportation Data to DPLOT
!-----------------------------------------
! C$="[XYXY(N,X1,Y1,X2,Y2,....Xn,Yn)]"
!-----------------------------------------
Nmax=1000 ! DPLOT limitation
Ndebut=0
!
WHILE Nfin<Npoint
!
Ndebut=Ndebut+1
Nfin=Ndebut
Np=Nfin-Ndebut+1
!
WHILE Np<Nmax>=Npoint THEN GOTO Ex_xy2
END WHILE
!
Ex_xy2: D1$="[XYXY("&VAL$(Np)
N1=LEN(D1$)
D3$=")]"
N3=LEN(D3$)
!
N2=32767-(N1+N3)
DEALLOCATE D2$
ALLOCATE D2$[N2]
!
D2$=""
FOR I=Ndebut TO Nfin
X=Data_xy1(I,1)
Y=Data_xy1(I,2)
D2$=D2$&","&VAL$(X)&","&VAL$(Y)
NEXT I
!
C$=C1$&D1$&D2$&D3$
GOSUB Command
!
Ndebut=Nfin
!
END WHILE
PRINT
RETURN
!
!
!-----------------------------------------
Xyz: ! XYZ Exportation Data to DPLOT
!-----------------------------------------
! C$="[XYZ(N,X1,Y1,Z1,X2,Y2,Z2....Xn,Yn,Zn)]"
!-----------------------------------------
Npoint=4
ALLOCATE REAL Valeur(1:Npoint/2,1:Npoint/2,1:3)
!
! -----------
! X/Y | 2 | 20 |
! ----------------
! | 1 | 3 | 0 |
! | 10 | 0 | 30 |
! ----------------
!
Valeur(1,1,1)=1! X point# 1
Valeur(1,1,2)=2! Y
Valeur(1,1,3)=3! Z
!
Valeur(1,2,1)=1! X point# 2
Valeur(1,2,2)=20! Y
Valeur(1,2,3)=0! Z
!
Valeur(2,1,1)=10! X point# 3
Valeur(2,1,2)=2! Y
Valeur(2,1,3)=0! Z
!
Valeur(2,2,1)=10! X point# 4
Valeur(2,2,2)=20! Y
Valeur(2,2,3)=30! Z
!
D1$="[XYZ("&VAL$(Npoint)
D2$=""
!
FOR I=1 TO Npoint/2
FOR J=1 TO Npoint/2
X=Valeur(I,J,1)
Y=Valeur(I,J,2)
Z=Valeur(I,J,3)
D2$=D2$&","&VAL$(X)&","&VAL$(Y)&","&VAL$(Z)
NEXT J
NEXT I
!
D3$=")]"
C$=C1$&D1$&D2$&D3$
C$=D1$&D2$&D3$
GOSUB Command
!
PRINT
RETURN
!
!
!-----------------------------------------
Scale: ! Manual Scale X & Y
!-----------------------------------------
! C$="[ManualScale(xlo,ylo,xhi,yhi,ylo2,yhi2)]"
!-----------------------------------------
Xmin=0
Xmax=10
Xstep=.5
Ymin1=-2! First Axle : Scale Y1
Ymax1=+2
Ystep=.25
Ymin2=0! Second Axle : Scale Y2
Ymax2=0! N/A
Zstep=0! N/A (Curve XY)
!
IF Ymin2<>0 AND Ymax2<>0 THEN
C$="[ManualScale("&VAL$(Xmin)&","&VAL$(Ymin1)&","&VAL$(Xmax)&","&VAL$(Ymax1)&","&VAL$(Ymin2)&","&VAL$(Ymax2)&")]"
ELSE
C$="[ManualScale("&VAL$(Xmin)&","&VAL$(Ymin1)&","&VAL$(Xmax)&","&VAL$(Ymax1)&",,)]"
END IF
GOSUB Command
!
!-----------------------------------------
! Manual Scale Xstep & Ystep
!-----------------------------------------
! C$="[TickInterval(State,dx,dy,dz)]"
!-----------------------------------------
IF Xstep<>0 OR Ystep<>0 THEN State=1
IF Zstep<>0 THEN
C$="[TickInterval("&VAL$(State)&","&VAL$(Xstep)&","&VAL$(Ystep)&","&VAL$(Zstep)&")]"
ELSE
C$="[TickInterval("&VAL$(State)&","&VAL$(Xstep)&","&VAL$(Ystep)&",)]"
END IF
GOSUB Command
!
!-----------------------------------------
! Title 1
!-----------------------------------------
! C$="[Title1("String")]"
!-----------------------------------------
Title$="TEST DPLOT HTBASIC"
C$="[Title1("""
C$=C$&""&Title$&""
C$=C$&""")]"
GOSUB Command
!
!-----------------------------------------
! Xaxis Label
!-----------------------------------------
! C$="[XAxisLabel("String")]"
!-----------------------------------------
Title$="Axe X"
C$="[XAxisLabel("""
C$=C$&""&Title$&""
C$=C$&""")]"
GOSUB Command
!
!-----------------------------------------
! Yaxis Label
!-----------------------------------------
! C$="[YAxisLabel("String")]"
!-----------------------------------------
Title$="Axe Y"
C$="[YAxisLabel("""
C$=C$&""&Title$&""
C$=C$&""")]"
GOSUB Command
!
!
!***********************
! EXIT Menu
!***********************
FOR J=1 TO 8
ON KEY J LABEL "" GOTO Nextj
Nextj: NEXT J
ON KEY 8 LABEL "Suite Exit " GOTO Suite
KEY LABELS ON
Wait: WAIT .1
GOTO Wait
!
Suite: KEY LABELS OFF
C$="[FileClose()]"
GOSUB Command
!
GOSUB Stop_dp
GOTO End
!
!
!***********************
C2d: ! Create Data for 2D curve
!***********************
DEALLOCATE Data_xy1(*)
DEALLOCATE Data_xy2(*)
ALLOCATE REAL Data_xy1(1:Npoint,1:3)! Curve 1
ALLOCATE REAL Data_xy2(1:Npoint,1:3)! Curve 2
!
Xmin=0
Xmax=2*PI
Xstep=Xmax/Npoint
Xi=1
!
RAD
FOR X=Xmin TO Xmax STEP Xstep
Y1=SIN(X)
Y2=ATN(X/2)*(X/5+RND*(.1)+RND*.3-1)
!
Data_xy1(Xi,1)=X! Data
Data_xy1(Xi,2)=Y1! Curve 1
!
Data_xy2(Xi,1)=X! Data
Data_xy2(Xi,2)=Y2! Curve 2
!
IF Xi<Npoint>0
PRINT Retour1
PRINT "WINDOWS handle of the main DPLOT application window"
CASE ELSE
PRINT "(";Retour1;") : DPLOT start"
END SELECT
!
SELECT Hide
CASE 0
PRINT Dplot$&" is Started normaly"
CASE ELSE
PRINT Dplot$&" is invisible to the user"
END SELECT
!
SELECT Was_active
CASE 0
PRINT Dplot$&" Was not already Active"
CASE 1
PRINT Dplot$&" Was already Active"
CASE ELSE
PRINT "Was Active=";Was_active
GOTO End
END SELECT
PRINT
RETURN
!
!
!-------------------------------------
Stop_dp:! STOP DPLOT
!-------------------------------------
! Procedure / VOID=Rien
!-------------------------------------
ON ERROR GOSUB Er_dll
DLL GET "STDCALL VOID DPLOTLIB:DPlot_Stop" AS "Dplot_stop"
OFF ERROR
!
IF Was_active=0 THEN
Dplot_stop
PRINT Dplot$&" stopped ..."
END IF
PRINT
RETURN
!
!
!-------------------------------------
Command:! SEND Command to DPLOT
!-------------------------------------
! Function / INT=LONG
!-------------------------------------
ON ERROR GOSUB Er_dll
DLL GET "STDCALL LONG DPLOTLIB:DPlot_Command" AS "Dplot_command"
OFF ERROR
!
IF Doc_num=0 THEN Index=0
Retour1=FNDplot_command((Doc_num),C$)
!
SELECT Retour1
CASE >0
!PRINT C$&" ---> Success"
!PRINT
IF Index=0 THEN Doc_num=Retour1
CASE 0
PRINT C$&" ---> Error Processing This Command !!!"
PRINT
GOTO End
CASE -1
PRINT C$&" ---> Could Not Find/Excecute DPLOT !!!"
PRINT
GOTO End
CASE -2
PRINT C$&" ---> Could Not Establish a DDE connection with DPLOT !!!"
PRINT
GOTO End
END SELECT
RETURN
!
!
!***********************
Er_dll: ! Verification Chargement DLL
!***********************
SELECT ERRN
CASE 1104 ! Function already loaded
ERROR RETURN
CASE ELSE
PRINT ERRM$,ERRN
PRINT
GOTO End
END SELECT
!
!***********************
End: ! END of PROGRAM
!***********************
PRINT "END OF PROGRAM"
PRINT
LIST DLL
KEY LABELS ON
END[/code][/quote]
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Wed Sep 23, 2015 7:47 pm    Post subject: Reply with quote

Sorry, but there's no sample code because the entire Graph-XT product including source is proprietary. My demo version expired a long time ago so I won't be much help here. You may get a helpful reply here, but I think you'll have better luck on Techsoft's site (or not, since you aren't using their tools).
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Lolo15



Joined: 23 Sep 2015
Posts: 3
Location: France

PostPosted: Thu Sep 24, 2015 11:44 am    Post subject: Reply with quote

Find the bug ! Idea

When I open the DPLOT session I need to replace :

C$="[FileNew()]" ! for 2D plot
by
C$="[FileNew(3)]" ! for 3D plot [XYZ]

It was too easy in fact Laughing
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Thu Sep 24, 2015 8:37 pm    Post subject: Reply with quote

Glad you figured it out. Well done. Very Happy
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> Basic All times are GMT - 5 Hours
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