andrewheiss / SublimeStataEnhanced

Plugin that adds support for Stata 11–15 for Sublime Text 2 and 3
56 stars 22 forks source link

Cannot send more than 8192 characters at a time #34

Closed andrewheiss closed 8 years ago

andrewheiss commented 8 years ago

The plugin cannot send a selection of text containing more than 8192 characters, but I can't figure out if this is because of a limitation in AppleScript or in Stata's AppleScript library.

The plugin will still create valid AppleScript commands for selections longer than 8192 characters, since the command is generated with with lines 69-78 in text_2_stata.py (you can see the resulting command in ST's console). However, longer commands do not get sent to Stata.

This happens either because there's a size limit for strings in AppleScript, or Stata's DoCommandAsync command only accepts strings of a certain size. I don't know which one.

Here's a file for testing (displays a number sequentially until the last line, which has a bunch of 0s to force the file to be 8192 characters):

mikedecr commented 8 years ago

I'm not familiar with Python or AppleScript myself, but for anyone interested in investigating a fix for this issue, I have not to date run into such a character limit using R-Box to send R commands to the console. Might serve as some kind of inspiration for finding a fix for this.

elbersb commented 8 years ago

I also ran into this error, because I need to run a few bigger files. This is what I found: "The length of the stataCommand needs to be less than 8192. If it is not, an INVALID_PARAMETER error will be generated." (Source: http://www.stata.com/automation/#list)

Maybe there should be an option in the plugin to send a whole do-file instead? I could look into that, if there's interest.

andrewheiss commented 8 years ago

Building the file with super+b sends the whole do file to Stata

elbersb commented 8 years ago

The build command didn't work for me, because my finder is set to open do files in Sublime... So that didn't really do anything. I changed my build commands to run the do file from within Stata. That works for me, but maybe has other disadvantages? You can see the changes in the pull request.

Also in the pull request is a change to the run command. When the user attempts to run a command with more than 8191 characters, a dialog box pops open to ask if the whole file should be run instead. If yes, then the same method as described above is used.

andrewheiss commented 8 years ago

Fixed with https://github.com/andrewheiss/SublimeStataEnhanced/pull/42