IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

modifier valeurs d'un paramètre sas sous vb


Sujet :

VBScript

  1. #1
    Membre régulier
    Inscrit en
    Mars 2008
    Messages
    156
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 156
    Points : 73
    Points
    73
    Par défaut modifier valeurs d'un paramètre sas sous vb
    Bonjour,

    Je souhaiterai modifier la valeur d'une invite dans mon script vb (qui lance un projet SASEG).
    Je dispose d'un unique paramètre et je voudrais lui passer la date du jour.

    Voici le code que j'ai en partie adapté (code trouvé sur le site du support technique SAS) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
     
    Option Explicit
    Dim app
     
    Call dowork
     
    'shut down the app
    If not (app Is Nothing) Then
        app.Quit
        Set app = Nothing
    End If
     
     
    Sub dowork()
        On Error Resume Next
        '----
        ' Start up Enterprise Guide using the project name
        '----
        Dim prjName
        Dim prjObject
     
        prjName = "\\SUDOUEST\Dev\SAS\Projet.egp"    'Project Name
     
        Set app = CreateObject("SASEGObjectModel.Application.4.3")
        If Checkerror("CreateObject") = True Then
            Exit Sub
        End If
     
        '-----
        ' open the project
        '-----
        Set prjObject = app.Open(prjName,"")
        If Checkerror("app.Open") = True Then
            Exit Sub
        End If
     
    '---------------------------------
    'Begin processing the project
    '---------------------------------
     
    ' Discover the parameters for the project
    Set parmList = prjObject.Parameters
     
    ' Get the default value from the first parameter
    Set parm = parmList.Item(0)
     
    ' Change the value of the parameter to la date du jour and display the new value.
    parm.Value = Date()
     
     
    '-------------------------------
    'Begin processing the stored process
    '-------------------------------
    Set spList = prjObject.StoredProcessCollection
     
    ' Cycle through the list of stored processes and the parameters for each of them.
    for n=0 to (spList.Count - 1)
    	Set sp = spList.Item(n)
    	' Get the list of parameters
    	Set spParamList = sp.Parameters
     
    	' Process each stored process parameter
          for i=0 to (spParamList.Count - 1)
     
    	    Set spParam = spParamList.Item(i)
    		' Change the value of the parameter
    	    spParam.Value = Date()
     
    		' Save the project with the updated stored process
    	    prjObject.Save
    	Next
    Next
     
     
        '-----
        ' run the project
        '-----
        prjObject.run
        If Checkerror("Project.run") = True Then
            Exit Sub
        End If
     
     
        '-----
        ' Save the new project
        '-----
        prjObject.Save
        If Checkerror("Project.Save") = True Then
            Exit Sub
        End If
     
        '-----
        ' Close the project
        '-----
        prjObject.Close
        If Checkerror("Project.Close") = True Then
            Exit Sub
        End If
     
    End Sub
     
    Function Checkerror(fnName)
        Checkerror = False
     
        Dim strmsg
        Dim errNum
     
        If Err.Number <> 0 Then
            strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description
            'MsgBox strmsg  'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
            Checkerror = True
        End If
     
    End Function

    Sans succès, si quelqu'un a une idée...

  2. #2
    Rédacteur
    Avatar de omen999
    Profil pro
    Inscrit en
    Février 2006
    Messages
    1 296
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 1 296
    Points : 3 549
    Points
    3 549
    Par défaut
    bonjour,
    Sans succès, si quelqu'un a une idée...
    un devin peut-être...
    commence déjà par décommenter la ligne 110 et dis-nous ce que tu lis
    puisque l'auteur du script s'est paluché une gestion centralisée des erreurs autant que ça serve
    nomen omen, nemo non omen - Consultez la FAQ VBScript et les cours et tutoriels VBScript
    le plus terrible lorsqu'une voiture renverse un piéton, c'est que ce sont les freins qui hurlent. (ramón)
    pas de questions techniques par mp

Discussions similaires

  1. Numpy - Modifier valeurs sous condition
    Par mydomdom dans le forum Calcul scientifique
    Réponses: 4
    Dernier message: 24/04/2014, 16h14
  2. Réponses: 0
    Dernier message: 26/11/2012, 23h58
  3. Réponses: 2
    Dernier message: 26/06/2012, 08h49
  4. Réponses: 2
    Dernier message: 11/04/2011, 16h12
  5. Réponses: 6
    Dernier message: 28/10/2004, 10h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo