Re: [julia-users] readall() from osascript process (MacOS X)?

2016-02-04 Thread cormullion
Thanks!

Re: [julia-users] readall() from osascript process (MacOS X)?

2016-02-04 Thread cormullion
Yay, it all works, thanks again. BTW, it's for this hacky script that I use 
when editing text files — it pads out the second part of each line starting at 
a particular character so that all the lines are vertically aligned on that 
character (probably much easier in other editors...).

 function readwrite()
 userinput = readall(`osascript -e "display dialog \"Align on\" default 
answer \"#\""`)
 chr = chomp(last(split(userinput, ':')))
 widest = 1
 # read all input into array
 buffer = []
 while !eof(STDIN)
 line = chomp(readline(STDIN))
 chrpos = contains(line, chr)
 if chrpos
 if searchindex(line, chr) > widest
 widest = searchindex(line, chr)
 end
 end
 push!(buffer, line)
 end

 for line in buffer
 chrpos = contains(line, chr)
 if chrpos && (line != "")
 # chop line in two
 chrpos = searchindex(line, chr)
 firsthalf = line[1:chrpos-1]
 secondhalf = line[chrpos:end]
 newline = rpad(firsthalf, widest, " ") * secondhalf
 println(newline)
 else
 # don't bother
 println(line)
 end
 end
 end



Re: [julia-users] readall() from osascript process (MacOS X)?

2016-02-03 Thread Josef Sachs
> On Wed, 3 Feb 2016 11:03:07 -0800 (PST),  said:

> I'd like to get some information from running the `osascript` command on 
> MacOS X, For example:

> julia> run(`osascript -e "display dialog \"Character\" default answer 
> \"#\""`)
> button returned:OK, text returned:#

> julia> typeof(ans)
> Void

> I tried to use `readall` to read the result that's printed/returned, but no 
> luck.

> julia> readall(run(`osascript -e "display dialog \"Character\" default 
> answer \"#\""`))
> button returned:OK, text returned:#
> ERROR: MethodError: `readall` has no method matching readall(::Void)

> Anyone know of a trick to get information back from this process?

Leave out the run.

julia> x = readall(`osascript -e "display dialog \"Character\" default answer 
\"#\""`)

I think this is going to change a little in 0.5.


[julia-users] readall() from osascript process (MacOS X)?

2016-02-03 Thread cormullion
I'd like to get some information from running the `osascript` command on 
MacOS X, For example:

julia> run(`osascript -e "display dialog \"Character\" default answer 
\"#\""`)
button returned:OK, text returned:#

julia> typeof(ans)
Void

I tried to use `readall` to read the result that's printed/returned, but no 
luck.

julia> readall(run(`osascript -e "display dialog \"Character\" default 
answer \"#\""`))
button returned:OK, text returned:#
ERROR: MethodError: `readall` has no method matching readall(::Void)

Anyone know of a trick to get information back from this process?