''This VBScript will open a text file containing the RA and Dec for the observatory telescope
''and write it into the FITS header of whatever image is exposed

''''''''''''''''''''''''''''''
'Declare Variables

Dim cam ' "The" Camera object
Dim doc ' "The" Image Object
Dim crval1,crpix1,ctype1,ctype2
Dim strTest
Dim strCRVAL1,strCRVAL2,strCTYPE1,strCTYPE2,strCDELT1,strCDELT2,strCRPIX1,strCRPIX2
Dim Suc1,Suc2,Suc3,Suc4,Suc5,Suc6,Suc7,Suc8

''''''''''''''''''''''''''''''
'FITS KEYS
strCRVAL1="CRVAL1"
strCRVAL2="CRVAL2"
strCTYPE1="CTYPE1"
strCTYPE2="CTYPE2"
strCDELT1="CDELT1"
strCDELT2="CDELT2"
strCRPIX1="CRPIX1"
strCRPIX2="CRPIX2"

''''''''''''''''''''''''''''''
'Values

crval1=CDbl(10)
crpix1=CDbl(0.002002)
ctype1="RA---TAN"
ctype2="Dec--TAN"

'''''''''''''''''''''''''''''''
'Create objects with methods and properties of their own

Set cam = CreateObject("MaxIm.CCDCamera")
Set doc= CreateObject("MaxIm.Document")
MsgBox(strCRPIX2)

'cam.LinkEnabled = True
'if Not cam.LinkEnabled Then
'wscript.echo "Failed to start camera."
'Quit
'End If
'wscript.echo "Camera is ready, Exposing."
'cam.Expose 1, 1, 0
'Do While Not cam.ImageReady
'Loop

'if Not cam.LinkEnabled Then
Do While Not cam.LinkEnabled
Loop

if cam.ImageReady Then
wscript.echo"Camera Is active."
Suc1=cam.SetFITSKey(strCRVAL1,crval1)
Suc2=cam.SetFITSKey(strCRVAL2,crval1)
Suc3=cam.SetFITSKey(strCTYPE1,ctype1)
Suc4=cam.SetFITSKey(strCTYPE2,ctype2)
Suc5=cam.SetFITSKey(strCDELT1,crpix1)
Suc6=cam.SetFITSKey(strCDELT2,crpix1)
Suc7=cam.SetFITSKey(strCRPIX1,crpix1)
Suc8=cam.SetFITSKey(strCRPIX2,crpix1)

'cam.SaveImage "C:/Script.fit"
'wscript.echo "Exposure is done, Image saved as Script.fit"

'doc.OpenFile "C:/Script.fit"
'strTest=doc.GetFITSKey(BZERO)
'Suc=doc.SetFITSKey(CRVAL1,crval1)

'doc.SaveFile"C:/Script.fit",mxFITS
'MsgBox(Suc)
End if
'Loop