PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Keyword arguments for WIN32OLE?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Keyword arguments for WIN32OLE?

Réponse
 
LinkBack Outils de la discussion
Vieux 09/03/2008, 23h03   #1
djlewis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Keyword arguments for WIN32OLE?

Is there a way to pass ~keyword~ arguments to a WIN32OLE method in
Ruby? For example, I've tried...

@selection.Find.Execute( :FindText=>"look
for", :ReplaceWith=>"something else")

.... and the same with the arguments as an explicit hash. They don't
work. I'm reduced to using terribly ugly, error-prone things like...

def replace( find, replace)
@selection.Find.Execute( find, nil, nil, nil, nil, nil, nil, nil,
nil, replace)
end

which is OK once set up. But translating ruby-style hash keyword
arguments to WIN32OLE keyword arguments would be tremendous .

BTW, the VBA function used above is...

expression.Execute(FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap,
Format, ReplaceWith, Replace, MatchKashida, MatchDiacritics,
MatchAlefHamza, MatchControl)

Thanks. --David.
  Réponse avec citation
Vieux 10/03/2008, 13h07   #2
Masaki Suketa
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Keyword arguments for WIN32OLE?

Hello,

djlewis wrote:
> Is there a way to pass ~keyword~ arguments to a WIN32OLE method in
> Ruby? For example, I've tried...
>
> @selection.Find.Execute( :FindText=>"look
> for", :ReplaceWith=>"something else")


Try
@selection.Find.Execute({:FindText=>"look
for", :ReplaceWith=>"something else"})
or
@selection.Find.Execute({"FindText"=>"look
for", "ReplaceWith"=>"something else"})

Regards,
Masaki Suketa


  Réponse avec citation
Vieux 10/03/2008, 13h29   #3
Masaki Suketa
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Keyword arguments for WIN32OLE?

In Ruby 1.8, hash keys must be String object.
And in Ruby 1.9, hash keys must be String or Symbol object.

So,
> @selection.Find.Execute({:FindText=>"look
> for", :ReplaceWith=>"something else"})

style is supported in Ruby 1.9

> @selection.Find.Execute({"FindText"=>"look
> for", "ReplaceWith"=>"something else"})

style is supported in Ruby 1.8 and Ruby 1.9.

Regards,
Masaki Suketa


  Réponse avec citation
Vieux 10/03/2008, 17h31   #4
Rick DeNatale
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Keyword arguments for WIN32OLE?

On 3/10/08, Masaki Suketa <masaki.suketa@nifty.ne.jp> wrote:
> In Ruby 1.8, hash keys must be String object.
> And in Ruby 1.9, hash keys must be String or Symbol object.
>


To be clear you're talking about hashes used as arguments to win32ole
methods, not Ruby hashes in general.

Right?

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

  Réponse avec citation
Vieux 10/03/2008, 22h42   #5
Masaki Suketa
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Keyword arguments for WIN32OLE?

Rick DeNatale wrote:
> On 3/10/08, Masaki Suketa <masaki.suketa@nifty.ne.jp> wrote:
>> In Ruby 1.8, hash keys must be String object.
>> And in Ruby 1.9, hash keys must be String or Symbol object.
>>

>
> To be clear you're talking about hashes used as arguments to win32ole
> methods, not Ruby hashes in general.
>
> Right?


Yes. I'm talking about Win32OLE methods, not Ruby hashes in general.

Regards,
Masaki Suketa

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 14h19.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13701 seconds with 13 queries