vbscript error

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

vbscript error

Post by mfauzim » Tue Oct 31, 2006 3:16 am

Code: Select all

I have error when try to call vbscript function.

			 GoSub>ACT_AsasTelRtn
			 //let>cenddate
			 //messagemodal>ActivationStatus
			 let>aa=%ActivationStatus%
			 let>SwitchResult='%H30%'
			 //messagemodal>H30
			 //messagemodal>SwitchResult


			 //Vbeval>AsasDataUpdateStatus("%aa%","%currentdate%","%SwitchResult%"),cstatreply
// error is this function with SwitchResult. somehow got 1033 compilation error. 
			 Vbeval>AsasDataUpdateStatus("%aa%","%currentdate%"),cstatreply


The switchresult is produce by the follwing code and another MS routine:
Let>H30_SIZE=4098
LibFunc>hIE,ExtractTag,r,%IE[0]%,,H3,0,0,H30
//messagemodal>H30
//messagemodal>r
MIDSTR>r_6,1,r,H30
// if I comment MIDSTR, then the vbscript function works, but the message is not clear since the output of not formatteed properly. Appreciate any suggestion on how to address the result formatting so that it can be pass to the vbscript function
//messagemodal>H30
//messagemodal>r

regards

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Oct 31, 2006 3:28 am

Change the line:

let>SwitchResult='%H30%'

to:

let>SwitchResult=%H30%


the single quotes are not needed. I am not certain of the error they might cause, but my guess is that MacroScheduler would put the value '%H30%' in SwitchResult instead of the value stored in H30.

It might help if you would include the VBScript function.

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

It still do not work

Post by mfauzim » Tue Oct 31, 2006 3:42 am

Hi I've tried the suggestion before trying the "'" and it does not work. Somehow it is the result content. If I remove/comment the midstr line, then the functon works but the result is not that clear since it isnot formatted properly

regards

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Oct 31, 2006 3:47 am

Then you need to post the VB Function so that we can read all the code required to get the error.

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

Code

Post by mfauzim » Tue Oct 31, 2006 4:15 am

The vbscript function:

Code: Select all

Function AsasDataUpdateStatus(rtnstat,cstartdate)
'Function AsasDataUpdateStatus( rtnstat  )
'Function AsasDataUpdateStatus(rtnstat,cstartdate,switchmsg)
' this function with switchmsg is fail/not call
   on error goto 0
	AsasDataUpdateStatus = 0
  'if not pArtnGetDateData.EOF then
	'cstartdate =	pArtnGetDateData.fields("today")
   'else
   'end if

	'msgbox rtnstat
	'msgbox cstartdate
	cProcStat = "SWT"
	if rtnstat = "S" then
	   cProcStat = "CAS"
	end if
	nProsKey = pArtnAsasData.fields("HistoryKey")
	pArtnAsasSql = "update SVC_ACT_HISTORY set rtn_status = '" & rtnstat & "', PROCESS_CURRENT_ATTEMP_NO = PROCESS_CURRENT_ATTEMP_NO + 1 "
	pArtnAsasSql = 	pArtnAsasSql & ", process_status = '" & cProcStat & "'"
	pArtnAsasSql = 	pArtnAsasSql & ", ASAS_SVC_START_STATUS_DATE =  '" & cstartdate & "',"
	pArtnAsasSql = 	pArtnAsasSql & "  ASAS_SVC_NEW_STATUS_DATE = getdate() "
	pArtnAsasSql = 	pArtnAsasSql & ", ASAS_SVC_NEW_STATUS = '" & rtnstat & "'"
	pArtnAsasSql = 	pArtnAsasSql & " where HistoryKey = " & nProsKey
	'msgbox pArtnAsasSql

	'pArtnAsasSql = 	pArtnAsasSql & ", ASAS_SVC_START_STATUS_DATE = " & cstartdate & ""
	'pArtnAsasSql = 	pArtnAsasSql & ", ASAS_SVC_NEW_STATUS_DATE = " & cenddata & ""
    'msgbox pArtnAsasSql
    set pUpdate = pArtnOdbcConn.Execute(pArtnAsasSql)
  	on error resume next
  	if err.number > 0 then
   	    AsasDataUpdateStatus = -1
  	end if
	'msgbox "Asas tel sql 2 : " & GetAsasData
	'msgbox pArtnAsasData
  	on error resume next

    msgbox switchmsg
	
	'pArtnAsasSql = "insert into SVC_ACT_log( HISTORYKEY, PROCESS_STATUS, RTN_STATUS,ACTIVITY_START_DATE,ACTIVITY_END_DATE,RETURN_CODE) values ( "
	pArtnAsasSql = "insert into SVC_ACT_log( HISTORYKEY, PROCESS_STATUS, RTN_STATUS,ACTIVITY_START_DATE,ACTIVITY_END_DATE ) values ( "

	pArtnAsasSql = 	pArtnAsasSql & nProsKey
	pArtnAsasSql = 	pArtnAsasSql & ", 'SWT' "
	pArtnAsasSql = 	pArtnAsasSql & ", '" & rtnstat & "'"
	pArtnAsasSql = 	pArtnAsasSql & ", '" & cstartdate & "' ,"
	pArtnAsasSql = 	pArtnAsasSql & " getdate() "
	'pArtnAsasSql = 	pArtnAsasSql & " '" & switchmsg & "' "
	pArtnAsasSql = 	pArtnAsasSql & " ) "
	'msgbox pArtnAsasSql


    set pUpdate = pArtnOdbcConn.Execute(pArtnAsasSql)
  	on error resume next
  	if err.number > 0 then
   	    AsasDataUpdateStatus = -1
  	end if
	'msgbox "Asas tel sql 2 : " & GetAsasData
	'msgbox pArtnAsasData
  	on error resume next

'update process control
'

  pControlSQLexist = "select count(*) as ntotal from REF_PROCESS_CONTROL where SYSTEM_TYPE  = 'ASAS' and PROCESS_NO = 1 "

  set pAControlEXISTData = pArtnOdbcConn.Execute(pControlSQLexist)
  if err.number > 0 then
     UpdateArtnData = 2
  end if

 'msgbox pArtnSQLexist

   	  If pAControlEXISTData.fields("ntotal") <1>AsasDataLoop
	      VBEval>GetNextTelNo,TelNo
 	      //messagemodal>TelNo

		  if>TelNo=-1
            GOto>FinishAsasDataLoop
		  else
     		 // assign telno to Asas telno
			 GoSub>Set_AsasTelRtn
		     //messagemodal>AsasTelRtn
			 Let>ActivationStatus=F
			 //Let>cstartdate
			 vbeval>GetDateTime(),currentdate

			 //messagemodal>%currentdate%
			 let>H30=a
			 GoSub>ACT_AsasTelRtn
			 //let>cenddate
			 //messagemodal>ActivationStatus
			 let>aa=%ActivationStatus%
			 let>SwitchResult='%H30%'
			 //messagemodal>H30
			 //messagemodal>SwitchResult


			 //Vbeval>AsasDataUpdateStatus("%aa%","%currentdate%","%SwitchResult%"),cstatreply --- this does not work even if i remove the '' from let>SwitchResult='%H30%'

			 Vbeval>AsasDataUpdateStatus("%aa%","%currentdate%"),cstatreply


the result is output from switch message as per code below:

Code: Select all




Let>H30_SIZE=4098
LibFunc>hIE,ExtractTag,r,%IE[0]%,,H3,0,0,H30
//messagemodal>H30
//messagemodal>r
MIDSTR>r_6,1,r,H30 -- if I comment this code, then the function works
//messagemodal>H30
//messagemodal>r

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Oct 31, 2006 7:52 am

The value you are passing to VBScript probably has some characters in it that VBScript doesn't like. Quotes need double quoting, and line terminators need removing. Because you are extracting the data from a web page maybe something like that is happening. Before passing it to VBScript do this:

StringReplace>H30,","",H30
StringReplace>H30,LF,,H30
StringReplace>H30,CR,,H30

See if that helps. If not, it would help if we could see what the actual value of this variable is. To do that, enable logging and set _DUMP_VARS to 1 prior to the VBEval line:

Let>_DUMP_VARS=1

Set it back to 0 afterwards. This will dump the contents of all variables to the log file.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

It works

Post by mfauzim » Wed Nov 01, 2006 6:04 am

Thanks markus, yes there some hidden character which causing the problem. using you suggestion resolved it. Great man.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts