MyBASIC2 Script Example |
' Just some code to manipulate points, channels and curves. ' It also changes T0 and makes sure that frames being references to T0 ' ' It uses TRACE to show progress so make sure to start the MyBASIC2 Tracer first. ' MyBASIC2 Tracer is supplied with the IDE ' OPTION TRACE ON OPTION WINPUMP OFF OPTION FORMAT ON
$INCLUDE "MyBASIC2.bas" $INCLUDE "MaxTRAQ.mqb"
TRACE TRACE_CLS
' Just test some application stuff TRACE "App Instance: ";APP.GetInstance() TRACE "App Mode: ";APP.GetMode() TRACE "App Event: ";APP.GetCurrentEvent()
TRACE "HWND = ";FORMAT( "0x%08X", INT( APP.GetWindow() ) ) TRACE "HWND = ";FORMAT( "0x%08X", INT( APP.GetWindow( "tracker" ) ) ) TRACE "HWND = ";FORMAT( "0x%08X", INT( APP.GetWindow( "recorder" ) ) )
IF FILE.IsOpen() THEN TRACE "Current File Description: ";FILE.GetDescription() ENDIF
DIM strFileName AS STRING
strFileName = "e:\TestT0.mqf"
FILE.Close( FALSE )
' Check to make sure file exists IF FILE.Exists( strFileName ) THEN FILE.Open( strFileName ) ELSE TRACE "File ";strFileName;" doesn't exist and can't be opened !!!" STOP ENDIF
FILE.Import( "e:\force\walk.mdq" ) APP.View( "GRAPH", TRUE )
VIDEO.SetTableType( TABLE_ANALOGS ) GRAPH.SetCurrent( 9 )
POINT.SetVisible( 2, FALSE ) POINT.SetVisible( 3, FALSE ) POINT.SetVisible( 4, FALSE ) POINT.SetVisible( 5, FALSE )
GRAPH.Redraw()
VIDEO.SetTableType( TABLE_ANALOGS ) GRAPH.SetCurrent( GRAPH_ANALOG )
' Just set channel data to some arbitrary values CHANNEL.Set( 1, 1, 3 ) CHANNEL.Set( 5, 1, 3 ) CHANNEL.Set( 10, 1, 3 ) CHANNEL.Set( 15, 1, 3 ) CHANNEL.Set( 20, 1, 3 ) CHANNEL.Set( 25, 1, 3 )
CHANNEL.SetVisible( ALL_CHANNELS, FALSE ) CHANNEL.SetVisible( 1, TRUE )
' Hide all curves except curve no 1 FOR i = 1 TO 10 GRAPH.SetVisible( i, FALSE ) ENDFOR GRAPH.SetVisible( 1, TRUE ) GRAPH.Redraw()
VIDEO.SetFrame( 200, FALSE ) SLEEP( 2 ) VIDEO.SetFrame( 1, TRUE )
VIDEO.SetOffsetT0( TRUE )
DIM curFrame AS INTEGER curFrame = VIDEO.GetFrame()
TRACE "Current Frame 1: ";curFrame TRACE "Angle at Frame(";curFrame;"): ";ANGLE.Get( curFrame, 1 ) TRACE "Distance at Frame(";curFrame;"): ";DISTANCE.Get( curFrame, 1 )
VIDEO.SetFrame( 76 ) curFrame = VIDEO.GetFrame() TRACE "Current Frame 2: ";curFrame
curFrame = VIDEO.GetFrame() TRACE "Current Frame 3: ";curFrame TRACE "Angle at Frame(";curFrame;"): ";ANGLE.Get( curFrame, 1 ) TRACE "Distance at Frame(";curFrame;"): ";DISTANCE.Get( curFrame, 1 )
GRID.Create( curFrame+5, 3, 3, 10, 10, 300, 300 ) NOTE.Create( curFrame+5,_ curFrame+5,_ 380, 380, 400, 400, 480, 430,_ "Kalle ???" )
TRACE TRACE_DIVIDER
TRACE "Coord P1(";curFrame;"): ";_ POINT.Get( curFrame, 1, DIM_X );", ";_ POINT.Get( curFrame, 1, DIM_Y )
POINT.Set( curFrame, 1, DIM_X, 123 ) POINT.Set( curFrame, 1, DIM_Y, 341 ) POINT.Set( curFrame, 1, DIM_STATUS, TRUE )
TRACE "Coord P1(";curFrame;"): ";_ POINT.Get( curFrame, 1, DIM_X );", ";_ POINT.Get( curFrame, 1, DIM_Y )
VIDEO.SetNoOfPoints( VIDEO.GetNoOfPoints() + 1 ) POINT.Copy( 1, 10, VIDEO.GetNoOfPoints(), 10, 10 )
POINT.Set( 1, VIDEO.GetNoOfPoints(), DIM_X, 111.123 ) POINT.Set( 1, VIDEO.GetNoOfPoints(), DIM_Y, 222.321 ) POINT.Set( 1, VIDEO.GetNoOfPoints(), DIM_STATUS, TRUE )
POINT.CopyFrame( 1, 2, 2 )
VIDEO.SetT0( 1 ) VIDEO.SetT1( VIDEO.GetNoOfFrames() ) VIDEO.SetFrame( 201, FALSE )
' Close file without saving changes FILE.SetModified( FALSE ) FILE.Close()
END
|