AppleScript: Set default colour for ColourPicker from variable - applescript

I'm trying to call the ColourPicker from AppleScript using a variable as the default colours.
However I cannot get this to work.
To illustrate my issue I wrote a little code sample of what I tried, which does not work.
set defaultColour to do shell script "echo {65535, 0, 65535}"
set RGB to (choose color default color defaultColour)
##set RGB to (choose color default color {65535, 0, 65535})
I included the working, default code for reference.
Thanks in advance for your help.

Using run script command you can always convert the "text-form integers list " directly to usual integers list. So, repeat loop no need at all:
set defaultColour to "{65535, 0, 65535}"
set RGB to choose color default color (run script defaultColour)

As I learned that the returned string is interpreted as text I started digging on how to turn the string into numbers. I came up with this:
set defaultColour to do shell script "echo {65535, 0, 65535}"
set currentColour to {}
repeat with i from 1 to count of words in defaultColour
set rgbValue to word i of defaultColour as number
set the end of currentColour to rgbValue
end repeat
set RGB to (choose color default color currentColour)
I got inspired by #philastokes (via applehelpwriter.com).

Related

Batch code reading problem equal dash apostrophe

I got stuck with reading this script. I assume that SET RAWDATA is some sort of setting the parameters, but can someone tell me what is all about. Particulary I wonder about this syntax: '='%, ' ='%, =%.
SET RAWDATA=%RAWDATA:~0,-1%
SET KEYS=%KEYS:~0,-2%
SET RAWDATA=%RAWDATA: =%
SET RAWDATA=%RAWDATA:' ='%
SET RAWDATA=%RAWDATA: '='%
SET RAWDATA=NULL,now(),%RAWDATA%

A bash/gnuplot script to produce movie-like effects

I would like to plot a sequence of images one after the other on the same window using gnuplot. Images are all the same exact size and I have many of them sequentially called test_0X.gnu and are in gnuplot format.
I wrote this in bash
#! /bin/bash
for i in $(seq -f "%06g" 0 1000)
do
echo "set term pdf enhance color" > script.plg
echo "set output 'demo.pdf'" >> script.plg
echo "plot 'test_$i.gnu' with lines" >> script.plg
echo "set output"
gnuplot < script.plg
evince demo.pdf &
sleep 0.3
done;
The seq -f ensures the correct number of padded zeros is present before the number.
This works but once the script starts I am unable to stop it, as ctrl+c or ctrl+z doesn't work and I cannot access other terminal due to constant coming up of a pdf windows.
How do I stop this?
How do I make the sequence skip (e.g. by 10) and show me only test_000010.gnu, test_000020.gnu, .. etc.
Bonus: Any other, more sensible way to do this is welcome.
Just write a short gnuplot script
set terminal wxt
files = system('ls test_*.gnu')
do for [file in files] {
plot file with lines
pause 0.5
}
and run this
gnuplots "gif" terminal can produce a readymade animation.
skip=5 # change as needed
set term gif animate 10 # 10/100 s delay between frames
set out "test.gif"
# assuming your data files are named "test_0001.dat" etc.
do for [i=1:100:skip] {plot sprintf("test_%04.f.dat",i)}
set out

Gnuplot script file not working under Windows when plotting single points

I am a bit confused, I have the same gnuplot script that works under
Version 4.6 patchlevel 4 Build System: Linux x86_64
but not under
Version 4.6 patchlevel 5 Build System: MS-Windows 32 bit
the script file is
clear
set terminal epslatex size 20cm,14cm
set output 'mwe.tex'
set style data points
set style line 101 lc rgb "black" lw 2 pt 1 ps 2
set grid
set xlabel 'xlabel'
set ylabel 'ylabel'
xmin= -0.2
xmax= 0.7
set xrange [xmin:xmax]
set key below
plot "<echo '0.408 270.7'" with points ls 101 notitle,\
Does the command "<echo somehow not work under Windows?
The error I get with Windows is 'skipping unreadable file "
The < pipes the following command through a shell (see help special-filenames). The command itself is mostly system-dependent and not part of gnuplot (in this case the echo).
If you want a portable way to specify a single point, you can set an empty label and use the point option:
set style line 101 lc rgb "black" lw 2 pt 1 ps 2
set label at 0.408, 270.7 "" point ls 101
Note, that this works only if you also plot other stuff, since the label is set only if the plot command is invoked.
echo (lower case) is a unix command. In windows you will need to use "<ECHO in uppercase.

Bash, Always display colored bar at top of screen

Is there anyway to modify the bash profile scripts to always display a colored bar at top of screen. I have a requirement to show a colored hostname, username, and ipaddress on the screen at all times, but i don't want to overload PS1 as it would make the prompt take up over half of the default console width.
Not perfect, but this shows you how to fix part of your prompt on the first row of the screen:
PS1='\w \[\e[s\e[1;1H\e[42m\]\h \u ipaddress\[\e[0m\e[u\]\$ '
A breakdown:
\e[s - save the current cursor position
\e[1;1H - move the cursor to row 1, column 1 (numbered from the upper left-hand corner
\e[u - restore the cursor to the previously saved position
\e42m - make the background green
\e0m - restore the default foreground/background colors
\[...\] - enclose the various non-printing characters so that bash can correctly compute the length of the prompt.
Wikipedia lists other escape codes. The two things missing from this answer are how to extend the bar all the way across the string and how to set the correct IP address.
Update: I believe this covers the changes that ruckc made:
PS1='\[\e[s\e[1;1H\e[42m\e[K\h \u ipaddress\e[0m\e[u\]\w \$ '
How about add a \n inside your PS1, so that you always use a new line with full width?
if you are looking for something less hacky (but maybe overkill), consider byobu
https://en.wikipedia.org/wiki/Byobu_(software)
Alternatively, if you are using xterms, you could set the xterm title instead:
export PS1="\[\033]0;\u $(host $(hostname))\007\]\u#\h:\w\$ "
This sets your xterm title, and sets your prompt to contain username#host:pwd.
My .bashrc contains something like this so PS1 is set correctly depending on whether we're in an xterm or not:
if [[ -n "$TERM" ]] ; then
if ( echo $TERM | $GREP -q xterm ) ; then
export PS1="\[\033]0;\u#\h:\w\007\]\u#\h:\w\$ "
else
export PS1="\u#\h:\w\$ "
fi
fi

setting text to clipboard in applescript

Whenever i try to run the following code:
set RAccounts to (read POSIX file "/Users/student/Desktop/Accounts.txt")
set word 1 of RAccounts to clipboard
It gives me the error " cannot set text to clipboard " any help without having to do keystrokes etc. also when i try
get word 1 of RAccounts and paste
it tells me cannot make into type boolean any help guys?
If you are you trying to put word 1 into the clipboard.
set the clipboard to word 1 of RAccounts

Resources