I have a question with respect to Dialogs.
The program I try to create contains a Dialog box, with which I can switch 24 relais.
At the moment, each relais has an on button and an off button to switch the relais on ON or OFF mode. This works fine.
I now want to implement a feature to combine the On and OFF button in one button with the label ON when the relais is switched on and the label OFF when it is switched off. To do this, I created a loop asking the state of each relais before the dialog is shown.
The loop works fine and the correct relais status is shown as label on the button when I start the program. However, it does not modify the label when I switch the relais.
So, I think that the loop for getting the actual status is only run when I start the program but not again when I press a button to switch a relais. So my basic question is where to put the loop in the program so that it is activated each after a button is pressed, then inquiring the status new and again bring the new stat as label On or PFF to the buttons. I hope may explanation is understandable.
I copied the entire program below including the loop which I have markes as loop for relais status.
I short tip would be fine. I tried all positions inthe script but I only get the correct label after the program is started and it does not change afterwards.
Thanks in advance.
Philipp
Code: Select all
Let>inifile=C:\BBBackup\Inifiles\power_source_relais_0001.ini
Let>MSG_XPOS=0
Let>MSG_YPOS=0
//HTTPRequest>http://%ip_1%/io.cgi?DOA1=0,,GET,,HTMLResponse
//Message>Relais status (1 = on): (%HTMLResponse%)
Dialog>NGSR1dlg
Width=300
Height=620
Top=250
Left=250
Max=0
Min=0
Resize=1
Top = 100
BorderIcons = [biSystemMenu]
Caption=%s_cap%
ClientHeight = 10
ClientWidth = 10
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 16
//First relais
Button=Close,20,10,230,30,99
Label=Relais %ip_1% %co_1%,20,50,80,50
Label=< %rel1% (Def: %op1%),120,75,30,40
Button=Rel_[1]_[8],20,70,40,20,11
Button=Rel_[1]_[8],70,70,40,20,10
Label=< %rel2% (Def: %op2%),120,105,30,40
Button=Rel_[1]_[9],20,100,40,20,21
Button=Rel_[1]_[9],70,100,40,20,20
Label=< %rel3% (Def: %op3%),120,135,30,40
Button=Rel_[1]_[10],20,130,40,20,31
Button=Rel_[1]_[10],70,130,40,20,30
Label=< %rel4% (Def: %op4%),120,165,30,40
Button=Rel_[1]_[11],20,160,40,20,41
Button=Rel_[1]_[11],70,160,40,20,40
// Until here I changes the label variable to the label arrey but it also did not work.
Label=< %rel5% (Def: %op5%),120,195,30,40
Button=ON,20,190,40,20,51
Button=OFF,70,190,40,20,50
Label=< %rel6% (Def: %op6%),120,225,30,40
Button=ON,20,220,40,20,61
Button=OFF,70,220,40,20,60
Label=< %rel7% (Def: %op7%),120,255,30,40
Button=ON,20,250,40,20,71
Button=OFF,70,250,40,20,70
Label=< %rel8% (Def: %op8%),120,285,30,40
Button=ON,20,280,40,20,81
Button=OFF,70,280,40,20,80
//Second relais
Label=Relais %ip_2% %co_2%,20,320,80,50
Label=< %rel9% (Def: %op9%),120,345,30,40
Button=ON,20,340,40,20,91
Button=OFF,70,340,40,20,90
Label=< %rel10% (Def: %op10%),120,375,30,40
Button=ON,20,370,40,20,101
Button=OFF,70,370,40,20,100
Label=<-%rel11% (Def: %op11%),120,405,30,40
Button=ON,20,400,40,20,111
Button=OFF,70,400,40,20,110
Label=< %rel12% (Def: %op12%),120,435,30,40
Button=ON,20,430,40,20,121
Button=OFF,70,430,40,20,120
Label=< %rel13% (Def: %op13%),120,465,30,40
Button=ON,20,460,40,20,131
Button=OFF,70,460,40,20,130
Label=< %rel14% (Def: %op6%),120,495,30,40
Button=ON,20,490,40,20,141
Button=OFF,70,490,40,20,140
Label=< %rel15% (Def: %op7%),120,525,30,40
Button=ON,20,520,40,20,151
Button=OFF,70,520,40,20,150
Label=< %rel16% (Def: %op8%),120,555,30,40
Button=ON,20,550,40,20,161
Button=OFF,70,550,40,20,160
//Third relais
Label=Relais %ip_3% %co_3%,20,590,80,50
Label=< %rel17% (Def: %op1%),120,615,30,40
Button=ON,20,610,40,20,171
Button=OFF,70,610,40,20,170
Label=< %rel18% (Def: %op2%),120,645,30,40
Button=ON,20,640,40,20,181
Button=OFF,70,640,40,20,180
Label=<-%rel19% (Def: %op3%),120,675,30,40
Button=ON,20,670,40,20,191
Button=OFF,70,670,40,20,190
Label=< %rel20% (Def: %op4%),120,705,30,40
Button=ON,20,700,40,20,201
Button=OFF,70,700,40,20,200
Label=< %rel21% (Def: %op5%),120,735,30,40
Button=ON,20,730,40,20,211
Button=OFF,70,730,40,20,210
Label=< %rel22% (Def: %op6%),120,765,30,40
Button=ON,20,760,40,20,221
Button=OFF,70,760,40,20,220
Label=< %rel23% (Def: %op7%),120,795,30,40
Button=ON,20,790,40,20,231
Button=OFF,70,790,40,20,230
Label=< %rel24% (Def: %op8%),120,825,30,40
Button=ON,20,820,40,20,241
Button=OFF,70,820,40,20,240
Button=Close,20,850,230,30,99
EndDialog>NGSR1dlg
Let>i=0
Repeat>i
Let>i=i+1
ReadIniFile>inifile,network,ip%i%,ip_tmp%i%
Let>ip_%i%=ip_tmp%i%
Length>ip_%i%,len_ip
if>%len_ip%<5
Message>Relaiscard %i% not installed.
Wait>1
else
Message>Relaiscard %i% installed.
Wait>1
ReadIniFile>inifile,network,co%i%,co_tmp%i%
Let>co_%i%=co_tmp%i%
endif
Until>i=3
Let>k=0
Repeat>k
Let>k=k+1
ReadIniFile>inifile,label,r%k%,rel_tmp%k%
Let>rel%k%=rel_tmp%k%
ReadIniFile>inifile,label,o%k%,op_tmp%k%
Let>op%k%=op_tmp%k%
Until>k,24
While>%ModalResult%<>99
Show>NGSR1dlg,ModalResult
if>%ModalResult%=11
HTTPRequest>http://%ip_1%/io.cgi?DOA1=0,,GET,,HTMLResponse
Message>Relais 1 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
if>%ModalResult%=10
HTTPRequest>http://%ip_1%/io.cgi?DOI1=0,,GET,,HTMLResponse
Message>Relais 1 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=21
HTTPRequest>http://%ip_1%/io.cgi?DOA2=0,,GET,,HTMLResponse
Message>Relais 2 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=20
HTTPRequest>http://%ip_1%/io.cgi?DOI2=0,,GET,,HTMLResponse
Message>Relais 2 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
if>%ModalResult%=31
HTTPRequest>http://%ip_1%/io.cgi?DOA3=0,,GET,,HTMLResponse
Message>Relais 3 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=30
HTTPRequest>http://%ip_1%/io.cgi?DOI3=0,,GET,,HTMLResponse
Message>Relais 3 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=41
HTTPRequest>http://%ip_1%/io.cgi?DOA4=0,,GET,,HTMLResponse
Message>Relais 4 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=40
HTTPRequest>http://%ip_1%/io.cgi?DOI4=0,,GET,,HTMLResponse
Message>Relais 4 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
if>%ModalResult%=51
HTTPRequest>http://%ip_1%/io.cgi?DOA5=0,,GET,,HTMLResponse
Message>Relais 5 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
if>%ModalResult%=50
HTTPRequest>http://%ip_1%/io.cgi?DOI5=0,,GET,,HTMLResponse
Message>Relais 5 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=61
HTTPRequest>http://%ip_1%/io.cgi?DOA6=0,,GET,,HTMLResponse
Message>Relais 6 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=60
HTTPRequest>http://%ip_1%/io.cgi?DOI6=0,,GET,,HTMLResponse
Message>Relais 6 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=71
HTTPRequest>http://%ip_1%/io.cgi?DOA7=0,,GET,,HTMLResponse
Message>Relais 7 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=70
HTTPRequest>http://%ip_1%/io.cgi?DOI7=0,,GET,,HTMLResponse
Message>Relais 7 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=81
HTTPRequest>http://%ip_1%/io.cgi?DOA8=0,,GET,,HTMLResponse
Message>Relais 8 (%ip_1%) - %co_1% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=80
HTTPRequest>http://%ip_1%/io.cgi?DOI8=0,,GET,,HTMLResponse
Message>Relais 8 (%ip_1%) - %co_1% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=91
HTTPRequest>http://%ip_2%/io.cgi?DOA1=0,,GET,,HTMLResponse
Message>Relais 1 (%ip_2%) - %co_2% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=90
HTTPRequest>http://%ip_2%/io.cgi?DOI1=0,,GET,,HTMLResponse
Message>Relais 1 (%ip_2%) - %co_2% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=101
HTTPRequest>http://%ip_2%/io.cgi?DOA2=0,,GET,,HTMLResponse
Message>Relais 2 (%ip_2%) - %co_2% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=100
HTTPRequest>http://%ip_2%/io.cgi?DOI2=0,,GET,,HTMLResponse
Message>Relais 2 (%ip_2%) - %co_2% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=111
HTTPRequest>http://%ip_2%/io.cgi?DOA3=0,,GET,,HTMLResponse
Message>Relais 3 (%ip_3%) - %co_2% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=110
HTTPRequest>http://%ip_2%/io.cgi?DOI3=0,,GET,,HTMLResponse
Message>Relais 3 (%ip_3%) - %co_2% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=121
HTTPRequest>http://%ip_2%/io.cgi?DOA4=0,,GET,,HTMLResponse
Message>Relais 4 (%ip_2%) - %co_3% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=120
HTTPRequest>http://%ip_2%/io.cgi?DOI4=0,,GET,,HTMLResponse
Message>Relais 4(%ip_2%) - %co_3% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=131
HTTPRequest>http://%ip_2%/io.cgi?DOA5=0,,GET,,HTMLResponse
Message>Relais 5 (%ip_2%) - %co_4% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=130
HTTPRequest>http://%ip_2%/io.cgi?DOI5=0,,GET,,HTMLResponse
Message>Relais 5 (%ip_2%) - %co_4% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=141
HTTPRequest>http://%ip_2%/io.cgi?DOA6=0,,GET,,HTMLResponse
Message>Relais 6 (%ip_2%) - %co_5% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=140
HTTPRequest>http://%ip_2%/io.cgi?DOI6=0,,GET,,HTMLResponse
Message>Relais 6 (%ip_2%) - %co_5% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=151
HTTPRequest>http://%ip_2%/io.cgi?DOA7=0,,GET,,HTMLResponse
Message>Relais 7 (%ip_2%) - %co_6% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=150
HTTPRequest>http://%ip_2%/io.cgi?DOI7=0,,GET,,HTMLResponse
Message>Relais 7 (%ip_2%) - %co_6% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=161
HTTPRequest>http://%ip_2%/io.cgi?DOA8=0,,GET,,HTMLResponse
Message>Relais 8 (%ip_2%) - %co_7% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=160
HTTPRequest>http://%ip_2%/io.cgi?DOI8=0,,GET,,HTMLResponse
Message>Relais 8 (%ip_2%) - %co_7% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=171
HTTPRequest>http://%ip_3%/io.cgi?DOA1=0,,GET,,HTMLResponse
Message>Relais 1 (%ip_3%) - %co_8% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=170
HTTPRequest>http://%ip_3%/io.cgi?DOI1=0,,GET,,HTMLResponse
Message>Relais 1 (%ip_3%) - %co_8% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=181
HTTPRequest>http://%ip_3%/io.cgi?DOA2=0,,GET,,HTMLResponse
Message>Relais 2 (%ip_3%) - %co_18% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=180
HTTPRequest>http://%ip_3%/io.cgi?DOI2=0,,GET,,HTMLResponse
Message>Relais 2 (%ip_3%) - %co_18% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=191
HTTPRequest>http://%ip_3%/io.cgi?DOA3=0,,GET,,HTMLResponse
Message>Relais 3 (%ip_3%) - %co_19% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=190
HTTPRequest>http://%ip_3%/io.cgi?DOI3=0,,GET,,HTMLResponse
Message>Relais 3 (%ip_3%) - %co_19% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=201
HTTPRequest>http://%ip_3%/io.cgi?DOA4=0,,GET,,HTMLResponse
Message>Relais 4 (%ip_3%) - %co_20% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=200
HTTPRequest>http://%ip_3%/io.cgi?DOI4=0,,GET,,HTMLResponse
Message>Relais 4 (%ip_3%) - %co_20% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=211
HTTPRequest>http://%ip_3%/io.cgi?DOA5=0,,GET,,HTMLResponse
Message>Relais 5 (%ip_3%) - %co_21% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=210
HTTPRequest>http://%ip_3%/io.cgi?DOI5=0,,GET,,HTMLResponse
Message>Relais 5 (%ip_3%) - %co_21% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=221
HTTPRequest>http://%ip_3%/io.cgi?DOA6=0,,GET,,HTMLResponse
Message>Relais 6 (%ip_3%) - %co_22% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=220
HTTPRequest>http://%ip_3%/io.cgi?DOI6=0,,GET,,HTMLResponse
Message>Relais 6 (%ip_3%) - %co_22% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=231
HTTPRequest>http://%ip_3%/io.cgi?DOA7=0,,GET,,HTMLResponse
Message>Relais 7 (%ip_3%) - %co_23% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=230
HTTPRequest>http://%ip_3%/io.cgi?DOI7=0,,GET,,HTMLResponse
Message>Relais 7 (%ip_3%) - %co_23% switched off. (%HTMLResponse%)
Else
If>%ModalResult%=241
HTTPRequest>http://%ip_3%/io.cgi?DOA8=0,,GET,,HTMLResponse
Message>Relais 8 (%ip_3%) - %co_24% switched on. (%HTMLResponse%)
Else
If>%ModalResult%=240
HTTPRequest>http://%ip_3%/io.cgi?DOI87=0,,GET,,HTMLResponse
Message>Relais 8 (%ip_3%) - %co_24% switched off. (%HTMLResponse%)
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
let>j=0
Repeat>j
Let>j=j+1
Let>act_request=http://%ip_i%/io.cgi?
HTTPRequest>http://%ip_1%/io.cgi?,,GET,,HTMLResponse
let>m=7
Repeat>m
Let>m=m+1
MidStr>%HTMLResponse%,%m%,1,stat_%j%_%m%
IF>stat_%j%_%m%=1
Let>rel_[%j%]_[%m%]=ON
Else
Let>rel_[%j%]_[%m%]=OFF
Endif
Message>rel_[%j%]_[%m%]
Wait>0.2
Until>m,15
Until>j,3
Wait>1
CloseDialog>NGSR1dlg
EndWhile