Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 02/03/2009, à 18:06

olsman037

[contourné avec gedit] collaboration notepad++ et stata

Bonjour à tous,

J'ai posté ce post dans "autres" mais je crois qu'ici ce serait mieux ici...

J'ai une version de stata  pour linux, et j'ai installé notepad++ avec wine (à part emacs et kate, je n'ai pas trouvé d'éditeur de texte avec une bonne prise en charge du langage stata, et je n'ai pas trouvé comment les faire collaborer simplement avec stata).

Sous windows, on peut lancer stata a partir de notepad++, grâce à ce petit tutoriel : http://mysite.verizon.net/huebler/2008/ … stata.html, qui au taf sous XP marche du feu de dieu...
En gros, il crée un exécutable qui copie et colle des bouts de mon fichier .do (fichier texte) et les envoi à Stata...

Voici en exemple, le script qui m'intéresse le plus (et si je sais comment faire marcher celui là je réussirai bien a faire marcher l'autre!!)


voici le fichier .ini (je ne vois pas trop quoi changer)
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[Stata]
; Path to Stata executable
; Edit to match user's setup, examples for Stata/SE 9 and 8 listed below
statapath = "C:\Program Files\Stata10\wsestata.exe"
; statapath = "C:\Program Files\Stata9\wsestata.exe"
; statapath = "C:\Program Files\Stata8\wsestata.exe"

; Title of Stata Window
; Edit to match user's setup, examples for Stata/SE 9 and 8 listed below
statawin = "Stata/SE 10.1"
; statawin = "Stata/SE 9.2"
; statawin = "Stata/SE 8.2"

[Delays]
; Pause after copying of Stata commands to clipboard, in milliseconds
; Use higher number if script fails (default: 100, recommended range: 0 - 200)
clippause = 100

; Pause between window-related operations, in milliseconds
; Use lower number to speed up script, higher number if script fails (default: 200)
winpause = 200

; Pause between key strokes sent to Stata, in milliseconds
; Use lower number to speed up script, higher number if script fails (default: 1)
keypause = 1

; End of INI file


-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

et voici le fichier à compiler (avec autoit, qui marche sous wine):
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

; Declare variables
Global $ini, $statapath, $statawin, $winpause, $keypause, $clippause, $commands, $tempfile, $tempfile2

; File locations
; Path to INI file
$ini = @ScriptDir & "\rundolines.ini"
; Path to Stata executable
$statapath = IniRead($ini, "Stata", "statapath", "C:\Program Files\Stata10\wsestata.exe")
; Title of Stata window
$statawin = IniRead($ini, "Stata", "statawin", "Stata/IC 10.0")

; Delays
; Pause after copying of Stata commands to clipboard
$clippause = IniRead($ini, "Delays", "clippause", "100")
; Pause between window-related operations
$winpause = IniRead($ini, "Delays", "winpause", "200")
; Pause between keystrokes sent to Stata
$keypause = IniRead($ini, "Delays", "keypause", "1")

; Set SendKeyDelay and WinWaitDelay to speed up or slow down script
Opt("WinWaitDelay", $winpause)
Opt("SendKeyDelay", $keypause)

; If more than one Stata window is open, the window
; that was most recently active will be matched
Opt("WinTitleMatchMode", 2)

; Clear clipboard
ClipPut("")
; Copy selected lines from editor to clipboard
Send("^c")
; Pause avoids problem with clipboard, may be AutoIt or Windows bug
Sleep($clippause)
$commands = ClipGet()

; Terminate script if no commands selected in editor
If $commands = "" Then
  Exit
EndIf

; Create file name in system temporary directory
$tempfile = EnvGet("TEMP") & "\statacmd.tmp"

; Open file for writing and check that it worked
$tempfile2 = FileOpen($tempfile, 2)
If $tempfile2 = -1 Then
  MsgBox(0, "Error: Cannot open temporary file", "at [" & $tempfile & "]")
  Exit
EndIf

; Write commands to temporary file, add CR-LF at end
; to ensure last line is executed by Stata
FileWrite($tempfile2, $commands & @CRLF)
FileClose($tempfile2)

; Check if Stata is already open, start Stata if not
If WinExists($statawin) Then
  WinActivate($statawin)
  WinWaitActive($statawin)
  ; Activate Stata Command Window and select text (if any)
  Send("^4")
  Send("^a")
  ; Run temporary file
  ; Double quotes around $tempfile needed in case path contains blanks
  ClipPut("do " & '"' & $tempfile & '"')
  ; Pause avoids problem with clipboard, may be AutoIt or Windows bug
  Sleep($clippause)
  Send("^v" & "{Enter}")
Else
  Run($statapath)
  WinWaitActive($statawin)
  ; Activate Stata Command Window
  Send("^4")
  ; Run temporary file
  ; Double quotes around $dofile needed in case path contains blanks
  ClipPut("do " & '"' & $tempfile & '"')
  ; Pause avoids problem with clipboard, may be AutoIt or Windows bug
  Sleep($clippause)
  Send("^v" & "{Enter}")
EndIf

; End of script


-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

j'ai essayé de le faire marcher sous intrepid :

J'ai crée un faux stata, dans wine c:\programme files\stata10\ : un fichier texte, renommé en .exe avec dedans

#!/bin/bash
/usr/local/stata/xstata

Quand je le lance avec wine, ça me lance bien stata...

J'ai réussi a incorporer les commandes dans notepad++, stata se lance bien à partir de notepad, mais l'info n'arrive pas jusqu'à lui...

Quelqu'un aurait une idée (peut-être une histoire de dossier temporaire pas pareil que windows..)?

J'y connais rien en programmation (mais ça me fait pas peur de mettre les mains dans le cambouis...)

Help !!!

Merci

Dernière modification par olsman037 (Le 10/03/2009, à 16:06)


Sony Vaio VPC-SB1C5E, i7-2620M, 8Go, GPU AMD 6470M avec triple boot W7, Ubuntu 10.10 et Arch...
Galère les nouveaux sony sous linux!!!! (switch AMD/Intel, touchpad, ethernet,....)

Hors ligne

#2 Le 10/03/2009, à 16:05

olsman037

Re : [contourné avec gedit] collaboration notepad++ et stata

J'ai résolu l'affaire en utilisant gedit et un petit script
http://forum.ubuntu-fr.org/viewtopic.php?id=300206
Ca envoi la sélection à stata... et c'est tout du linux!!!

Y'a plus qu'a faire une coloration aussi bien que celles de notepad++...


Sony Vaio VPC-SB1C5E, i7-2620M, 8Go, GPU AMD 6470M avec triple boot W7, Ubuntu 10.10 et Arch...
Galère les nouveaux sony sous linux!!!! (switch AMD/Intel, touchpad, ethernet,....)

Hors ligne