[Gambas-user] Weird, yet again. Two way access to a collection. (not really a gambas issue)
Charlie Ogier
charlie at cogier.com
Wed Nov 21 17:22:48 CET 2018
Hi Bruce,
Here is an idea. I let you decide if it's 'good'.
The code in the attached file is:-
/Public Sub Form_Open()//
//Dim sList As String[] = Split(File.Load("../codes"), gb.newline)//
//
//Print sList[4617]//
//Print Split(sList[1329], "`")[0]//
//Print sList.Find("*NO_CHOC*", gb.Like)//
//Print sList[sList.Find("*NO_CHOC*", gb.Like)]//
//
//End//
/
Produces: -
/A chocolate ice cream//
//Chocolate Ice Creams are out of stock today, offer another flavor//
//1329//
//Chocolate Ice Creams are out of stock today, offer another flavor`
NO_CHOC/
Charlie
On 21/11/2018 08:54, Bruce wrote:
> This has been bothering me for some years.
>
> It's fairly simple. We have a set of status codes that we use across
> many applications. They are numeric (integer) and have a code (the
> number), a mnemonic (short string) and an "explanation" (i.e. a user
> interpret-able string that describes the status "in full".
>
> Here, there and everywhere within an application we need to set the
> status code of something. Fairly plainly some method returns an
> integer value that reflects the current status. Bing bong. But, in
> order to do that we have to know from memory, when maintaining the
> code for that some method, that "if this happens, then return 617" or
> whatever. This is a pain.
>
> So, I'm trying to come up with some way that I could make a module in
> a library that would let us access the status codes EITHER by the code
> or by the mnemonic. I can neither get this clear in my mind
> conceptually nor implementation-wise.
>
> (EXAMPLE) Let's say we have an Ice Cream Parlor POS application that
> is loosely connected to the inventory "system". If a situation occurs
> where there is no chocolate ice cream in stock then, when the POS
> operator presses key 4617 (a chocolate ice cream) then it would
> display "Chocolate Ice Creams are out of stock today, offer another
> flavor". So, code 1329 = that explanation, but when I'm coding I'd
> like to specify the status as "NO_CHOC" rather than go search through
> a bunch of design documents and other stuff to find the right status
> code to use. I hope that makes sense, it's the simplest explanation I
> can think of. By the way, in reality we have around 1600 specific
> status codes in our systems. So I am really hoping that someone has a
> good idea here.
>
> tia
> Bruce
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181121/1132410b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GUITest.tar.gz
Type: application/gzip
Size: 13539 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181121/1132410b/attachment.gz>
More information about the User
mailing list