[TxMt] request user input example?

Alexander Ross alex.j.ross at gmail.com
Wed Mar 21 15:50:49 UTC 2007


In python, the you can use the `raw_input' and `input' commands.

Try this python code:

	print raw_input("Enter your name, sir:")


–Alex

On Mar 21, 2007, at 2:07 AM, Ciarán Walsh wrote:

> The following Perl code:
>
> 	print <STDIN>;
>
> and the following Ruby code:
>
> 	puts gets
>
> both show this behaviour. Just create a new document, set to the  
> relevant language, paste in the code and press command-R to run it.
>
> I'd be very surprised if there was a way to override STDIN  
> behaviour in standard PHP, but if anyone finds one let me know. You  
> could use a function such as this:
>
> function read_input() {
>     if (isset($_SERVER['TM_BUNDLE_SUPPORT'])) {
>         list($button, $input) = explode("\n", `CocoaDialog inputbox  
> --title "STDIN" \\
>             --informative-text "Script is requesting input…" \\
>             --button1 "Send"`);
>         return $input;
>     } else {
>         return fgets(STDIN);
>     }
> }
>
> to read input, which will use a dialog to request input when run  
> with command-shift-R in TextMate, but will use standard STDIN  
> otherwise.
>
> Ciarán
>
> On 21 Mar 2007, at 08:32, Timothy Bates wrote:
>
>> hi there,
>> I see in the change list that
>>
>> [NEW] Perl bundle: PerlMate will now request for user input when  
>> reading from <STDIN> (Ciarán Walsh)
>>
>>
>> This seems very handy: Does anyone have an example of a command  
>> which does this? If it is not perl specific, are there examples of  
>> syntax for other languages, like cmd line php?
>>
>> cheers,
>> t
>> _____________________________________________________________________ 
>> _
>> For new threads USE THIS: textmate at lists.macromates.com
>> (threading gets destroyed and the universe will collapse if you  
>> don't)
>> http://lists.macromates.com/mailman/listinfo/textmate
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate




More information about the textmate mailing list