Page 1 sur 1

[R] Problème de variable dans fonction

Posté : mer. 28 mai 2008 11:13
par sergio
bonjour,

mon problème : je n'arrive pas à changer la "valeur" d'une variable en passant à un autre fonction.

ce que je cherche à faire :

fonction1
je cherche dans un repertoire sur un serveur tous les fichiers ini

fonction2
je recupere le fichier ini et je lis la premiere section "Binaires"
si les binaires existes ok je pase à la lecture de la deuxieme section "Dialogues"
sinon je passe au fichier ini suivant (fonction1) .
fonction3
ensuite je lis la deuxieme section "Dialogues"
et la je recopie avec "robocopy" les differents repertoires indiqué dans cette section.

fonction4 fin

les fonctions testés une apres l'autre fonctionnent, quand je veux enchainer la fonction 1 avec les autres je ne conserve "qu"une valeur" et je boucle desssus.


merci par avance pour votre aide ;-)

le code :
► Afficher le texte

Re: [..] Problème de variable dans fonction

Posté : mer. 28 mai 2008 15:07
par ani
bonjour sergio,
excuse moi, mais çà fait bien la troisème fois que je modifie ton titre (tu oublie la balise [..] voir ce (lien )) pourquoi tu le modifie ?

Pour ton post, je ne pourrait aider, trop de difficulté, voilàvoilà

Re: [..] Problème de variable dans fonction

Posté : mer. 28 mai 2008 16:55
par sergio
bonjour ani,

Je vous prie de m'excuser je n'ai pas modifié le titre j'essayais de modifier la "colorisation" du code pour que ce soit plus lisible. car j'avais commencé avec forumcolor.

je n'avais pas vu pour la balise [..] dans le titre, j'en étais à peine à la balise [R] :mrgreen:

Re: [..] Problème de variable dans fonction

Posté : mer. 28 mai 2008 20:22
par ani
ok ok autant pour moi,
Pour la coloration du code, l'administration a suspendu cette partie pour un allegemement.

je jette un oeil a votre code, mais je ne promet rien

Re: [..] Problème de variable dans fonction

Posté : mer. 28 mai 2008 22:44
par Tlem
ani a écrit :Pour la coloration du code, l'administration a suspendu cette partie pour un allegemement.
Il n'est pas interdit d'utiliser la coloration pour présenter un code (Au contraire).
Simplement, si d'autres utilisateurs doivent reprendre le code en entier pour les corrections ... il vaut mieux passer par la balise de code classique (Inutile de charger la base de donnée pour rien ;) ).

Re: [..] Problème de variable dans fonction

Posté : jeu. 29 mai 2008 06:34
par Greenhorn
Hi,

I don't understand all of your code, but maybe you mean something like this here ...
► Afficher le texte
EDIT:
What I wanna point to is that it's better to create functions with a return value and then work with the result of the function.
If you could post an example.ini I could give you a better example for a solution. ;)

Maybe also interesting ...
http://www.autoitscript.com/forum/index ... bocopy+gui


Greetz
Greenhorn

Re: [..] Problème de variable dans fonction

Posté : ven. 30 mai 2008 09:20
par sergio
thank you Greenhorn for your help,

the guideline that you gave me is good.

in a few lines that I try to do:

we have a software with several possible profiles. There is a common part (directories identical) and directories.

in a repertoire I have a number of file. ini representing different profiles (you can add)
in this file ini I have two sections:
the first list which binaries specific profile.
the second section is the name of the directory profile.

what I try to do:
1 - read the files. Ini one by one
2 - reading the section binary: if all executables ini file in question exists in this case go to Step 3 if not move to Step 1 and read another file ini
3 - reading the section directory and launching the copy robocopy
4 - end

-----------------------------------------------------------------------------------
file.ini

Code : Tout sélectionner

#Executables à tester et Dialogue à copier 
[Binaires]
bin1 = C:\appli\grd\amospse\amospse.exe
bin2 = C:\apppli\ggh\amppat\amppat.exe
[Dialogues]
dial1 = gaa 
dial2 = gac  
dial3 = gad
dial4 = ggh
dial5 = grd
dial6 = windows
-----------------------------------------------------------------------------------

Re: [..] Problème de variable dans fonction

Posté : ven. 30 mai 2008 13:17
par Greenhorn
Thank you very much for your detailed reply, my dear. :D

I'll try to give you an example script ...


Greetz
Greenhorn

Re: [..] Problème de variable dans fonction

Posté : lun. 02 juin 2008 15:59
par Greenhorn
Hi sergio,

I have changed the script a little bit, maybe you find it's more practicable ... :roll:

Code : Tout sélectionner

; step 1
; listage des fichiers *.ini dans le répertoire
$aFichiersIni = _FileListToArray3 ($REP_INI, "*.ini", 1, 1, 1,"")

For $i = 1 To $aFichiersIni[0]
   
   ;step 2
    _trouve_bin ($aFichiersIni[$i])
    If @error Then ContinueLoop
   
Next



func _trouve_bin ($reference)
   
    $aDir = IniReadSectionNames($reference)

    If @error Then
        Return SetError(1)
    EndIf

    For $i = 1 To $aDir[0]
        
        $aBinaries = IniReadSection($reference, $aDir[$i])
        
        For $ii = 1 to $aBinaries[0][0]
            
            If Not FileExists ($aBinaries[$i][1]) Then
                $OK = 0
                ExitLoop
            Else
                $OK = 1
            EndIf
        Next
        
        If $OK Then
            
            RunAsWait ( $DomainUserName, _
                        $DomainName, _
                        $UserPassword, _
                        1, _
                        'c:\Windows\robocopy.exe "' & $REP_ORIG & $aBinaries[$i] & '" "' & $REP_DEST & $aBinaries[$i] & '" /MIR /R:1 /W:1', _
                        "c:\TMP", @SW_MAXIMIZE)
            
            If @error Then MsgBox(266256, Default, 'Error copying !', 5)
        EndIf
    Next
   
EndFunc


#cs - example.ini
[C:\appli\grd]
    bin1=amospse\amospse1.exe
    bin2=amospse\amospse2.exe
[C:\appli\ggh]
    bin1=amppat\amppat1.exe
    bin1=amppat\amppat2.exe
#ce

 
Salut
Greenhorn

Re: [..] Problème de variable dans fonction

Posté : mar. 03 juin 2008 11:30
par sergio
dear Greenhorn,
thank you for your valuable assistance,
I have no experience in the development of application, made a few small scripts.
I left with an idea, but you will allow me just to reach my goals.
greetings :mrgreen:

Re: [..] Problème de variable dans fonction

Posté : mer. 04 juin 2008 01:50
par Greenhorn
Moin, Moin sergio,

naturally it must be:

Code : Tout sélectionner

If Not FileExists ($aDir[$i] & '\' & $aBinaries[$i][1]) Then
    $OK = 0
    ExitLoop
Else
     $OK = 1
EndIf
Salut :wink:

Re: [..] Problème de variable dans fonction

Posté : mer. 04 juin 2008 10:29
par sergio
danke viele GreenHorn :mrgreen: