Bug avec arguments optionnels

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug avec arguments optionnels

flachyjoe
Bonjour,
j'ai un comportement étrange avec les arguments optionnels (...), le
premier argument disparaît et tous les autres sont décalés.

-------| le code qui pèche |-------
Public Function concat(delim As String, arg As String) As String
   Return arg & delim
End

Public Sub Form_Open()
   Dim f As String[], f2 As String[]
   f = ["01", "02", "03"]
   f2 = ArrayMap(f, Me, "concat", "$")
End

Public Function ArrayMap(Table As Variant[], Obj As Object, Func As
String, ...) As Variant[]
   Dim Item As Variant
   Dim Result As New Variant[]
   Dim Argu As New Variant[]
   Dim a As Variant
   For Each a In Args
     Argu.Push(a)
   Next

   For Each Item In Table    'erreur car Table=Me !
     Argu.Push(item)
     Result.Add(Object.Call(Obj, Func, Argu))
     Argu.Pop()
   Next

   Return Result
End
-----------------------

Un contournement :

-------| code qui fonctionne |-------
Public Function concat(delim As String, arg As String) As String
   Return arg & delim
End

Public Sub Form_Open()
   Dim f As String[], f2 As String[]
   f = ["01", "02", "03"]
   f2 = ArrayMap(f, Me, "concat", ["$"])
End

Public Function ArrayMap(Table As Variant[], Obj As Object, Func As
String, Argu As Variant[]) As Variant[]
   Dim Item As Variant
   Dim Result As New Variant[]

   For Each Item In Table
     Argu.Push(item)
     Result.Add(Object.Call(Obj, Func, Argu))
     Argu.Pop()
   Next

   Return Result
End
-----------------------

Merci.

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Gambas-user-fr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user-fr
Reply | Threaded
Open this post in threaded view
|

Re: Bug avec arguments optionnels

Fabien Bodard-4

Deja renommée tes variables table et résult en aTable et aResult pour éviter des conflit avec les classes de même nom

Le 4 avr. 2013 19:47, "Flachy Joe" <[hidden email]> a écrit :
Bonjour,
j'ai un comportement étrange avec les arguments optionnels (...), le
premier argument disparaît et tous les autres sont décalés.

-------| le code qui pèche |-------
Public Function concat(delim As String, arg As String) As String
   Return arg & delim
End

Public Sub Form_Open()
   Dim f As String[], f2 As String[]
   f = ["01", "02", "03"]
   f2 = ArrayMap(f, Me, "concat", "$")
End

Public Function ArrayMap(Table As Variant[], Obj As Object, Func As
String, ...) As Variant[]
   Dim Item As Variant
   Dim Result As New Variant[]
   Dim Argu As New Variant[]
   Dim a As Variant
   For Each a In Args
     Argu.Push(a)
   Next

   For Each Item In Table    'erreur car Table=Me !
     Argu.Push(item)
     Result.Add(Object.Call(Obj, Func, Argu))
     Argu.Pop()
   Next

   Return Result
End
-----------------------

Un contournement :

-------| code qui fonctionne |-------
Public Function concat(delim As String, arg As String) As String
   Return arg & delim
End

Public Sub Form_Open()
   Dim f As String[], f2 As String[]
   f = ["01", "02", "03"]
   f2 = ArrayMap(f, Me, "concat", ["$"])
End

Public Function ArrayMap(Table As Variant[], Obj As Object, Func As
String, Argu As Variant[]) As Variant[]
   Dim Item As Variant
   Dim Result As New Variant[]

   For Each Item In Table
     Argu.Push(item)
     Result.Add(Object.Call(Obj, Func, Argu))
     Argu.Pop()
   Next

   Return Result
End
-----------------------

Merci.

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Gambas-user-fr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user-fr

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Gambas-user-fr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user-fr
Reply | Threaded
Open this post in threaded view
|

Re: Bug avec arguments optionnels

flachyjoe
Bonjour Fabien,

J'ai changé les noms sans que ça change quoi que ce soit au problème (je n'ai pas de classe Table ou Result déclarées d'ailleurs).

J'utilise bien la version svn (revision 5611) et j'ai aussi généré un exécutable pour vérifier que le bug ne touchait pas que l'IDE.

Merci !

Le 05/04/2013 08:43, Fabien Bodard a écrit :

Deja renommée tes variables table et résult en aTable et aResult pour éviter des conflit avec les classes de même nom

Le 4 avr. 2013 19:47, "Flachy Joe" <[hidden email]> a écrit :
Bonjour,
j'ai un comportement étrange avec les arguments optionnels (...), le
premier argument disparaît et tous les autres sont décalés.

-------| le code qui pèche |-------
Public Function concat(delim As String, arg As String) As String
   Return arg & delim
End

Public Sub Form_Open()
   Dim f As String[], f2 As String[]
   f = ["01", "02", "03"]
   f2 = ArrayMap(f, Me, "concat", "$")
End

Public Function ArrayMap(Table As Variant[], Obj As Object, Func As
String, ...) As Variant[]
   Dim Item As Variant
   Dim Result As New Variant[]
   Dim Argu As New Variant[]
   Dim a As Variant
   For Each a In Args
     Argu.Push(a)
   Next

   For Each Item In Table    'erreur car Table=Me !
     Argu.Push(item)
     Result.Add(Object.Call(Obj, Func, Argu))
     Argu.Pop()
   Next

   Return Result
End
-----------------------

Un contournement :

-------| code qui fonctionne |-------
Public Function concat(delim As String, arg As String) As String
   Return arg & delim
End

Public Sub Form_Open()
   Dim f As String[], f2 As String[]
   f = ["01", "02", "03"]
   f2 = ArrayMap(f, Me, "concat", ["$"])
End

Public Function ArrayMap(Table As Variant[], Obj As Object, Func As
String, Argu As Variant[]) As Variant[]
   Dim Item As Variant
   Dim Result As New Variant[]

   For Each Item In Table
     Argu.Push(item)
     Result.Add(Object.Call(Obj, Func, Argu))
     Argu.Pop()
   Next

   Return Result
End
-----------------------

Merci.

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Gambas-user-fr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user-fr


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html


_______________________________________________
Gambas-user-fr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user-fr

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Gambas-user-fr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user-fr
Reply | Threaded
Open this post in threaded view
|

Re: Bug avec arguments optionnels

Benoît Minisini
Le 05/04/2013 09:22, Flachy Joe a écrit :

> Bonjour Fabien,
>
> J'ai changé les noms sans que ça change quoi que ce soit au problème (je
> n'ai pas de classe Table ou Result déclarées d'ailleurs).
>
> J'utilise bien la version svn (revision 5611) et j'ai aussi généré un
> exécutable pour vérifier que le bug ne touchait pas que l'IDE.
>
> Merci !
>

Le bug a (normalement) été corrigé avec la révision #5686, et sera
"backporté" dans la version 3.4.2.

--
Benoît Minisini

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Gambas-user-fr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user-fr