Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > VB to Perl

Reply
Thread Tools

VB to Perl

 
 
Larry
Guest
Posts: n/a
 
      01-15-2005
Hi all,

Sorry for gettin back on this question but I wasn't able to go about it!

Below is a chunk of VB code:

[vb]
Private Type WaveInCaps
ManufacturerID As Integer
ProductID As Integer
DriverVersion As Long
ProductName(1 To 32) As Byte
Formats As Long
Channels As Integer
Reserved As Integer
End Type

Dim Caps As WaveInCaps
Call waveInGetDevCaps(0, VarPtr(Caps), Len(Caps))
[/vb]


and I need to that in Perl!!

sorry again!

(I ain't gonna post this anymore)
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      01-15-2005
Larry wrote:

> and I need to that in Perl!!


What have you tried so far? What were the results, and how were they
different from what you expected?

Looks to me like the VB declares a complex data type, declares an instance
of that type, then passes the address and size of that instance to some
function.

To learn about working with complex data types in Perl, have a look at:

perldoc perlreftut
perldoc perldsc

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
 
Chris Mattern
Guest
Posts: n/a
 
      01-15-2005
Robert Sedlacek wrote:

> Larry wrote:
>
>> and I need to that in Perl!!

>
> What? You haven't said what it does. Shall we learn VB to help you?
>
>

I'm not gonna learn VB. I can't afford the IQ loss.

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      01-15-2005
Larry <> wrote:


> Below is a chunk of VB code:


[snip\

> and I need to that in Perl!!



Step 1: Learn VB

Step 2: Learn Perl

Step 3: Convert the VB code to Perl code


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Robert Sedlacek
Guest
Posts: n/a
 
      01-15-2005
Larry wrote:

> and I need to that in Perl!!


What? You haven't said what it does. Shall we learn VB to help you?


p


--
http://www.dunkelheit.at/
 
Reply With Quote
 
Wes Groleau
Guest
Posts: n/a
 
      01-15-2005
Larry wrote:
> Hi all,
>
> Sorry for gettin back on this question but I wasn't able to go about it!
>
> Below is a chunk of VB code:
>
> [vb]
> Private Type WaveInCaps
> ManufacturerID As Integer
> ProductID As Integer
> DriverVersion As Long
> ProductName(1 To 32) As Byte
> Formats As Long
> Channels As Integer
> Reserved As Integer
> End Type


defines what Ada/Pascal calls a record, C or C++ a struct

> Dim Caps As WaveInCaps


Creates one of those and names it Caps

> Call waveInGetDevCaps(0, VarPtr(Caps), Len(Caps))


Calls a function and passes it some information
about Caps.

--
Wes Groleau
"Two things are infinite, the universe and human stupidity.
But I'm not so sure about the universe."
-- Albert Einstein
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      01-15-2005
Larry <> wrote in news:dontmewithme-
:

> Sorry for gettin back on this question but I wasn't able to go
> about it!
>
> Below is a chunk of VB code:


This is a Windows 32 API call. Surprisingly enough, there is a Perl module
called Win32::API on CPAN.

....

> and I need to that in Perl!!


Then you should consider trying to do it yourself first and posting
questions about the _specific_ problems you encounter.

On the other hand, I am getting tired of pointing out this obvious maxim
to people who are obviously never going to learn. Here's some untested
code. Enjoy!

> sorry again!


Don't apologize. Just do what the posting guidelines suggest and there
won't be any need for apologies. Useless apologies create just as much
noise as asinine queries.

#! /usr/bin/perl

use strict;
use warnings;

use Win32::API;
use Win32::API::Struct;

use Data:umper;

Win32::API::Struct->typedef(WAVEINCAPS => qw(
INT ManufacturerID;
INT ProductID;
LONG DriverVersion;
TCHAR ProductName[32];
LONG Formats;
INT Channels;
INT Reserved;
)
);

Win32::API->Import(winmm => q{
LRESULT waveInGetDevCaps(
UINT_PTR DeviceID,
LPWAVEINCAPS pwic,
UINT cbwic
)}
);

my $caps = Win32::API::Struct->new('WAVEINCAPS');

# You probably need a way of finding out a valid device id
# 0 seems suspect

my $result = waveInGetDevCaps(
0,
$caps,
Win32::API::Struct->sizeof('WAVEINCAPS')
);

print Dumper $caps;

__END__
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      01-15-2005
Wes Groleau wrote:
>> Below is a chunk of VB code:

[...]
> defines what Ada/Pascal calls a record, C or C++ a struct


The most similar data structure in Perl would probably be a hash.

>> Dim Caps As WaveInCaps

>
> Creates one of those and names it Caps


my %Caps;

>> Call waveInGetDevCaps(0, VarPtr(Caps), Len(Caps))

>
> Calls a function and passes it some information
> about Caps.


Maybe
waveInGetDevCaps(0, $Caps{VarPrt}, $Caps{Len});

jue


 
Reply With Quote
 
Wes Groleau
Guest
Posts: n/a
 
      01-16-2005
"J���������������� ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿ ½ï¿½ï¿½" wrote:
>>>Call waveInGetDevCaps(0, VarPtr(Caps), Len(Caps))

>>
>>Calls a function and passes it some information
>>about Caps.

>
> Maybe
> waveInGetDevCaps(0, $Caps{VarPrt}, $Caps{Len});


Yes, but I think the OP wants us to tell him/her
how to write waveInGetDevCaps in perl.

--
Wes Groleau
-----------

"Thinking I'm dumb gives people something to
feel smug about. Why should I disillusion them?"
-- Charles Wallace
(in _A_Wrinkle_In_Time_)
 
Reply With Quote
 
Larry
Guest
Posts: n/a
 
      01-16-2005
In article <Xns95DFA6CB41C29asu1cornelledu@132.236.56.8>,
"A. Sinan Unur" <> wrote:

> Here's some untested code. Enjoy!


I can not thank you enough!! That made my life a lot easier!

I just need you to spell out the chunk of code below:

Win32::API->Import(winmm => q{
LRESULT waveInGetDevCaps(
UINT_PTR DeviceID,
LPWAVEINCAPS pwic,
UINT cbwic
)}
);

I feel to know the "import" function but it'd be great if you could tell
me what "LRESULT","UINT_PTR","UINT_PTR" and "UINT" are meant to be!

thanks again!!!
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 04-04-2011 10:00 PM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 02-27-2011 11:00 PM
FAQ 2.17 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? PerlFAQ Server Perl Misc 0 02-03-2011 11:00 AM
FAQ 1.4 What are Perl 4, Perl 5, or Perl 6? PerlFAQ Server Perl Misc 0 01-23-2011 05:00 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57