Quick Sign In:  

Forum: VirtualDJ Technical Support

Topic: How to reset search options with script?

This topic is old and might contain outdated or incorrect information.

Grok32Home userMember since 2019
I am trying to make a button to search for the album of the playing song.
This works up to a point.


search_options "title" off &
search_options "filepath" off &
search_options "filename" off &
search_options "comment" off &
search_options "album" on &
search_options "author" off &
Search `get_loaded_song 'album'` &
browser_sort '+album'


But... when I try to set the search options back to where they were, it no longer searches only the album field.


search_options "title" off &
search_options "filepath" off &
search_options "filename" off &
search_options "comment" off &
search_options "album" on &
search_options "author" off &
Search `get_loaded_song 'album'` &
browser_sort '+album' &
search_options "filepath" on &
search_options "filename" on &
search_options "comment" on &
search_options "album" on &
search_options "author" on


According to djdad (from an older post), scripts aren't executed in order (which makes my head hurt). I guess this explains why it doesn't work but is there another way to have the script reset the search options?
 

Posted Wed 11 Dec 19 @ 6:43 pm
locoDogPRO InfinityModeratorMember since 2013
try this for searching


setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '+album'
let me try figure out your searchfields number for the other

Try that
setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '+album' & repeat_start 'BrowserIsntInstant' 100ms 1 & setting 'searchFields' 63

 

Posted Wed 11 Dec 19 @ 6:53 pm
locoDogPRO InfinityModeratorMember since 2013
The deal is the browser search isn't instant, it's quick but needs a few ms to do it.
Script is more or less instant, so I added a repeat_start to add 100ms delay before resetting the fields

Also I used setting "searchField" X
each field has a value 2^n, so so for the zeroth and first choices the X value would be 3 [Title & Artist] [2^0 + 2^1]
Album is 6th in the list [but number 5 in computer geeky start counting from zero maths stuff] so 2^5 == 32
 

Posted Wed 11 Dec 19 @ 7:27 pm
Grok32Home userMember since 2019
Thanks that is an easier way to set the search options but the result is the same. It works once, but if you highlight another song it reverts back to option 63. Even on subsequent searches. It seems highlighting another song should have no effect on the script but it does. I tried increasing the delay to 5000ms... same result. I even tried scrolling 5 times with the rs, which works fine after the delay but the search options seem to ignore the delay.
 

Posted Wed 11 Dec 19 @ 7:29 pm
Grok32Home userMember since 2019
There seems to be a race going on. The number of results varies from time to time with some searches including results from fields other than 'album' but not always the same amount of songs. Weird.
 

Posted Wed 11 Dec 19 @ 7:51 pm
locoDogPRO InfinityModeratorMember since 2013
try this
setting 'searchFields' 32 & repeat_start_instant 'BrowserIsntInstant' 200ms 2 & toggle '$flipflop' & var '$flipflop' 1 ? search `get_loaded_song 'album'` & browser_sort '+album' : setting 'searchFields' 63
 

Posted Wed 11 Dec 19 @ 7:58 pm
locoDogPRO InfinityModeratorMember since 2013
I suppose database size comes into play. see what gives full results & add more ms
 

Posted Wed 11 Dec 19 @ 8:00 pm
Grok32Home userMember since 2019
Thanks! That appears to work. My DB is not that large, about 35000 songs.
 

Posted Wed 11 Dec 19 @ 10:34 pm
Grok32Home userMember since 2019
Did some more testing. Seems the rs was not needed. The toggle alone did the trick. I can't understand why but I won't argue with success!


setting 'searchFields' 32 & toggle '$flipflop' & search `get_loaded_song 'album'` & browser_sort '+album' & setting 'searchFields' 63

Nope. I take that back, It was not always right but your script has worked reliably so far.
 

Posted Wed 11 Dec 19 @ 10:52 pm
Grok32Home userMember since 2019
One more question. Is it possible to sort on two fields such as browser_sort 'album, track' ? If so what is the syntax?
 

Posted Wed 11 Dec 19 @ 11:42 pm
locoDogPRO InfinityModeratorMember since 2013
same as sorting one field, the last one you call becomes the primary order, the one called before the last one becomes the secondary so I guess you want

browser_sort 'track' & browser_sort 'album'

 

Posted Thu 12 Dec 19 @ 4:43 am
locoDogPRO InfinityModeratorMember since 2013
See if this works consistently

set '$flipflop' 0 & setting 'searchFields' 32 & repeat_start_instant 'BrowserIsntInstant' 100ms 6 & cycle '$flipflop' 6 & var '$flipflop' 0 ? setting 'searchFields' 63 : var '$flipflop' 3 ? search `get_loaded_song 'album'` & browser_sort '+album' : nothing
 

Posted Thu 12 Dec 19 @ 8:42 am
Grok32Home userMember since 2019
It does search correctly but it hangs up occasionally for some reason. I did find another way that works and could possibly help in other situations where sequencing is a problem.

down ? setting 'searchFields' 32 & search `get_loaded_song 'album'` & browser_sort '-track' : setting 'searchFields' 63

Thanks for the tip on sorting! I have been working on that for weeks and it never occurred to me to use two commands. I was trying to pack it into one.

 

Posted Thu 12 Dec 19 @ 6:21 pm


(Old topics and forums are automatically closed)