|
Post by angelo2449 on Oct 2, 2020 13:02:55 GMT -5
Hi guys,
With this code:
radiobutton #main.continua, "Linea Continua", [ContinuaSet], [ContinuaReset], xa + 345, ya + 40, 200, 25
.........
.........
FlagColor = 0
wait
' ----------------------------
[Controlla]
if FlagColor = 0 then
Notice "Attenzione" + chr$(13) + "Devi prima scegliere il Colore!"
#main.continua, "reset"
wait
else
return
end if
' ----------------------------
[ContinuaSet]
gosub [Controlla]
CodLinea$ = "C"
wait
' ----------------------------
Check the status of "FlagColor". In case it is equal to zero, I would like to reset the radiobutton "#maib.continua". But this does not happen, the program enters in a loop that always proposes 'Notice'. The program is blocked! If I remove # main.continua, "reset" , everything works normally!
Why?
Thank you.
|
|
|
Post by Chris Iverson on Oct 2, 2020 13:17:08 GMT -5
Interesting. This is a behavior I wouldn't have expected in LB, and I suspect it might be a bug, since it only happens if you're in the event handler for the Radiobutton Set event.
If you reset the button that just got set as part of the event handler for the set event, it looks like it goes into an infinite loop. It doesn't happen if the button is reset outside of the event handler.
'Form created with the help of Freeform 3 v07-15-08 'Generated on Oct 02, 2020 at 13:12:11
[setup.main.Window]
'-----Begin code for #main
nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
radiobutton #main.radiobutton1, "RadioButton Caption", [radiobutton1Set], [radiobutton1Reset], 5, 5, 144, 25 button #main.button2,"Reset",[button2Click], UL, 60, 152, 44, 25
'-----End GUI objects code
open "untitled" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event wait
[radiobutton1Set] 'Perform action for the radiobutton named 'radiobutton1'
'Insert your own code here notice "Set" #main.radiobutton1, "reset" wait
[radiobutton1Reset] 'Perform action for the radiobutton named 'radiobutton1'
'Insert your own code here notice "reset" wait
[button2Click] 'Perform action for the button named 'button2'
'Insert your own code here #main.radiobutton1, "reset" wait
[quit.main] 'End the program close #main end
|
|
|
Post by angelo2449 on Oct 2, 2020 15:50:28 GMT -5
So how can I trade? Thank you
|
|
|
Post by angelo2449 on Oct 2, 2020 15:57:31 GMT -5
This is the complete program, the error is evident Which causes an infinite loop.
nomainwin
if FileExists("C:\AutocadSupporto\Config\Unita.dat") then open "C:\AutocadSupporto\Config\Unita.dat" for input as #14 input #14, Disco$ close #14 end if
WindowWidth = 750 WindowHeight = 430
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "yellow" ForegroundColor$ = "black"
xa = 30 : ya = 40
texteditor #main.edit, -400, -400, 200, 100 textbox #main.fin, xa + 15, 20, 640, 25
groupbox #main.colore, "Colore", xa + 20, ya + 15, 300, 115 radiobutton #main.nero, "Linea colore Nero", [NeroSet], [NeroReset], xa + 25, ya + 40, 200, 25 radiobutton #main.rosso, "Linea colore Rosso", [RossoSet], [RossoReset], xa + 25, ya + 70, 200, 25
groupbox #main.linea, "Linea", xa + 335, ya + 15, 317, 115 radiobutton #main.continua, "Linea Continua", [ContinuaSet], [ContinuaReset], xa + 345, ya + 40, 200, 25 radiobutton #main.tratt, "Linea Tratteggiata", [TrattSet], [TrattReset], xa + 345, ya + 70, 200, 25 radiobutton #main.punt, "Linea Puntinata", [PuntSet], [PuntReset], xa + 345, ya + 100, 200, 25
button #main.si, "Salva i 10 Punti", [Salva10Punti], UL, xa + 225, ya + 150, 210, 45 button #main.info, "Info", [Info], UL, 45, ya + 210, 120, 40 button #main.libr, "Libretto", [Libretto], UL, 255, ya + 210, 210, 40 button #main.esci, "Esci", [quit.main], UL, 565, ya + 210, 120, 40 TextboxColor$ = "cyan" textbox #main.notifica, 42, ya + 275, 643, 25
open "Gestione della Linea di Tipo > 7 < - Contorni 10 Punti - Ver. 30/09/2020" for window as #main #main, "font courier_new 10 17 bold" #main, "trapclose [quit.main]"
CodColor$ = "nil" CodLinea$ = "nil"
#main.edit, "!cls"; #main.edit, "!paste"; #main.edit, "!contents? StringaIn$"; StringaIn$ = "7|0|1430|1430|1430|1430|1430|1430|1430|1430|1430|1430|NC|" ''7|0|1310|1290|1280|1100|1400|1420|1430|1390|1310|1290|N|T| #main.fin, trim$(StringaIn$)
if left$(StringaIn$, 4) = "7|0|" then Pos1 = len(StringaIn$) - 4 ' |RC| CodColor$ = mid$(StringaIn$, Pos1 + 2, 1) CodLinea$ = mid$(StringaIn$, Pos1 + 3, 1) end if
print "left$(StringaIn$, 4) xxxx "; left$(StringaIn$, 4) print "Pos1 xxxx "; Pos1 print "StringaIn$ xxxx "; StringaIn$ print "CodColor$ xxxx "; CodColor$ print "CodLinea$ xxxx "; CodLinea$
if CodColor$ <> "nil" then select case CodColor$
case "N" #main.nero, "set"
case "R" #main.rosso, "set"
end select end if
if CodLinea$ <> "nil" then select case CodLinea$
case "C" #main.continua, "set"
case "T" #main.tratt, "set"
case "P" #main.punt, "set"
end select end if
CodColor$ = "" FlagColor = 0 #main.nero, "reset" #main.rosso, "reset" #main.continua, "reset" #main.tratt, "reset" #main.punt, "reset"
wait
' -----------------------------------------------
[Libretto]
run "Notepad " + Disco$ + "\AutocadSupporto\Libretto\LibrettoPregeo.dat"
wait
' -----------------------------------------------
[Salva10Punti]
if CodColor$ = "nil" then Notice "Attenzione" + chr$(13) + "Devi impostare il Colore della linea" wait end if
if CodLinea$ = "nil" then Notice "Attenzione" + chr$(13) + "Devi impostare il Tipo della linea" wait end if
#main.fin, "!contents? Contenuto$" Contenuto$ = trim$(Contenuto$) + CodColor$ + CodLinea$ + "|"
open Disco$ + "\AutocadSupporto\Libretto\LibrettoPregeo.dat" for append as #15 print #15, Contenuto$ close #15
#main.edit, "!cls"; #main.edit, CodColor$ + "#" + CodLinea$; #main.edit, "!selectall"; #main.edit, "!copy";
#main.notifica, "Riga salvata in > LibrettoPregeo <" Timer 1000, [Salta] wait
[Salta] #main.notifica, "" #main.libr, "!setfocus"
close #main end
' ----------------------------
[NeroSet]
CodColor$ = "N" FlagColor = 1
wait
' ----------------------------
[NeroReset] [RossoReset] [ContinuaReset] [TrattReset] [PuntReset]
wait
' ----------------------------
[RossoSet]
CodColor$ = "R" FlagColor = 1
wait
' ----------------------------
[Controlla]
if FlagColor = 0 then Notice "Attenzione" + chr$(13) + "Devi prima scegliere il Colore!" #Caso$, "reset" wait else return end if
' ----------------------------
[ContinuaSet]
Caso$ = "#main.continua" gosub [Controlla] CodLinea$ = "C"
wait
' ----------------------------
[TrattSet]
Caso$ = "#main.tratt" gosub [Controlla] CodLinea$ = "T"
wait
' ----------------------------
[PuntSet]
Caso$ = "#main.punt" gosub [Controlla] CodLinea$ = "P"
wait
' ----------------------------
[Info]
if FileExists("C:\AutocadSupporto\Info\SiNo7.txt") then run "Notepad " + "C:\AutocadSupporto\Info\SiNo7.txt" end if
wait
' ----------------------------
function FileExists(FilePath$) dim FileExistsInfo$(1,1) ' ritorna 0 (zero) se il file non esiste, 1 (uno) se esiste files "", FilePath$, FileExistsInfo$( FileExists = val(FileExistsInfo$(0,0)) end function
' -------------------------------
[quit.main]
#main.edit, "!cls"; #main.edit, "Fine"; #main.edit, "!selectall"; #main.edit, "!copy";
close #main end
' -----------------------------------------------
Thank You.
|
|
|
Post by Chris Iverson on Oct 3, 2020 0:09:03 GMT -5
The only workaround I can think of is to make the reset NOT part of the Set event.
Here's my example code modified to do just that using a timer. Instead of immediately resetting as part of the event handler, it just starts a timer, and then ends the set event handler.
When the timer fires, the TIMER event handler resets the radiobutton. This dodges the infinite loop.
'Form created with the help of Freeform 3 v07-15-08 'Generated on Oct 02, 2020 at 13:12:11
[setup.main.Window]
'-----Begin code for #main
nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
radiobutton #main.radiobutton1, "RadioButton Caption", [radiobutton1Set], [radiobutton1Reset], 5, 5, 144, 25 button #main.button2,"Reset",[button2Click], UL, 60, 152, 44, 25
'-----End GUI objects code
open "untitled" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event wait
[resetButton] timer 0 #main.radiobutton1, "reset" wait
[radiobutton1Set] 'Perform action for the radiobutton named 'radiobutton1'
'Insert your own code here notice "Set" timer 100, [resetButton] wait
[radiobutton1Reset] 'Perform action for the radiobutton named 'radiobutton1'
'Insert your own code here notice "reset" wait
[button2Click] 'Perform action for the button named 'button2'
'Insert your own code here #main.radiobutton1, "reset" wait
[quit.main] 'End the program close #main end
|
|
|
Post by Rod on Oct 3, 2020 10:17:56 GMT -5
Is the clue not in the help file where it states that reset does not actually do anything? Usually one radiobutton is set. Perhaps the fix is to set an alternate radiobutton. If its multiple choice would a checkbox work better?
|
|
|
Post by tsh73 on Oct 3, 2020 14:01:56 GMT -5
If I remove NOTICE and instead print to textbox, it gets called only once. So I think it might be NOTICE that breaks event queue.
EDIT
Interesting but if I replace NOTICE with CustomNotice function of JB freeform, it does loop.
'Form created with the help of Freeform 3 v07-15-08 'Generated on Oct 02, 2020 at 13:12:11
[setup.main.Window]
'-----Begin code for #main
nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
radiobutton #main.radiobutton1, "RadioButton Caption", [radiobutton1Set], [radiobutton1Reset], 5, 5, 144, 25 button #main.button2,"Reset",[button2Click], UL, 60, 152, 44, 25 TEXTEDITOR #main.log, 160, 10, 200, 300
'-----End GUI objects code
open "untitled" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event wait
[radiobutton1Set] 'Perform action for the radiobutton named 'radiobutton1'
'Insert your own code here 'notice "Set" 'no notice - no problem #main.log time$("ms") #main.radiobutton1, "reset" wait
[radiobutton1Reset] 'Perform action for the radiobutton named 'radiobutton1'
'Insert your own code here notice "reset" wait
[button2Click] 'Perform action for the button named 'button2'
'Insert your own code here #main.radiobutton1, "reset" wait
[quit.main] 'End the program close #main end
|
|