Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-25-2009, 01:21 PM
ShiamakD ShiamakD is online now
Registered User
 
Join Date: 04-28-2008
Location: us
Posts: 32
sample perl with visualbuild script

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
Reply With Quote
  #2  
Old 06-25-2009, 02:07 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Attached.
Attached Files
File Type: bld perl.bld (570 Bytes, 1648 views)
Reply With Quote
  #3  
Old 06-25-2009, 02:24 PM
ShiamakD ShiamakD is online now
Registered User
 
Join Date: 04-28-2008
Location: us
Posts: 32
Quote:
Originally posted by kinook
Attached.
I was looking for a PERL script example not python..plus the script that you attached failed compilation.
Reply With Quote
  #4  
Old 06-25-2009, 02:29 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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
Attached Files
File Type: bld perl.bld (598 Bytes, 1590 views)
Reply With Quote
  #5  
Old 06-26-2009, 10:53 AM
ShiamakD ShiamakD is online now
Registered User
 
Join Date: 04-28-2008
Location: us
Posts: 32
Quote:
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?
Reply With Quote
  #6  
Old 06-26-2009, 11:03 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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.
Reply With Quote
  #7  
Old 06-26-2009, 12:08 PM
ShiamakD ShiamakD is online now
Registered User
 
Join Date: 04-28-2008
Location: us
Posts: 32
Quote:
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.
Reply With Quote
  #8  
Old 06-26-2009, 12:49 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
That works ok in my tests:
Code:
@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.
Reply With Quote
  #9  
Old 06-26-2009, 12:56 PM
ShiamakD ShiamakD is online now
Registered User
 
Join Date: 04-28-2008
Location: us
Posts: 32
Quote:
Originally posted by kinook
That works ok in my tests:
Code:
@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);
Reply With Quote
  #10  
Old 06-26-2009, 02:16 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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.
Attached Files
File Type: bld perl2.bld (1.1 KB, 1659 views)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 08:35 PM.


Copyright © 1999-2023 Kinook Software, Inc.