PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Windev Mobile 18- trouble using ArraySeek with array
Windev Mobile 18- trouble using ArraySeek with array
Débuté par Rob, 20 aoû. 2014 17:19 - 2 réponses
Posté le 20 août 2014 - 17:19
Hello everyone. This problem I'm running into should be pretty simple, so I'm not sure what I'm doing wrong.

I have an application I'm developing for a windows mobile device.
In it I have a globally defined array that gets filled from a web service. The program needs to validate user input into an entry field against that array to see if the value entered resides somewhere in that array.

Should be pretty easy right?
I was able to successfully do something very similar with a two-dimensional array without trouble, but for some reason this one-dimensional array refuses to cooperate.

Here my array is globally defined.
garrLocations is dynamic array
garrLocations = new array of string


Here my array gets filled by the web service.
And I can check this by looping through the array and using INFO() to display each value. And each value is there.
bufResult is Buffer
bufResult = InventoryAudit_GetLocations()
Deserialize(garrLocations,bufResult,psdXML)
ArraySort(garrLocations,asAscending)


And here is where it tries to validate the data entry against the array. I've tried several different search types, but they only ever return -1
nResSubscript is int
nResSubscript = ArraySeek(garrLocations,asLinearFirst,EDT_TagNumber)
Info(nResSubscript)


Any ideas would be greatly appreciated.
Posté le 20 août 2014 - 20:04
Hi Rob

it looks like you are fighting against the usual enemy : the TYPE of
string...

My analysis of the problem is this:
- you web service returns strings... ANSI strings
- you are looking for a value entered in an edit field under android: A
UNICODE string by default

at a binary level, you will never have a match.

It is very important when you work between environments to ALWAYS be
sure of the type of your data... Always declare your strings
SPECIFICALLY as ANSI or UNICODE, and never ASSUME...

And be careful, because the default on the android hardware is always
unicode, but in the GO mode, it may still be ansi, hence different
behaviors.

Best regards


--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com

On 8/20/2014 9:19 AM, Rob wrote:
Hello everyone. This problem I'm running into should be pretty simple,
so I'm not sure what I'm doing wrong.

I have an application I'm developing for a windows mobile device.
In it I have a globally defined array that gets filled from a web
service. The program needs to validate user input into an entry field
against that array to see if the value entered resides somewhere in that
array.

Should be pretty easy right?
I was able to successfully do something very similar with a
two-dimensional array without trouble, but for some reason this
one-dimensional array refuses to cooperate.

Here my array is globally defined.
garrLocations is dynamic array
garrLocations = new array of string


Here my array gets filled by the web service.
And I can check this by looping through the array and using INFO() to
display each value. And each value is there.
bufResult is Buffer
bufResult = InventoryAudit_GetLocations()
Deserialize(garrLocations,bufResult,psdXML)
ArraySort(garrLocations,asAscending)


And here is where it tries to validate the data entry against the array.
I've tried several different search types, but they only ever return -1
nResSubscript is int
nResSubscript = ArraySeek(garrLocations,asLinearFirst,EDT_TagNumber)
Info(nResSubscript)


Any ideas would be greatly appreciated.
Membre enregistré
105 messages
Posté le 22 août 2014 - 21:41
Thank you for the input Fabrice.

I actually learned that lesson a few months ago. Now I always specify variable types. Been there, got that T-shirt Haha!

My problem ended up being an issue with the data in the database I was pulling from, and the way it was imported into the database originally.

It was ending up inside my array with a ton of trailing spaces, even though those spaces didn't show in the XML from the web service, nor in the info() messages.