Partial string searching in arrays, help please.

Post » Thu Oct 13, 2016 2:05 pm

Evening all,



I'm trying to search through a string array to search for various index records and/or names but want to


do this using a partial search.



I have a text box input show up and I want the player to be able to type in a name, then have that string


search through the array , which then would either, a) if only one index contains the string in which the user typed, display xx information.


if more than one index contains the string, then pop up a list and display the full string names.. at which point the user would click on whichever and something happens etc...



it's still a work in progress.. but you get the idea.. i just need to take the input from the user and have it search through.



the only thing i found on array searching is using find or rfind,, but that seems to want exact strings. I need a sort of wild card or an include type function.



Well, I eagerly await some replies and could use some help on this please.



Thanks,



T-Mush-S



P.S. It's for my mod which I'm in the process of updating. It works great as is, and uses the MCM for pretty much most of the functionality, but I wanted to extend it further by adding a search query to it. The indexes / arrays etc.. are done and I'm currently using SkyUILib for the textinput popup. That all works great, and the strings get read directly from the player inputs, but as it is, I can't figure a way to search through them unless the player knows exactly how to spell an NPC's name, or rather what the game believes the name is.

User avatar
renee Duhamel
 
Posts: 3371
Joined: Thu Dec 14, 2006 9:12 am

Post » Thu Oct 13, 2016 2:35 pm

As an potential alternative would it be possible to use a dummy container filled with tokens representing your strings? You mentioned you already have a SkyUI requirement so you could use SkyUI's inventory filter to search your "strings".

User avatar
Add Meeh
 
Posts: 3326
Joined: Sat Jan 06, 2007 8:09 am

Post » Fri Oct 14, 2016 12:17 am

That's a good idea. I can play around with that too. At most I would have is 81 objects/strings anyhow so the inventory walking shouldn't be that slow. I just like arrays because they're pretty much instant. Also, when using containers; does the index of the item change if adding or subtracting. My mod relies on all index to be static once placed. the index coincides with where they are in the quest's reference aliases as well as the objectives as well as several other arrays.



eg. index 1 in my reference alias would be say: Sofia


index 1 in my objective would contain sofia's name


index 1 in my NPCStatsArray would grab sofia's info as a string and store the fact that she's a child.



and this goes on...



so say i have 10 npc's and they're assigned 1 through 10, then i remove number 4.. well all array's and references in 4 will be set to none..


but all the others don't shift.. they're still assigned to their respected indexes.



etc. etc.. so all my array's match 1 for 1. if using a container.. i thought they shifted indexes depending on how many are in said container. I can check to see.



so if i were to search for "sof" and her container put her at 4 instead of 1, then my returns would be off and the info would show for whichever is in my index 4 arrays. I hope that makes sense.



of course i could be way off the mark here and if that's the case then all of my rambling here is moot. :D

User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Thu Oct 13, 2016 2:56 pm

FOUND IT!... after a lot of reading, and searching.. turns out SKSE has a find function for it's own.. which does include wild card searches




Find - StringUtil

http://www.creationkit.com/index.php?title=Find_-_StringUtil



there's the link if anyone else may need it.

User avatar
stevie trent
 
Posts: 3460
Joined: Thu Oct 11, 2007 3:33 pm


Return to V - Skyrim