Mai 2024 | Lun | Mar | Mer | Jeu | Ven | Sam | Dim |
---|
| | 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 | | | Calendrier |
|
| | Problème de script vbs. | |
| | Auteur | Message |
---|
Pedro
Nombre de messages : 1555 Date d'inscription : 19/01/2014
| Sujet: Problème de script vbs. Lun 5 Fév 2024 - 13:19 | |
| Bonjour. Le script vbs créé provoque une erreur, et je ne vois vraiment pas pourquoi !! L'erreur se situe à la ligne 2 du script: les guillemets ne sont pas ajoutés dans la ligne, alors qu'ils sont bien programmés !! Merci de votre aide. - Code:
-
DIM a$,b$,c$,d$,e$,f$,h%,l%,n%,t%,x%,w%,y%,zz%
caption 0,"Grammaire." f$ = dir_current$+"\gifs_animes\prof3.gif"
n%=0 file_open_read 1,"message.txt" while file_eof(1)<>1 n%=n%+1 a$=file_readln$(1) if instr(a$,"Cliquez")>0 then a$="La leçon est maintenant terminée." if n%<5 if n%=1 then l%=val(a$) if n%=2 then t%=val(a$) if n%=3 then w%=val(a$) if n%=4 h%=val(a$) Gifanime(f$,l%,t%,w%,h%) end_if end_if if n%>4 if trim$(a$)="" wait 1000 else corriger_accents() Message_Vocal(a$) end_if end_if end_while file_close 1
terminate
end
' ------------------------------------------------------------------------------ sub corriger_accents() c$="è Å“ ç É ï â ä û ô ù ß ö ü Ãœ Ö á à ó ú ñ ¿ ¡ " d$="é ê î è oe ç É ï â ä û ô ù ß ö ü Ü Ö á í ó ú ñ ¿ ¡ "
for zz%=1 to len(c$)/3 while 0=0 e$=mid$(c$,zz%*3-2,2) x%=instr(a$,e$) if x%=0 then exit_while a$=left$(a$,x%-1)+mid$(d$,zz%*3-2,1)+right_pos$(a$,x%+2) end_while next zz% while 0=0 x%=instr(a$,"Ã"+chr$(160)) if x%=0 then exit_while a$=left$(a$,x%-1)+"à"+right_pos$(a$,x%+2) end_while end_sub
sub Message_Vocal(texte$) dim_local scriptVBS$ scriptVBS$ = "script.vbs" file_open_write 2, scriptVBS$ file_writeln 2, "DIM speaks, speech" file_writeln 2, "speaks = " + chr$(34)+texte$+chr$(34) file_writeln 2, "Set speech = CreateObject(" + chr$(34) + "sapi.spvoice" + chr$(34) + ")" file_writeln 2, "speech.Speak speaks" file_close 2 execute_wait scriptVBS$ file_delete scriptVBS$ end_sub ' ------------------------------------------------------------------------------
SUB Gifanime(f$,l%,t%,w%,h%) ' Affichage en x%,y% du gif animé f$ DIM_LOCAL fh$,v%(4),hv% fh$ = "temporaire.htm" ' FILEBIN_OPEN_READ 9,f$ ' Le compilateur ne reconnaît pas FILEBIN_BLOCK_READ. ' FILEBIN_POSITION 9,6: FILEBIN_BLOCK_READ 9,4,v%(0) ' dimensions du gif ' w% = v%(0) + 256*v%(1): h% = v%(2) + 256*v%(3) left 0,l% top 0,t% width 0,w%+35 height 0,h%+55 ' FILEBIN_CLOSE 9 FILE_OPEN_WRITE 9,fh$ FILE_WRITELN 9,"<HTML>" file_writeln 9,"<body bgcolor='#ffffa4'>" FILE_WRITELN 9,"<IMG SRC="+f$ file_writeln 9,"</body>" FILE_WRITELN 9,"</HTML>" FILE_CLOSE 9 hv% = 900: WHILE OBJECT_EXISTS(hv%)=1: hv% = hv%+1: END_WHILE HVIEWER hv%: TOP hv%,0: LEFT hv%,0: WIDTH hv%,w%+20: HEIGHT hv%,h%+20 FILE_LOAD hv%,fh$ FILE_DELETE fh$ END_SUB | |
| | | Marc
Nombre de messages : 2392 Age : 63 Localisation : TOURS (37) Date d'inscription : 17/03/2014
| Sujet: Re: Problème de script vbs. Lun 5 Fév 2024 - 15:49 | |
| Bonjour Pedro ! Pour effectuer un test, pourrais-tu nous partager les fichiers message.txt et prof3.gif ? - Citation :
- L'erreur se situe à la ligne 2 du script: les guillemets ne sont pas ajoutés dans la ligne, alors qu'ils sont bien programmés !!
A la lecture du source, je ne vois pas d’erreur dans les scripts VBS. Par contre, les lignes 14,15 et 16 semblent erronées. L'expression « val(a$) » est correcte uniquement si a$ représente une valeur numérique... | |
| | | Pedro
Nombre de messages : 1555 Date d'inscription : 19/01/2014
| Sujet: Problème de script vbs. Mar 6 Fév 2024 - 13:51 | |
| | |
| | | Marc
Nombre de messages : 2392 Age : 63 Localisation : TOURS (37) Date d'inscription : 17/03/2014
| Sujet: Re: Problème de script vbs. Mar 6 Fév 2024 - 15:56 | |
| Bonjour Pedro, Merci pour les fichiers complémentaires. Voici ton code fonctionnel après quelques modifications : - Code:
-
DIM a$,b$,c$,d$,e$,f$,h%,l%,n%,t%,x%,w%,y%,zz%
caption 0,"Grammaire." f$ = dir_current$+"\gifs_animes\prof3.gif"
create_hide hviewer 900 create_show
n%=0 file_open_read 1,"message.txt" while file_eof(1)<>1 n%=n%+1 a$=file_readln$(1) if instr(a$,"Cliquez")>0 then a$="La leçon est maintenant terminée." if n%<5 if n%=1 then l%=val(a$) if n%=2 then t%=val(a$) if n%=3 then w%=val(a$) if n%=4 h%=val(a$) Gifanime(f$,l%,t%,w%,h%) end_if end_if if n%>4 if trim$(a$)="" wait 1000 else corriger_accents() Message_Vocal(a$) end_if end_if end_while file_close 1
terminate
end
' ------------------------------------------------------------------------------ sub corriger_accents() c$="è Å“ ç É ï â ä û ô ù ß ö ü Ãœ Ö á à ó ú ñ ¿ ¡ " d$="é ê î è oe ç É ï â ä û ô ù ß ö ü Ü Ö á í ó ú ñ ¿ ¡ "
for zz%=1 to len(c$)/3 while 0=0 e$=mid$(c$,zz%*3-2,2) x%=instr(a$,e$) if x%=0 then exit_while a$=left$(a$,x%-1)+mid$(d$,zz%*3-2,1)+right_pos$(a$,x%+2) end_while next zz% while 0=0 x%=instr(a$,"Ã"+chr$(160)) if x%=0 then exit_while a$=left$(a$,x%-1)+"à"+right_pos$(a$,x%+2) end_while end_sub
sub Message_Vocal(texte$) dim_local scriptVBS$ scriptVBS$ = "script.vbs" file_open_write 2, scriptVBS$ file_writeln 2, "DIM speaks, speech" file_writeln 2, "speaks = " + chr$(34)+texte$+chr$(34) file_writeln 2, "Set speech = CreateObject(" + chr$(34) + "sapi.spvoice" + chr$(34) + ")" file_writeln 2, "speech.Speak speaks" file_close 2 execute_wait scriptVBS$ file_delete scriptVBS$ end_sub ' ------------------------------------------------------------------------------
SUB Gifanime(f$,l%,t%,w%,h%) ' Affichage en x%,y% du gif animé f$ DIM_LOCAL fh$,v%(4),hv% fh$ = "temporaire.htm" ' FILEBIN_OPEN_READ 9,f$ ' Le compilateur ne reconnaît pas FILEBIN_BLOCK_READ. ' FILEBIN_POSITION 9,6: FILEBIN_BLOCK_READ 9,4,v%(0) ' dimensions du gif ' w% = v%(0) + 256*v%(1): h% = v%(2) + 256*v%(3) show 900 left 0,l% top 0,t% width 0,w%+35 height 0,h%+55 ' FILEBIN_CLOSE 9 FILE_OPEN_WRITE 9,fh$ FILE_WRITELN 9,"<HTML>" file_writeln 9,"<body bgcolor='#ffffa4'>"
' ligne originale : ' FILE_WRITELN 9,"<IMG SRC="+f$
' ligne modifiée par Marc : FILE_WRITELN 9,"<IMG SRC="+chr$(34) + f$ + chr$(34) + " >"
file_writeln 9,"</body>" FILE_WRITELN 9,"</HTML>" FILE_CLOSE 9 hv% = 900 TOP hv%,0: LEFT hv%,0: WIDTH hv%,w%+20: HEIGHT hv%,h%+20 FILE_LOAD hv%,fh$ FILE_DELETE fh$ END_SUB L’objet HVIEWER est créé en début de code pour ne pas interférer avec la synthèse vocale. Pour l’afficher, faire un SHOW 900. Pour le cacher c'est un HIDE 900. Pour l’affichage de l’image GIF, j’ai corrigé la ligne de la balise «img scr ». Bonne continuation ! | |
| | | Pedro
Nombre de messages : 1555 Date d'inscription : 19/01/2014
| Sujet: Problème de script vbs. Mar 6 Fév 2024 - 16:11 | |
| Bonjour.
Merci beaucoup Marc pour les quelques modifications. Cette fois, le script fonctionne parfaitement.
Une pause est bien effectuée après chaque phrase, et la gif animée disparaît à la fin de la lecture !!
Bien évidemment, le mouvement des lèvres de la locutrice n'est pas synchronisée avec le texte, s'agissant d'une gif animée. Mais enfin, cela m'évite de créer de multiples vidéos qui ne feraient que gonfler démesurément la taille de mon logiciel.
Encore merci. | |
| | | Contenu sponsorisé
| Sujet: Re: Problème de script vbs. | |
| |
| | | | Problème de script vbs. | |
|
Sujets similaires | |
|
| Permission de ce forum: | Vous ne pouvez pas répondre aux sujets dans ce forum
| |
| |
| |