Connexion rapide:  

Forum: General Discussion

Sujet Why my param_contains is not working?

Ce topic est ancien et peut contenir des informations obselètes ou incorrectes.

Hi,
Im trying to check if a content of field user1 exists in user2:
deck 2 get_loaded_song "user2" & param_compare `deck 1 get_loaded_song 'user1'` ? deck 1 loaded_song "comment" "match":deck 1 loaded_song "comment" "nomatch"

But im always getting "nomatch" as answer.
If im doing this:
deck 2 get_loaded_song "user2" & param_compare "example" ? deck 1 loaded_song "comment" "match":deck 1 loaded_song "comment" "nomatch"

Then it will compare correctly.
Why will `deck 1 get_loaded_song 'user1'` not be translated correctly?
Thank you
 

Posté Sat 15 Aug 20 @ 3:07 am
locoDogPRO InfinityModeratorMember since 2013
param_compare isn't a script

try param_equal `first thing` `second thing`
or you could use param_contains
 

Posté Sat 15 Aug 20 @ 3:15 am
ouch *facepalm*

it was a very long night yesterday to try with this. Its just a typo, yes, ive tried it with:
deck 2 get_loaded_song "user2" & param_contains `deck 1 get_loaded_song 'user1'` ? deck 1 loaded_song "comment" "match":deck 1 loaded_song "comment" "nomatch"
or
deck 2 get_loaded_song "user2" & param_contains "`deck 1 get_loaded_song 'user1'`" ? deck 1 loaded_song "comment" "match":deck 1 loaded_song "comment" "nomatch"
but no luck.
 

Posté Sat 15 Aug 20 @ 7:49 am
LIMOLPRO InfinityMember since 2003
commas may be misplaced and too many commas
 

Posté Sat 15 Aug 20 @ 8:57 am
What would be the correct comma use?
 

Posté Sat 15 Aug 20 @ 9:40 am
locoDogPRO InfinityModeratorMember since 2013
I think param_contains only works in this fashion;
get_script contains "string",

and won't work as;
get_script contains get_script
 

Posté Sat 15 Aug 20 @ 10:10 am
OK, thank you. This doesnt hurt, then i will write it as a plugin.
 

Posté Sat 15 Aug 20 @ 10:51 pm
NicotuxHome userMember since 2014
right , this is one the param_* verbs that do not allow script as a parameter
usage:
param_contains <needle> [<haystack>]
both being strings, haystack may sometimes be a text parameter

There may be a bug here however

param_equal does not seem to work correctly with text parameters (maybe parameter fault, as debug needs an extra cast):
var_list & set myvar1 `get_loaded_song artist & param_cast text 5` & get_var myvar1 & param_cast text & debug "myvar1=" & debug & get_loaded_song artist & param_cast text 5 & param_cast text & debug "param=" & debug & param_equal `get_var myvar1 & param_cast text` ? set mystr `get_text 'match'` & debug "test OK": set mystr `get_text 'nomatch'` & debug "test fail"
==> test fails

but correctly with script parameters:
var_list & set myvar1 `get_loaded_song artist & param_cast text 5` & get_var myvar1 & param_cast text & debug "myvar1=" & debug & param_equal `get_var myvar1 & param_cast text` `get_loaded_song artist & param_cast text 5` ? set mystr `get_text 'match'` & debug "test OK" : set mystr `get_text 'nomatch'` & debug "test fail"
==> test OK

using param_contains does not work here it's not a bug, it's just missing feature:
var_list & set myvar1 `get_loaded_song artist & param_cast text 5` & get_var myvar1 & param_cast text & debug "myvar1=" & debug & param_contains `get_var myvar1 & param_cast text` `get_loaded_song artist & param_cast text 5` ? set mystr `get_text 'match'` & debug "test OK" : set mystr `get_text 'nomatch'` & debug "test fail"

@VDJ Monty:
fine :) but take very care about unicode encoded VDJstring passed as a C strings in SDK8. Simple compare may not be a problem, but truncate or even length are
(i.e., the param_cast text 5 is broken with international and decorations, cutting string as ASCII string in middle of utf8 char or missing some due to multi byte one)
relatively easy to workaround in a plugin, even without any external lib
(already done in a custom (not uploaded) plugin for strings handling)
 

Posté Sat 15 Aug 20 @ 11:20 pm
Thank you, Nicotux, for the UTF8 information. For me, my content is numeric only, so, i will not need to take care about it.

Yes, it looks like I also need to generate a general string handling plugin, because i have 3 different plugins already to handle different strings on different places. :c)
 

Posté Sat 15 Aug 20 @ 11:43 pm


(Les anciens sujets et forums sont automatiquement fermés)