The following S_TOOLS-STx script example demonstrates basic use of the graphical cursors.
[macro gui_cursors_example #standalone=1] // // create display, graph and dialog // and configure // if '$#standalone' == 1 then if '$(load macrocode $scriptdirectory\gui_basic_example.sts)' > 0 em $rc ; $#mac - $emsg gui_basic_example 0 end // // display cursor styles combobox in dialog // and static control for cursor position values. // cursorStyle := set '0' cursorStyleList := set 'cross crosshair hbar vbar hbarcross vbarcross harmonic rangeselection' functionBound := set '0' functionBoundList := set 'unbound bound' // // show cursors in graph // $myGraph cursormode both $cursorStyle on $(int $functionBound-1) off off red yellow /Apply // // connect them with a value item, so the value can be // extracted at any time using the syntax $cursors[!data,$#i] // myCursors := new value * if '$myCursors[?]' != 'value' em -1 ; value creation failed ($emsg) $myCursors input $myGraph.cursors /Read // // return if this is not a standalone call // if '$#standalone' != 1 exit 1 // caller will clean up // // create dialog controls and show // the display // $myDialog $myDialog[!controls] combobox 0 0 'Cursor Style' cursorStyle * * cursorStyleList functionBound := set '0' functionBoundList := set 'unbound bound' $myDialog $myDialog[!controls] combobox 1 0 'Function Bound' functionBound * * functionBoundList staticCtrlId := $myDialog[!controls] $myDialog $staticCtrlId static 2 0 'text' * 50 1 $myDialog enabled restored /Write // update dialog $myDisplay enabled restored 100 100 800 800 // // process messages until display is close // by the user // setmsghandler display $myDisplay gui_cursors_example_mh setmsghandler menu $myDialog gui_cursors_example_mh setmsghandler value $myCursors gui_cursors_example_mh AppMode := 1 do while '$AppMode' != '0' GetMessage end setmsghandler display $myDisplay setmsghandler menu $myDialog setmsghandler value $myCursors // // clean up // delete $myGraph $myDisplay $myDialog $mySpu $myCursors exit [MACRO gui_cursors_example_mh #objtype #objname #msgid #msgpar] if '$#objtype' == display || '$#objtype' == shell then if '$#msgid' == Close || '$#msgId' == Exit then AppMode := 0 end else if '$#objtype' == 'menu' then if '$#msgid' == 'update' then $#objname /Read // retrieve new $myGraph cursormode both $(word $cursorStyle $cursorStyleList) * $(int $functionBound-1) /Apply end else if '$#objtype' == 'value' then if '$#objname' == '$myCursors' then #x1 := format '%.2f' $myCursors[!data,5] #y1 := format '%.2f' $myCursors[!data,6] #x2 := format '%.2f' $myCursors[!data,10] #y2 := format '%.2f' $myCursors[!data,11] $myDialog $staticCtrlId * 'x1=$#x1 y1=$#y1 x2=$#x2 y2=$#y2' end end exit 1