Hi, Great that you have sorted it out.
Some more thoughts:
For "loading" the the entire ini file you could also read it as a normal file, into a variable, remove the [KEYS] row and simply add Let> at the beginning of each row using RegEx>. Then by using IncludefromVar> all ini-variables will be updated.
Second, if you have a "nailed" dialog layout, you can, instead of putting it in the beginning of the script, put the dialog code in a label. Use LabeltoVar> to read it into a variable. Then you can easily pull out all panel names by using RegEx. Since all panel names are then in an ordered array you can loop through and create all Dialog Handlers etc.
Then you can use IncludefromVar> to insert the dialog script into the main script.
Maybe here is where it all breaks, Ideally you want to be able to link the panel names in the dialog with the names used in the ini file.
Sample (pls fold if you do not want details):
Code: Select all
// Read ini file (from label below instead of file)
GoSub>readIni
// Create the Dialog using label to variable
GoSub>createDialog
// Find all panels (into var Panel_k, tot count into nPanels)
GoSub>findPanels
// Create Dialog Handlers (for all found panels)
GoSub>createDialogHandlers
// Update Dialog Properties (based on ini file)
GoSub>updateDialogProperties
Show>Dialog1,
// SRT to read ini
SRT>readIni
LabelToVar>ini,ini
// Remove group row [KEYS]
Let>tmp0=(?m-s)^\[.+?\]\R
RegEx>tmp0,ini,0,m,nm,1,,ini
// Find all record for each panel
Let>tmp0=(?ms)(key\d+).+?\R(\1.+?(\R))+
RegEx>tmp0,ini,0,strRecord,nRecords,0,
// Convert the init file to Let>xxx statements that can be included as script
RegEx>(?m)^(.),ini,0,m,nm,1,Let>$1,ini
IncludeFromVar>ini
END>readIni
// Create Dialog
SRT>createDialog
LabelToVar>BaseDialog,BaseDialog
IncludeFromVar>BaseDialog
Let>WIN_USEHANDLE=1
MoveWindow>dialog1.handle,10,10
Let>WIN_USEHANDLE=0
END>createDialog
// Find all Panels
SRT>findPanels
RegEx>\w+(?=:\s+TPanel),BaseDialog,0,Panel,nPanels,0
END>findPanels
// Create Dialog Handlers
SRT>createDialogHandlers
Let>k=0
While>k<nPanels
Add>k,1
Let>tmp=Panel_%k%
AddDialogHandler>Dialog1,%tmp%,OnClick,DOKEY(%k%)
EndWhile
END>createDialogHandlers
// SRT to handle panel clicks
SRT>DOKEY
//index = ID of clicked panel
Let>index=DOKEY_Var_1
// Caption of clicked panel
Let>clickedCaption=key%index%txt
// All ini items for clicked panel
Let>strPanelRecord=strRecord_%index%
Let>MSG_HEIGHT=250
Let>MSG_WIDTH=300
MDL>%clickedCaption% was pressed%CRLF%%CRLF%%strPanelRecord%
END>DOKEY
// SRT to Update Dialog Properties
SRT>updateDialogProperties
Let>k=0
While>k<nPanels
Add>k,1
// Update color and caption from ini file.
// Panel_k contains name (id) of panel k
Let>tmp=Panel_%k%
// Color and caption from ini file
Let>tmpCol=key%k%col
Let>tmpCap=key%k%txt
SetDialogProperty>Dialog1,%tmp%,Color,tmpCol
SetDialogProperty>Dialog1,%tmp%,Caption,tmpCap
EndWhile
END>updateDialogProperties
// Base Dialog
/*
BaseDialog:
Dialog>Dialog1
object Dialog1: TForm
Top = 10
Left = 10
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 850
ClientWidth = 500
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 10
Top = 50
Width = 65
Height = 25
Caption = '1'
ParentBackground = False
TabOrder = 1
end
object Panel2: TPanel
Left = 85
Top = 50
Width = 65
Height = 25
Caption = '2'
ParentBackground = False
TabOrder = 2
end
object Panel3: TPanel
Left = 160
Top = 50
Width = 65
Height = 25
Caption = '3'
ParentBackground = False
TabOrder = 3
end
object Panel4: TPanel
Left = 235
Top = 50
Width = 65
Height = 25
Caption = '4'
ParentBackground = False
TabOrder = 4
end
object Panel5: TPanel
Left = 310
Top = 50
Width = 65
Height = 25
Caption = '5'
ParentBackground = False
TabOrder = 5
end
object Panel6: TPanel
Left = 10
Top = 80
Width = 65
Height = 25
Caption = '6'
ParentBackground = False
TabOrder = 6
end
object Panel7: TPanel
Left = 85
Top = 80
Width = 65
Height = 25
Caption = '7'
ParentBackground = False
TabOrder = 7
end
object Panel8: TPanel
Left = 160
Top = 80
Width = 65
Height = 25
Caption = '8'
ParentBackground = False
TabOrder = 8
end
object Panel9: TPanel
Left = 235
Top = 80
Width = 65
Height = 25
Caption = '9'
ParentBackground = False
TabOrder = 9
end
object Panel10: TPanel
Left = 310
Top = 80
Width = 65
Height = 25
Caption = '10'
ParentBackground = False
TabOrder = 10
end
end
EndDialog>Dialog1
*/
// Sample ini file
/*
ini:
[KEYS]
key1txt=Mix 1
key1mod=CTRL+ALT
key1key=114
key1col=15431178
key2txt=Mix 2
key2mod=CTRL+ALT
key2key=114
key2col=1516390
key3txt=Mix 3
key3mod=CTRL+ALT
key3key=114
key3col=4616657
key4txt=Mix 4
key4mod=CTRL+ALT
key4key=114
key4col=12879931
key5txt=Mix 5
key5mod=CTRL+ALT
key5key=114
key5col=4852408
key6txt=Mix 6
key6mod=CTRL+ALT
key6key=114
key6col=665170
key7txt=Mix 7
key7mod=CTRL+ALT
key7key=114
key7col=8198960
key8txt=Mix 8
key8mod=CTRL+ALT
key8key=114
key8col=927917
key9txt=Mix 9
key9mod=CTRL+ALT
key9key=114
key9col=16677175
key10txt=Mix 10
key10mod=CTRL+ALT
key10key=114
key10col=3651357
*/