Jump to content

HELP - Array from List excluding "blanks"?


gnosis3d
 Share

Recommended Posts

Not sure what to search for, so I am having to ask first...

In my utility, I have a list of CLIENTS. This list has been hard-coded, but I want to make it read from an external INI file.

The problem I am running into is I need to create a drop-down box listing these CLIENTS. I want to have space for, say... 19 clients. However, if I only have 10 clients, I need to last 9 to be "removed" from the drop-down list.

Here are some pieces of the code to see what I am going for.

GUICtrlCreateLabel("Client / Customer",10,75)
$client = GUICtrlCreateCombo ("Client1",10,90,90)
GUICtrlSetData($client,"Client1|Client2|Client3","Client1")

$clientDIR1= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR1", "NotFound")
$clientDIR2= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR2", "NotFound")
$clientDIR3= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR3", "NotFound")
$clientDIR4= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR4", "NotFound")
$clientDIR5= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR5", "NotFound")
$clientDIR6= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR6", "NotFound")
$clientDIR7= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR7", "NotFound")
$clientDIR8= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR8", "NotFound")
$clientDIR9= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR9", "NotFound")
$clientDIR10= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR10", "NotFound")
$clientDIR11= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR11", "NotFound")
$clientDIR12= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR12", "NotFound")
$clientDIR13= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR13", "NotFound")
$clientDIR14= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR14", "NotFound")
$clientDIR15= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR15", "NotFound")
$clientDIR16= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR16", "NotFound")
$clientDIR17= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR17", "NotFound")
$clientDIR18= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR18", "NotFound")
$clientDIR19= IniRead(@ProgramFilesDir & "\RemoteJuggler\remotejuggler.ini", "location", "clientDIR19", "NotFound")

If NOT $clientDIR1 = "none" Then
    $clientDIR1name = (StringTrimRight($clientDIR1,1) AND StringTrimLeft($clientDIR1,1))
EndIf
If NOT $clientDIR2 = "none" Then
$clientDIR2name = (StringTrimRight($clientDIR2,1) AND StringTrimLeft($clientDIR2,1))
EndIf
If NOT $clientDIR3 = "none" Then
$clientDIR3name = (StringTrimRight($clientDIR3,1) AND StringTrimLeft($clientDIR3,1))
EndIf
If NOT $clientDIR4 = "none" Then
$clientDIR4name = (StringTrimRight($clientDIR4,1) AND StringTrimLeft($clientDIR4,1))
EndIf
If NOT $clientDIR5 = "none" Then
$clientDIR5name = (StringTrimRight($clientDIR5,1) AND StringTrimLeft($clientDIR5,1))
EndIf
If NOT $clientDIR6 = "none" Then
$clientDIR6name = (StringTrimRight($clientDIR6,1) AND StringTrimLeft($clientDIR6,1))
EndIf
If NOT $clientDIR7 = "none" Then
$clientDIR7name = (StringTrimRight($clientDIR7,1) AND StringTrimLeft($clientDIR7,1))
EndIf
If NOT $clientDIR8 = "none" Then
$clientDIR8name = (StringTrimRight($clientDIR8,1) AND StringTrimLeft($clientDIR8,1))
EndIf
If NOT $clientDIR9 = "none" Then
$clientDIR9name = (StringTrimRight($clientDIR9,1) AND StringTrimLeft($clientDIR9,1))
EndIf
If NOT $clientDIR10 = "none" Then
$clientDIR10name = (StringTrimRight($clientDIR10,1) AND StringTrimLeft($clientDIR10,1))
EndIf
If NOT $clientDIR11 = "none" Then
$clientDIR11name = (StringTrimRight($clientDIR11,1) AND StringTrimLeft($clientDIR11,1))
EndIf
If NOT $clientDIR12 = "none" Then
$clientDIR12name = (StringTrimRight($clientDIR12,1) AND StringTrimLeft($clientDIR12,1))
EndIf
If NOT $clientDIR13 = "none" Then
$clientDIR13name = (StringTrimRight($clientDIR13,1) AND StringTrimLeft($clientDIR13,1))
EndIf
If NOT $clientDIR14 = "none" Then
$clientDIR14name = (StringTrimRight($clientDIR14,1) AND StringTrimLeft($clientDIR14,1))
EndIf
If NOT $clientDIR15 = "none" Then
$clientDIR15name = (StringTrimRight($clientDIR15,1) AND StringTrimLeft($clientDIR15,1))
EndIf
If NOT $clientDIR16 = "none" Then
$clientDIR16name = (StringTrimRight($clientDIR16,1) AND StringTrimLeft($clientDIR16,1))
EndIf
If NOT $clientDIR17 = "none" Then
$clientDIR17name = (StringTrimRight($clientDIR17,1) AND StringTrimLeft($clientDIR17,1))
EndIf
If NOT $clientDIR18 = "none" Then
$clientDIR18name = (StringTrimRight($clientDIR18,1) AND StringTrimLeft($clientDIR18,1))
EndIf
If NOT $clientDIR19 = "none" Then
$clientDIR19name = (StringTrimRight($clientDIR19,1) AND StringTrimLeft($clientDIR19,1))
EndIf

INI File Sample:

[location]
clientDIR1="/client1/"
clientDIR2="/client1/"
clientDIR3="/client1/"
clientDIR4="/client4/"
clientDIR5="/client5/"
clientDIR6="/client6/"
clientDIR7="/client7/"
clientDIR8="/client8/"
clientDIR9="/client9/"
clientDIR10="/client10/"
clientDIR11="none"
clientDIR12="none"
clientDIR13="none"
clientDIR14="none"
clientDIR15="none"
clientDIR16="none"
clientDIR17="none"
clientDIR18="none"
clientDIR19="none"
Link to comment
Share on other sites

Here is a quick way using a couple arrays to parse out the data that you don't want. To put these names into a GUI just use _arraytostring to parse the array. This list is also not limited to the number of customers you could have. :)

CODE
#include<array.au3>

$clients =IniReadSection(@ProgramFilesDir&'\Clients.ini','Location')

_ArrayDisplay($clients)

dim $avarray[1]

for $idd = 1 to UBound($clients)-1

if $clients[$idd][1] <> '"None"' Then _ArrayAdd($avarray,StringRegExpReplace($clients[$idd][1],('"'),''))

Next

_ArrayDisplay($avarray)

Kerros

Edit: changed @scriptdir in my script to @programdir to match original script

Edited by Kerros

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Link to comment
Share on other sites

Here is a quick way using a couple arrays to parse out the data that you don't want. To put these names into a GUI just use _arraytostring to parse the array. This list is also not limited to the number of customers you could have. :)

CODE
#include<array.au3>

$clients =IniReadSection(@ProgramFilesDir&'\Clients.ini','Location')

_ArrayDisplay($clients)

dim $avarray[1]

for $idd = 1 to UBound($clients)-1

if $clients[$idd][1] <> '"None"' Then _ArrayAdd($avarray,StringRegExpReplace($clients[$idd][1],('"'),''))

Next

_ArrayDisplay($avarray)

Kerros

Edit: changed @scriptdir in my script to @programdir to match original script

Beat me to it - Here's my quick and dirty:

CODE
#include <GuiConstants.au3>

$clientGUI = GUICreate("Clients")

$comboClients = GUICtrlCreateCombo("",10,10,75,20)

$aClientLocations = IniReadSection(@ScriptDir & "\remotejuggler.ini", "location")

For $i = 1 To $aClientLocations[0][0]

$aClientLocations[$i][1] = _StringStripQuotes($aClientLocations[$i][1])

Next

$clients = ""

For $i = 1 To $aClientLocations[0][0]

If $aClientLocations[$i][1] <> "none" Then

$clients &= $aClientLocations[$i][1] &"|"

EndIf

Next

If StringRight($clients,1) = "|" Then $clients = StringTrimRight($clients,1)

GUICtrlSetData($comboClients,$clients)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

EndSelect

Wend

Func _StringStripQuotes($var)

Do

If StringRight($var, 1) = Chr(34) Then

$var = StringTrimRight($var, 1)

EndIf

Until StringRight($var, 1) <> Chr(34)

Do

If StringLeft($var, 1) = Chr(34) Then

$var = StringTrimLeft($var, 1)

EndIf

Until StringLeft($var, 1) <> Chr(34)

Return $var

EndFunc

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...