Page 1 sur 1

un truc tout bête

MessagePublié: 28 Avr 2003 à 16:38
par yop
j'ai un agent LS faisant appel à une fonction LS.ex:dans initialize, j'ai un call fonction(var1,var2)dans ma fonction, il me retourne var = var1+var2si je fais msgbox var dans la fonction à la fin, j'affiche la somme varpar contre, si je fais msgbox var dans la suite de mon agent, il ne me retourne pas la valeur.comment hérite-t-on du résultat d'une sous-fonction dans la suite d'un agent ?merci.

Re: un truc tout bête

MessagePublié: 28 Avr 2003 à 16:47
par Raziel
Salut,Voici un exemple :Function Somme (Var1 as integer, var2 as integer) as integerSomme = Var1 + Var2end functionSub initializeTotal as integerTotal = Somme(10, 15)msgbox (str(Total))end sub

Re: un truc tout bête

MessagePublié: 28 Avr 2003 à 17:01
par yop
merci, ça marche, mais je n'arrive pas à l'adapter.quelque chose doit m'échapper.voici ma fonction :Function RS(chaine As String, avant As String, apres As String) As String Dim gauche As String, droite As String, tout As String Dim i As Variant i = False Do Until i = True If Instr(chaine,avant) = 0 Then i = True Else gauche = Left(chaine,Instr(chaine,avant)-1) droite = Right(chaine,Len(chaine)-(Instr(chaine,avant)-1+Len(avant))) tout = gauche+apres+droite chaine = tout End If Loop final = chaineEnd Functionelle permet de faire un replacesubstring.Voici le script :Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim vue As NotesView Dim doc As NotesDocument Dim item As Variant Dim body As NotesMimeEntity, value As NotesMimeEntity Dim html As String Set db = session.CurrentDatabase session.ConvertMime = False Set vue = db.GetView("($Inbox)") Set doc = vue.GetFirstDocument While Not (doc Is Nothing) If doc.Subject(0) = "Sujet" Then Set item = doc.GetFirstItem("Body") Set body = item.GetMimeEntity Set value = body.GetFirstChildEntity html$ = value.ContentAsText test$ = RS(html$,"<HTML>","") Msgbox test$ End If Set doc = vue.GetNextDocument(doc) WendEnd Suble test$ me retourne une chaine vide ??

Re: un truc tout bête

MessagePublié: 28 Avr 2003 à 17:07
par Raziel
Dans ton cas, pour pouvoir récupérer la valeur en sortie, il faut qu'à un moment, tu ai un truc du genre :RS = FinalRemplace :Function RS(chaine As String, avant As String, apres As String) As StringDim gauche As String, droite As String, tout As StringDim i As Varianti = FalseDo Until i = TrueIf Instr(chaine,avant) = 0 Theni = TrueElsegauche = Left(chaine,Instr(chaine,avant)-1)droite = Right(chaine,Len(chaine)-(Instr(chaine,avant)-1+Len(avant)))tout = gauche+apres+droitechaine = toutEnd IfLoopfinal = chaineEnd Functionpar :Function RS(chaine As String, avant As String, apres As String) As StringDim gauche As String, droite As String, tout As StringDim i As Varianti = FalseDo Until i = TrueIf Instr(chaine,avant) = 0 Theni = TrueElsegauche = Left(chaine,Instr(chaine,avant)-1)droite = Right(chaine,Len(chaine)-(Instr(chaine,avant)-1+Len(avant)))tout = gauche+apres+droitechaine = toutEnd IfLoopRS = ChaineEnd Function

Re: un truc tout bête

MessagePublié: 29 Avr 2003 à 09:47
par yop
merci, ça marche nickel.