Question on Dialogs

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
pfischer
Junior Coder
Posts: 21
Joined: Wed Jul 23, 2014 2:07 pm

Question on Dialogs

Post by pfischer » Thu Sep 01, 2022 1:11 pm

Dear all,
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



User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Question on Dialogs

Post by Dorian (MJT support) » Thu Sep 01, 2022 2:19 pm

I think this may have been created with a very old (and now unsupported) version of Macro Scheduler.

..and tbh I'm not entirely sure I am understanding correctly, but I am hoping the example below will help you with the principles of GetDialogProperty and SetDialogProperty (both introduced in v12) which you can apply to your scenario. A simple text field and button, toggling ON/OFF when the button is clicked.

Created in v15.0.20.

Code: Select all

Dialog>Dialog_Main
object Dialog_Main: TForm
  Left = 1073
  Top = 214
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Edit1: TEdit
    Left = 149
    Top = 43
    Width = 242
    Height = 40
    TabOrder = 0
    Text = 'ON'
  end
  object MSButton1: tMSButton
    Left = 453
    Top = 43
    Width = 150
    Height = 50
    Caption = 'ON'
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog_Main

Show>Dialog_Main
AddDialogHandler>Dialog_Main,MSButton1,OnClick,GetButton1

label>loop
wait>0.1
goto>loop

SRT>GetButton1
  GetDialogProperty>Dialog_Main,Edit1,Text,TheText
  If>TheText=ON
  SetDialogProperty>Dialog_Main,Edit1,Text,OFF
  SetDialogProperty>Dialog_Main,MSButton1,Caption,OFF
  Endif
  If>TheText=OFF
  SetDialogProperty>Dialog_Main,Edit1,Text,ON
  SetDialogProperty>Dialog_Main,MSButton1,Caption,ON
  Endif
END>GetButton1

Yes, we have a Custom Scripting Service. Message me or go here

pfischer
Junior Coder
Posts: 21
Joined: Wed Jul 23, 2014 2:07 pm

Re: Question on Dialogs

Post by pfischer » Fri Sep 02, 2022 5:18 pm

Deatr Dorian,
thanks for the reply and the instructions for a modal button. It is not exactly what I need but it helps me to try out if I adapt this script to my needs.
By the way. I use Version 14.# but found this kind of scripting in a forum to create modular buttons. Maybe this post was quite old but it worked for me except for this modal button label thing.
Thanks again for the fast reply and I will try it.
Best
Philipp

pfischer
Junior Coder
Posts: 21
Joined: Wed Jul 23, 2014 2:07 pm

Re: Question on Dialogs

Post by pfischer » Fri Sep 02, 2022 5:48 pm

Dear Dorian,
I tried your script and it works well except for on issue. I made a small adaption in the code so that it shows a still appearing problem. In the adapted script i have included a HTML response which I get from an sensor. This response includes an 8 digit (10000000) string where each digit codes if one of 8 relais is on (1) or off (0).
I included a simulation code line in which the first relais is switched on and all others off.
The script works well except for the start. When I start the script, I would like to have already the real HTML response value already as label. However, when I include the variable %tmp% in the dialog (which basically coded the status of the 1 relais), the code does not work.
So, my question now is how to convince the script to show the real relais status already when the script starts and not only after pressing the button the first time.
Thanks again
Philipp

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

Dialog>Dialog_Main
object Dialog_Main: TForm
  Left = 1073
  Top = 214
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Edit1: TEdit
    Left = 149
    Top = 43
    Width = 242
    Height = 40
    TabOrder = 0
    Text = '??'
  end
  object MSButton1: tMSButton
    Left = 453
    Top = 43
    Width = 150
    Height = 50
    Caption = '??'
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog_Main



//Original code
//HTTPRequest>http://172.30.2.20/io.cgi?,,GET,,HTMLResponse
//MessageModal>%HTMLResponse%

//Simulation code: 
Let>HTMLResponse=relais 10000000

MidStr>%HTMLResponse%,8,1,tmp

Show>Dialog_Main
AddDialogHandler>Dialog_Main,MSButton1,OnClick,GetButton1

label>loop
wait>0.1
goto>loop

SRT>GetButton1
//GetDialogProperty>Dialog_Main,Edit1,Text,TheText 
  If>%tmp%=0
  SetDialogProperty>Dialog_Main,Edit1,Text,OFF
  SetDialogProperty>Dialog_Main,MSButton1,Caption,OFF
  Endif
  If>%tmp%=1
  SetDialogProperty>Dialog_Main,Edit1,Text,ON
  SetDialogProperty>Dialog_Main,MSButton1,Caption,ON
  Endif
END>GetButton1

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Question on Dialogs

Post by Dorian (MJT support) » Fri Sep 02, 2022 6:28 pm

If I'm understanding correctly, you want to enter "1" in the edit box (taken from midstr).

Do this with SetDialogProperty.

Code: Select all

MidStr>%HTMLResponse%,8,1,tmp
....
SetDialogProperty>Dialog_Main,Edit1,Text,tmp

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Dialog>Dialog_Main
object Dialog_Main: TForm
  Left = 1073
  Top = 214
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Edit1: TEdit
    Left = 149
    Top = 43
    Width = 242
    Height = 40
    TabOrder = 0
    Text = '??'
  end
  object MSButton1: tMSButton
    Left = 453
    Top = 43
    Width = 150
    Height = 50
    Caption = '??'
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog_Main

//Original code
//HTTPRequest>http://172.30.2.20/io.cgi?,,GET,,HTMLResponse
//MessageModal>%HTMLResponse%
//Simulation code: 
Let>HTMLResponse=relais 10000000
MidStr>%HTMLResponse%,8,1,tmp


SetDialogProperty>Dialog_Main,Edit1,Text,tmp

Show>Dialog_Main
AddDialogHandler>Dialog_Main,MSButton1,OnClick,GetButton1
label>loop
wait>0.1
goto>loop
SRT>GetButton1
//GetDialogProperty>Dialog_Main,Edit1,Text,TheText 
  If>%tmp%=0
  SetDialogProperty>Dialog_Main,Edit1,Text,OFF
  SetDialogProperty>Dialog_Main,MSButton1,Caption,OFF
  Endif
  If>%tmp%=1
  SetDialogProperty>Dialog_Main,Edit1,Text,ON
  SetDialogProperty>Dialog_Main,MSButton1,Caption,ON
  Endif
END>GetButton1
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts