Extract line number with checkbox - livecode

how can i extract line with check box. In my stuck i have
text fld: "news",
group of checkbox: "Checkboxs",
checkbox: "Check 1 - Check 10",
button: "button" and a destination fld "Lower".
Now i went:
1) when i select multiple checkbox, checkbox will extract multiple line form text fld "news".
2) when i press button, button get text from fld "news" through checkbox and put it to fld "lower" horizontally one by one.
I have upload my project here you may check it.
Plz advice.

I think you want something like:
on mouseUp
local tLower, tNews, tLineNumber
put field "news" into tNews
repeat for each line tID in the childControlIDs of group "Checkboxs"
-- checkboxes named "Check <linenumber>"
put word 2 of the short name of control id tID into tLineNumber
put line tLineNumber of tNews & return after tLower
end repeat
delete the last char of tLower
put tLower into field "lower"
end mouseUp

Related

Capybara how to test for the disabled option in a dropdown list

I am new to Capybara and am trying to write a test where the default option in a dropdown list will change depending on the link the user clicks on in the preceding page. e.g. click on link1, then link1 will be the default option.
I found online someone said to test for the disabled option in a dropdown with the following, but I still can't get it to work.
Then /^"([^"]*)" should be selected for "([^"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
with_scope(selector) do
field_labeled(field).find(:xpath, ".//option[#selected = 'selected'][text() = '#{value}']").should be_present
end
end
Based on your description I'm assuming you mean the selected option rather than the disabled option. To do that in Capybara would be
expect(page).to have_select('id, name, placeholder or label text of select', selected: 'text of selected option')
Using that in your cucumber step with the possibility of scoping would then become
Then /^"([^"]*)" should be selected for "([^"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
within(selector) do
expect(page).to have_select(field, selected: value)
end
end
which you would call something like.
Then "California" should be selected for "State" within "#user_profile"
If you did really want to check for a disabled option in a select you could do it like
select = find(:select, 'id, name, placeholder or label text of select')
expect(select).to have_selector(:option, 'text of disabled option', disabled: true)
If you want to test if you have the option disabled.
Find the number of elements that disable that area. With the command
"size".
If the result is 1 or 0, you can type this command.
Example:
And(/^All segments in this area need to be subject to the product (\d+) see it$/) do
area=find_by_id('temelGostergeler')
number=area.all("div#urunTab.caption[style='display: none;']").size
print "All of "
expect(number).to eq 0
if
number==1
number="No product"
else
number="There are product"
end
p number
end
You can synchronize with the expect command if you want.

Sort string by values in text file using applescript

I'm trying to build an applescript to sort tags in the Genre field of a music file in iTunes.
I'm using a semi-colon separated list for the Genre field, like this: Rock; Art Rock; Female Vocalists
The string I want to sort is named genreList in my script:
{"Art Rock", "Female Vocalists", "Rock"}
My preferred tag order is listed as sortList:
{"Rock", "Dance", "Art Rock", "New Wave", "Female Vocalists", "Male Vocalists"}
I want the items in genreList to sort according to sortList, like this:
{"Rock", "Art Rock", "Female Vocalists"}
How do I sort the first list using the second list? I've searched here and on Google, but as I am a scripting novice I'm not even sure I'm searching for the right terms.
Try this, select one or multiple tracks in iTunes and run the script.
If the separator is supposed to be semicolon + space, please change the second property line.
If the genre property does not contain the separator, nothing will be changed.
If a genre does not match the items in the sorted list it will be appended at the end.
property sortedGenreList : {"Rock", "Dance", "Art Rock", "New Wave", "Female Vocalists", "Male Vocalists"}
property separator : ";"
tell application "iTunes" to set selectedItems to (get selection)
if selectedItems is {} then
display dialog "Nothing selected" buttons {"Cancel"} default button 1
end if
set {TID, text item delimiters} to {text item delimiters, separator}
repeat with aTrack in selectedItems
set orderedGenreList to {}
set nonOrderableGenres to {}
tell application "iTunes" to set trackGenreList to text items of (get genre of aTrack)
if (count trackGenreList) > 1 then
repeat with aGenre in trackGenreList
if sortedGenreList does not contain aGenre then set end of nonOrderableGenres to contents of aGenre
end repeat
repeat with aGenre in sortedGenreList
if trackGenreList contains aGenre then
set end of orderedGenreList to contents of aGenre
end if
end repeat
set orderedGenres to (orderedGenreList & nonOrderableGenres) as text
tell application "iTunes" to set genre of aTrack to orderedGenres
end if
end repeat
set text item delimiters to TID
If you want to use a text file with a genre per line replace the first property line with
set sortedGenreList to paragraphs of (read (choose file))

Some problems in model window

I create a model window(new Substack) for find a text in scrolling field. But it's not working i am using the following code
the following code calls the modal window
on mouseUp
modal stack "sub"
end mouseUp
The following code for finding a string in Scrolling field
on mouseUp
if field "EE" is empty then
answer "Please enter the filename" with "Ok"
end if
if field "EE" is not empty then
put the text of field "EE" into xx
--answer xx
repeat for each word myword in fld "MytextField"
if fld "MytextField" contains xx then find xx in fld "MytextField"
exit to top
end repeat
end if
end mouseUp
Here "MytextField" is in main stack
You don't explain what "not working" means, but most likely because stack "sub" is a different stack, you need to use an explicit reference for the field:
field "EE" of stack "myMainStack"
Another option is to set the defaultStack property to the name of your main stack, so you don't need to use explicit object references:
set the defaultStack to "myMainStack"
if field "EE" is empty then...
Remember to change the defaultStack back to your substack if you ever need to refer to an object in the substack.
You also don't need the repeat loop or the test for "contains". The loop isn't doing anything. All you need is
find xx in field "MytextField"
If the text isn't there the result will be "not found", otherwise the text will be boxed.
put the text of field "EE" into xx
if xx is not empty then
find xx in field "MytextField"
if the result is not empty then
answer the result
end if
end if

Return display dialog if string isn't found Applescript

I've created an Applescript that lets me type in a bunch of commands. I'm working on the section for playing music. Basically, it removes the word play (which is the command) from the string with text delimiters and then searches for the rest of the string in iTunes. If the song is there, it plays it. But if it's not, it just quits. So, I'm wondering if I can display a dialog that says something like "Song not found" if the song isn't in the iTunes library. Here is my code:
display dialog "Enter a command" default answer "" with title "Enter a command"
set userInput to text returned of the result
if userInput contains "Play" then set {TID, text item delimiters} to {text item delimiters, {"Play "}}
set resultString to text item 2 of userInput
set text item delimiters to TID
set playSong to (resultString as string)
if userInput contains "Play" then tell application "iTunes"
set mySongs to every track of library playlist 1 whose name is playSong
repeat with aSong in mySongs
play aSong
end repeat
end tell
Thanks :)
Just count the returned tracks:
if (count of mySongs) = 0 then
display alert "Song not found"
end if
Full script:
display dialog "Enter a command" default answer "" with title "Enter a command"
set userInput to text returned of the result
if userInput contains "Play" then set {TID, text item delimiters} to {text item delimiters, {"Play "}}
set resultString to text item 2 of userInput
set text item delimiters to TID
set playSong to (resultString as string)
if userInput contains "Play" then tell application "iTunes"
set mySongs to every track of library playlist 1 whose name is playSong
repeat with aSong in mySongs
play aSong
end repeat
if (count of mySongs) = 0 then
display alert "Song not found"
end if
end tell

How print PDF with hyperLink

I try to print PDF with HyperLink, without succes
I have a lock field "etat" with data
Data are formatted like:
Code TAB Nom TAB Adress TAB Ville
56 Eric rue caboteur ST NAZAIRE
87 Franc rue Midin ST brevin
etc
the textStyle of item 3 "Adress" set to "Link and linktext set to ""http://maps.google.fr/maps?f=q&hl=fr&q=theadresse""
When i click on hyperlink item in field "etat" that work fine
Now i would like have the same result after printing this field in PDF
I use this code for printing
on mouseUp
local theResult,thepDF
ask file "" with type "PDF file|pdf|PDF "
if it = "" then
exit mouseUp
end if
put it into thePDF
put the htmltext of fld "etat" into theResult
--set the fileType to "revoPDF "
open printing to pdf thePDF
revPrintField the name of field "etat"
--revPrintText theResult,"<%pageNumber%> of <%numPages%>","<%pageNumber%> of <%numPages%>",the long id of field "etat" of stack "CDH"
close printing
end mouseUp
I have a nice PDF with clicked words, but the click don't launch google maps
The dictionary say for command "print link"
"When printing fields, any text that has its linkText property set together with the link textStyle is treated as if a print link command had been executed with the contents of the property as link, and the formattedRect of the text as rectangle."
But no work.... I have a big headache
Thank for yours help to achieve this
Eric
I am trying to understand your problem and reading through your code, I think maybe the link text…
"http://maps.google.fr/maps?f=q&hl=fr&q=theadresse"
should be…
"http://maps.google.fr/maps?f=q&hl=fr&q=" & theadresse
This is assuming theadresse is a variable containing a valid address to search in Google.

Resources