PDA

View Full Version : Error setting temp macro in vbscript


pjaiswal
02-16-2006, 02:02 PM
Hi,

I am using this in my vbscript to set a temporary macro BatFile.

Application.Macros(vbldTemporary).Add "BatFile", vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile")
MsgBox "%BatFile%"

And then in the next step using the run program to run a bat file as follows:

%DOSCMD% %DestinationDir%\%BatFile%

But this gives me an error.

What am I doing wrong?

Thanks.

kinook
02-16-2006, 02:49 PM
What's the error message? If either macro could contain spaces, you'll want to enclose the value in double quotes:

%DOSCMD% "%DestinationDir%\%BatFile%"

pjaiswal
02-16-2006, 03:38 PM
%DOSCMD% "%DestinationDir%\%BatFile%"

Changing it to this also gives the following error:

The syntax of the command is incorrect.

Process completed with exit code 1
Step 'Run Program' failed

Also, in my VBScript

MsgBox vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile")

This pops the right value, but the one below pops up a messagebaox with : <object>

Application.Macros(vbldTemporary).Add "BatFile", vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile")
MsgBox "%BatFile%"

Also, the value destination dir is C:\Xfolder\bin

pjaiswal
02-16-2006, 03:45 PM
OK. Changing it to this:

Application.Macros(vbldTemporary).Add "BatFile", SFname

and SFname is a string with the recordset value worked....for some reason.

Thanks.

kinook
02-17-2006, 07:48 AM
Your code stores the recordset field object rather than its value. Use

Application.Macros(vbldTemporary).Add "BatFile", vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value

to store the field's value in the macro.

pjaiswal
02-17-2006, 01:31 PM
Hi,

I am trying to Set Macro called BatFile and giving the following in the value field like this:

%vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value%

or

vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value

or

vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile")

or

%vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile")%

These are the errors I get:


C:\PLTS\Bin\vbld_TempMacroObj' is not recognized as an internal or external command,
operable program or batch file.


Error expanding macros or script in property MacroValue: <Error parsing macros: Unrecoverable Parse Error at position 28 - expecting percent_sign>


What should I use?

kinook
02-17-2006, 02:01 PM
http://www.visualbuild.com/Manual?scriptexpressions.htm

pjaiswal
02-17-2006, 05:00 PM
Thanks!

I have another question:

builder.RunProgram(%DOSCMD% "%DestinationDir%\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value]")

Adding this line to my vbscript code gives me error:

Error in Run Script (VBScript) script code at Line 61, Column 33 (Expected ')')
Code: builder.RunProgram(C:\WINDOWS\system32\cmd.exe /C "C:\PLTS\Bin\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value]")

But running this same command in Run program action:

%DOSCMD%
"%DestinationDir%\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value]"

runs fine.

How can I incorporate this in the script?

pjaiswal
02-17-2006, 05:25 PM
This gives me the right value when I run the script:

MsgBox vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value


But

builder.RunProgramEx(%DOSCMD% %DestinationDir%\vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value)

gives me the error:

Error in Run Script (VBScript) script code at Line 62, Column 35 (Expected ')')
Code: builder.RunProgramEx(C:\WINDOWS\system32\cmd.exe /C C:\PLTS\Bin\vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value)