PDA

View Full Version : sample perl with visualbuild script


ShiamakD
06-25-2009, 01:21 PM
hi,

I am having hard time using perl script with VisualBuild (assinng a scalar value to a macro etc).. I couldnt go beyond compilation at times...

I was wondering if you have a sample perl script which you could share?

Thanks

kinook
06-25-2009, 02:07 PM
Attached.

ShiamakD
06-25-2009, 02:24 PM
Originally posted by kinook
Attached.

I was looking for a PERL script example not python..plus the script that you attached failed compilation.

kinook
06-25-2009, 02:29 PM
Sorry about that. See new attachment.

Results here when building with VBP 7.1 and ActivePerl 5.10.0.1005 on Win XP SP3:

6/25/2009 1:28:51 PM: --------------------Starting Build: 'Perl.bld'--------------------
6/25/2009 1:28:51 PM: Building project step 1 - Project steps...
6/25/2009 1:28:51 PM: Building project step 2 - Create macro...
6/25/2009 1:28:51 PM: Building project step 3 - Show macro...
123

ShiamakD
06-26-2009, 10:53 AM
Originally posted by kinook
Sorry about that. See new attachment.

Results here when building with VBP 7.1 and ActivePerl 5.10.0.1005 on Win XP SP3:

6/25/2009 1:28:51 PM: --------------------Starting Build: 'Perl.bld'--------------------
6/25/2009 1:28:51 PM: Building project step 1 - Project steps...
6/25/2009 1:28:51 PM: Building project step 2 - Create macro...
6/25/2009 1:28:51 PM: Building project step 3 - Show macro...
123

Thanks so much for your reply however I am facing a problem while assigning the value of a scalar (perl variable) to a macro??

e.g $Application->Macros(vbldMacroTemporary)->Add("ABC", '$abc');

if I use single quotes around "ABC" i get an compilation error or if i dont use quotes then VisualBuild assing my scalar as a VALUE to my macro?

kinook
06-26-2009, 11:03 AM
I'm not sure exactly what you mean by "if i dont use quotes then VisualBuild assing my scalar as a VALUE to my macro".

This does what I would expect (assigns the value '123' to the ABC temporary macro):

$abc = 123;
$Application->Macros(vbldMacroTemporary)->Add("ABC", $abc);

You can't assign a Perl variable reference to a VBP macro, but you can store the underlying variable's value.

ShiamakD
06-26-2009, 12:08 PM
Originally posted by kinook
I'm not sure exactly what you mean by "if i dont use quotes then VisualBuild assing my scalar as a VALUE to my macro".

This does what I would expect (assigns the value '123' to the ABC temporary macro):

$abc = 123;
$Application->Macros(vbldMacroTemporary)->Add("ABC", $abc);

You can't assign a Perl variable reference to a VBP macro, but you can store the underlying variable's value.

so I cant use something like
$abc = $_;
$Application->Macros(vbldMacroTemporary)->Add("ABC", $abc);
???

Thanks for your help.

kinook
06-26-2009, 12:49 PM
That works ok in my tests:@myNames = ('Larry', 'Curly', 'Moe');
foreach (@myNames)
{
$abc = $_;
$Application->Macros(vbldMacroTemporary)->Add($abc, $abc);
}Creates three temporary macros with names and values Larry, Curly, and Moe.

ShiamakD
06-26-2009, 12:56 PM
Originally posted by kinook
That works ok in my tests:@myNames = ('Larry', 'Curly', 'Moe');
foreach (@myNames)
{
$abc = $_;
$Application->Macros(vbldMacroTemporary)->Add($abc, $abc);
}Creates three temporary macros with names and values Larry, Curly, and Moe.

it still doesnt seems to work..:-( here is what i am trying to do..

open (MYFILE, 'c:\perl\bin\Build.log') || die("cant open file");
while (<MYFILE>)
{
chomp;
if (($_ =~ /[1-9]\serrors/) || ($_=~ /[1-9](\d+)\serrors/))

{
$abc = $_;
$Application->Macros(vbldMacroTemporary)->Add($ABC ,$abc);

}
}
close (MYFILE);

kinook
06-26-2009, 02:16 PM
VBP doesn't allow spaces in a macro name (and Perl is a case-sensitive language, so $ABC would not be defined in the sample code). The attached sample uses the first character of the match for the macro name. You would need to tweak as necessary to assign an appropriate macro name.