Menu channel {
Test : Strings.Test
}
alias -l Strings.Test {
dialog -m strings strings
list
}
;# Refresh both lists with up-to-date values.
alias -l list {
var %file test.ini
;# Flush both sides so that they are empty.
did -r strings 100
did -r strings 200
;# Placeholder for future references, %sort will allow me to display the values with different under different category orders.
var %sort $iif($readini(test.ini,sort,preference),$v1,organization)
if (%sort == organization) {
;# Adds values to left combo list
var %i 1, %action offered, %lines $ini(%file,%action,0)
while (%i <= %lines) {
var %value $no^($ini(%file,%action,%i))
did -a strings 100 %value
inc %i
}
;# Adds values to right combo list
var %i 1, %action active, %lines $ini(%file,%action,0)
while (%i <= %lines) {
var %value $no^($ini(%file,%action,%i))
did -a strings 200 %value
inc %i
}
}
}
dialog strings {
title "Strings List"
size -1 -1 216 142
option dbu
box "Offered List", 1, 2 2 106 116
combo 100, 5 10 100 106, sort
box "Active List", 2, 108 2 106 116
;# The reason I'm using combo instead of list is cause one of my future wishes are to make the edit box above function as a search bar as well.
combo 200, 111 10 100 106, sort
box "Sort By", 3, 2 118 106 22
;# These buttons will write the preferred layout to display the values.
button "Organization", 4, 4 124 34 14
button "Personality", 5, 38 124 34 14
button "Value", 6, 72 124 34 14
button "Reset", 7, 108 120 106 20
}
on *:dialog:strings:sclick:7: {
var %file test.ini, %lines $ini(%file,active,0)
;## Use the MOVE alias for this in the future.
;# This resets the right combo list.
while (%lines) {
writeini %file offered $ini(%file,active,%lines) 1
remini %file active $ini(%file,active,%lines)
dec %lines
}
list
}
on *:dialog:strings:dclick:100,200: {
var %dialog $dname, %action $iif($did == 100,add,rem), %value $did($did).seltext
move %dialog %action %value
}
alias -l move {
var %dialog $1, %action $2, %value $^($3-), %file test.ini
;## Make prettier echo text.
echo 3 -ag $capital(%action) $+ $iif(%action == rem,oved $qt($3-) from,ed $qt($3-) to) the active list.
;# Deletes it from one side and adds it to the other
writeini %file $iif(%action == add,active,offered) %value 1
remini %file $iif(%action == rem,active,offered) %value
;# Calls for the refresh again which will update the values shown.
list
}
;# This is used to remove the ^ from the string.
alias no^ return $replace($1-,$chr(94),$chr(32))
;# This is used to add ^ to the string instead of spaces.
;# The reason I do this is so it can be used as an item in the ini files.
alias ^ return $replace($1-,$chr(32),$chr(94))
;# This let's me capitalize the first letter of the string.
alias capital return $upper($left($1,1)) $+ $mid($1,2-)