yad/bash syntax of numeric field in form

304 views
Skip to first unread message

Joe

unread,
Mar 8, 2013, 7:54:20 PM3/8/13
to yad-c...@googlegroups.com
I'm trying out my first form!

I have a very simple working script to print multiple copies of a print file and I'm trying to build a yad front end for it.

Everything works, but the initial value and range for COPIES is being ignored.

Eventually, I want to read variables from yad, but that is commented out until I get yad to work by itself.

What have I coded wrong so the range is ignored?

What (if anything) do I have to change or escape when I put the read code back in?
(I added a blank line after the commented out read just in case. It's only there while the line is commented out.)

Is there a way to tell "NUM" to return an integer? I know how to parse the float if I have to.

TIA
    Joe
    kubuntu oneiric - latest yad from ppa 0.19.1

#!/bin/bash
## kprc
## print multiple copies of a print file
## Copyleft 03/08/2013 - JPmicrosystems
## Usage kprc

source /home/bigbird/bin/bash_trace
SCRIPT_NAME="Print Copies"
##USAGE="Usage is ${SCRIPT_NAME} [-1] <count> <file>"
##DSPTIME=5  ## yad message timeout interval
PQ="${HOME}/pq"
cd "${PQ}"

##IFS='|' read FILE COPIES ONE_SIDED <<< "$( \

yad --title "${SCRIPT_NAME}" --on-top --form \
--field="Print File":FL \
--field="Copies:NUM" '2!0..50!1!0' \
--field="One-sided":CHK \
--width=250 \
##)"
exit ## debug

echo "FILE [${FILE}] COPIES [${COPIES}] ONE_SIDED [${ONE_SIDED}]"
COPIES="${COPIES%%.*}"
[ "${FILE}" == "(null)" ] && FILE=""
[ "${ONE_SIDED}" == "TRUE" ] && ONE_SIDED=1 || ONE_SIDED=0
echo "FILE [${FILE}] COPIES [${COPIES}] ONE_SIDED [${ONE_SIDED}]"

slo.s...@gmail.com

unread,
Mar 9, 2013, 12:21:18 PM3/9/13
to yad-c...@googlegroups.com
Your value for the NUM field is being passed to the file selection (FL) field.  You need an empty place holder after the FL field like this:

...
yad --title "${SCRIPT_NAME}" --on-top --form \
--field="Print File":FL '' \
--field="Copies:NUM" '2!0..50!1!' \
--field="One-sided":CHK \
--width=250
...



--
You received this message because you are subscribed to the Google Groups "yad-common" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joe Consultant

unread,
Mar 10, 2013, 2:37:37 PM3/10/13
to yad-common
Thanks! That fixed it.

But, when I gave FL '', it filled the field with the name of the directory instead of (null). Then I saw that I needed ' ' to make it start with (null).

Just for anyone else reading this, I got it to start with a file in the directory by giving it the file name as the initial value. This had to include the path for this to work.


--
You received this message because you are subscribed to a topic in the Google Groups "yad-common" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/yad-common/bTaLUDtsuyg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to yad-common+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages