/*
 * CPK ARexx communications test...
 *
 * Author: Eric G. Suchanek, Ph.D.
 * Copyright © 1993, 1994 Eric G. Suchanek, Ph.D. All Rights Reserved
 *
 * You must launch cpk first to run this script.
 * 
 */

Options FailAt 100

Options Results

/* make sure cpk is running */

CALL Locate_CPK

IF RESULT = 1 THEN SAY "CPK has been found"
ELSE 
 do
  SAY "Could not locate or start CPK"
  EXIT
 end
endif


address cpk1
/*
 * Try to read the window title bar
 */

/* 
   NOTE: The Port command actually sets the errorlevel to 5,
   so you have to check for an 'error' to get the port name... 
*/

'Port'

if rc > 0 then say 'Port is: 'CPK.LASTERROR
else say 'Port is: 'Result

/*
 * bogus command
 */

'Junk'

if rc > 0 then say 'Error was (this should be an UNKNOWN COMMAND error) 'CPK.LASTERROR
else say 'The command worked!'


/*
"Load Prefs prefs/b_dna.prefs"
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The command worked!'
*/


"Load PDB pdb/hello.pdb"
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Load PDB command worked!'

"XRot 45.0"
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The XRot command worked!'

"YRot 35.0"
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The YRot command worked!'

"ZRot 25.0"
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The ZRot command worked!'

'Render'

/* or, more compactly, use the ROTATE command */
"Rotate 20.0 30.0 40.0"
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Rotate command worked!'

'Render'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Render command worked!'

'Reset'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Reset command worked!'

'Render'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Render command worked!'

'Scale 3'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Scale command worked!'
'Render'

"Load PDB pdb/heme.pdb"
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Load PDB command worked!'

'PhotoMode ON'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The PhotoMode ON command worked!'

'VectorMode ON'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The VectorMode ON command worked!'

'SwapColors ON'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The SwapColors ON command worked!'

/* valid range for SCALE is 1 -> 20 */

'Scale 21'
if rc > 0 then say 'Error was (should be an Argument Error) 'CPK.LASTERROR
else say 'The Scale command worked!'

'VectorMode OFF'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The VectorMode ON command worked!'

'BallStickMode ON'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The BallStickMode ON command worked!'

'Save IFF ram:test.iff'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Save IFF command worked!'

'Save PREFS ram:test.prefs'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Save Prefs command worked!'

/* Play with the POV-Ray menu items */

'Checkerboard Off'
if rc > 0 then say 'Error was  'CPK.LASTERROR
else say 'The Checkerboard OFF command worked!'

'Sky Off'
if rc > 0 then say 'Error was  'CPK.LASTERROR
else say 'The Checkerboard OFF command worked!'

'AreaLights ON'
if rc > 0 then say 'Error was  'CPK.LASTERROR
else say 'The AreaLights ON command worked!'

'Radius bogus'
if rc > 0 then say 'Error was (should be bad argument) 'CPK.LASTERROR
else say 'The Radius bogus command worked!'

'Radius CPK'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Radius VDW command worked!'

'Radius COVALENT'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Radius COVALENT command worked!'

'Radius BALLSTICK'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Radius BALLSTICK command worked!'

'Radius BALLSTICKGLASS'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Radius BALLSTICKGLASS command worked!'

'AreaLights OFF'
if rc > 0 then say 'Error was  'CPK.LASTERROR
else say 'The AreaLights OFF command worked!'

'Checkerboard ON'
if rc > 0 then say 'Error was  'CPK.LASTERROR
else say 'The Checkerboard ON command worked!'

'Sky ON'
if rc > 0 then say 'Error was  'CPK.LASTERROR
else say 'The Sky ON command worked!'

'Radius VDW'
if rc > 0 then say 'Error was  'CPK.LASTERROR
else say 'Radius VDW command worked!'

'PDB2POV'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Pdb2POV command worked!'

/* OK, set up a real scene to 'render' */
"rotate 45.0 45.0 45.0"
if rc > 0 then say 'Error was 'CPK.LASTERROR

/* this 'render' is not really necessary, but synchronizes the
   CPK display to our 'scene' 
*/

'PhotoMode OFF'
if rc > 0 then say 'Error was 'CPK.LASTERROR

'render'

/* run POV-Ray */
/*
'Radius BALLSTICK'
'POVRAY'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The POV-Ray command worked!'
*/

/*
 * Quit the program...
 */

/*
'Quit'
if rc > 0 then say 'Error was 'CPK.LASTERROR
else say 'The Quit command worked!'
*/

exit

Locate_CPK:
if POS('CPK' , SHOW('Ports')) = 0 then 
	return 0
else
	return 1
end if

