Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Query() question
Page 1 of 1

PostPosted: Sat Feb 26, 2005 6:05 am
by Mikael
This one has me totally stumped.

When I run the following test app:

pointer Rad;
string userAns;
int i;

Rad=Array("s,1");
Rad[0] = "One";

clear();
userAns=gets("Enter word to find..");
i=Query(1,1,0,1,Rad, &userAns,0);
if(i==-1){
alert("No results found!");
}else{
alert(i);
alert("Position of first "+userAns+"="+i+"\n");
}}

it works fine - even with a longer array. However, when I try something similiar in my main app such as:

expectedAns=CheckDisCharsAns(resultFromDb);//get string to check against from function which accesses db field
QueryStore[0]=expectedAns;//an array with 1 element
alert("QueryStore="+QueryStore[0]);
textInField=FgetText(Input);//get string to match
alert("textinField="+textInField);
queryResult=Query(1,1,0,1,QueryStore, &textInField,0);
alert("queryResult="+queryResult);

the integer queryResult is always returned as -1, regardless of whether the user answer in the field matches that found in the db field or not. The thing I find strange is that this happens even though I have the Array and Query functions set up the same way. What am I doing wrong?

Thanks in advance,

Mikael

PostPosted: Sat Feb 26, 2005 7:09 am
by Mikael
I've found the problem. As I suspected, it was caused by the extra whitespace found after the entry in the db field which I removed with Strip(&tmp," ",0x0011). The trouble is that I have alot of fields which contain more than one one-word-strings such as in:

columun 55
11 One Two Three Four Five

so I'll have to see whether I can use Strip(&tmp," ",0x0011) in the same manner and still get the desired results.

Mikael

PostPosted: Sat Feb 26, 2005 7:26 am
by Mikael
No luck!

I think I'd better take another look at the Sort() and Query() functions. Ideally I'd like to to be able to configure Query to be able to find either:'One', 'Two', 'Three', 'Four' or 'Five' in
a one element array, which has been filled with the results of:

columun 55
11 One Two Three Four Five

Back to the drawing board.

Mikael

PostPosted: Sat Feb 26, 2005 9:50 am
by Mikael
Woah!
Sort()'s 'mode' and 'offset' features have me stumped - even a simple sort had no effect; so I opted for a clumsy workaround using substr() and Strip() to prepare the various field entries - of which there are never more than six anyway - before they are passed off to array elements for querying with Query().

Mikael

PostPosted: Sat Feb 26, 2005 9:21 pm
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I think I'd better take another look at the Sort() and Query() functions. Ideally I'd like to to be able to configure Query to be able to find either:'One', 'Two', 'Three', 'Four' or 'Five' in
a one element array, which has been filled with the results of:

columun 55
11 One Two Three Four Five
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Given a variable, Query() looks for only one matching element in an array. I think you need to "invert" you mindset. You want to look for one string in a 5 deep array.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
queryResult=Query(1,1,0,1,QueryStore, &textInField,0);
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

So QueryStore should an array of strings containing "One", "Two", "Three", "Four", & "Five".

You then want to use:
queryResult=Query(1,1,0,5,QueryStore, &textInField,0); //since there are 5 elements in the array

This will tell you if textInField matched an of the strings in QueryStore.

-Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Sun Feb 27, 2005 5:43 am
by Mikael
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"> I think I'd better take another look at the Sort() and Query() functions. Ideally I'd like to to be able to configure Query to be able to find either:'One', 'Two', 'Three', 'Four' or 'Five' in
a one element array, which has been filled with the results of:

columun 55
11 One Two Three Four Five

Given a variable, Query() looks for only one matching element in an array. I think you need to "invert" you mindset. You want to look for one string in a 5 deep array.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Initially I wasn't sure whether or not Query() could be configured to search for individual strings within an element containing more than one.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">So QueryStore should an array of strings containing "One", "Two", "Three", "Four", & "Five".<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

This is what I worked out and implemented, my problem initially being how to separate the different entries in the field, because, as far as I'm aware, using DBgetrec() would simply pass:
'One Two Three Four Five' to a one element array, or:

One Two Three Four Five
One Two Three Four Five
One Two Three Four Five
One Two Three Four Five
One Two Three Four Five
One Two Three Four Five

to an array with six elements, instead of:

One
Two
Three
Four
Five

which is what I wanted. I did this using substr() and Strip() because all of my entries are placed at intervals of 7 characters. Strip simply got rid of possible excess whitespace. Following this, queryResult=Query(1,1,0,6,QueryStore, &textInField,0); worked like a dream.

I hope I understood you correctly,

Mikael

PostPosted: Mon Feb 28, 2005 3:09 am
by jstadolnik
Check out the Split() function...

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Mon Feb 28, 2005 12:38 pm
by Mikael
Thanks again Joe,
I should have seen it considering it is directly above Strip(). Another '...wood for the trees' type thing I guess.

Mikael:?