|
Post by wexhammer on Nov 21, 2019 6:40:02 GMT -5
Hi i have a slight problem with my code. I want to hide my bitmap image "a.bmp" when the value in the text box #1.3 is equal or greater than 100. I have been trying to work this out for over an hour now and i seem to be stuck on a tredmil. I have no other option but to now call for help. Please help me!
if #1.3, val("100"), then do #1.image "hide"
nomainwin
UpperLeftX = 250
UpperLeftY = 100
WindowWidth = 400
WindowHeight = 450
'make sure file exists
open "savedData.txt" for append as #3
close #3
'read from file
open "savedData.txt" for input as #3
if not(eof(#3)) then
line input #3,value1$
line input #3,value2$
end if
close #3
textbox #1.1, 90, 20, 40,20
textbox #1.2, 90, 110, 40,20
textbox #1.3, 90, 210, 40,20
button #1.exit, "Save",[save],LR,30,30,55,35
bmpbutton #1.image, "a.bmp", [abutton], UR, 50, 30
open "Splash Screen" for window as #1
#1.image "disable"
print #1.1, value1$
print #1.2, value2$
print #1.3, (val(value1$) + val(value2$)) * val("10")
'how would i make the image disapear when the text box #1.3 value
'is greater than > 100?
if #1.3, val("100"), then do #1.image "hide"
wait
[save]
'get texbox content
#1.1 "!contents? value1$"
#1.2 "!contents? value2$"
#1.3 "!contents? value3$"
'save textbox content
open "savedData.txt" for output as #3
print #3,value1$
print #3,value2$
print #3,value3$
close #3
'-------------------------
wait
[abutton]
wait
|
|
|
Post by Rod on Nov 21, 2019 8:20:02 GMT -5
Run this, change the contents of textbox 3 to less than 100, click [check]. Change it to more than 100, click [check]
'write dummy data to file open "savedData.txt" for output as #1 #1 "101" #1 "102" #1 "103" close #1
'open the window nomainwin UpperLeftX = 250 UpperLeftY = 100 WindowWidth = 400 WindowHeight = 450 textbox #1.1, 90, 20, 40,20 textbox #1.2, 90, 110, 40,20 textbox #1.3, 90, 210, 40,20 button #1.exit, "Save",[save],LR,150,55 button #1.check "Check", [check], LR, 200, 55 open "Splash Screen" for window as #1 #1 "trapclose [quit]"
'read three items from file open "savedData.txt" for input as #2 line input #2,value1$ line input #2,value2$ line input #2,value3$ close #2
'put values in textboxes #1.1 value1$ #1.2 value2$ #1.3 value3$
'now wait for user input wait
[check] 'get texbox3 content #1.3 "!contents? value3$" if val(value3$)>100 then notice "hide your bmp" wait
[save] 'get texbox content #1.1 "!contents? value1$" #1.2 "!contents? value2$" #1.3 "!contents? value3$" open "savedData.txt" for output as #3 #3 value1$ #3 value2$ #3 value3$ close #3 wait
[quit] close #1 end
We need better code to check for file existence but later.
|
|
|
Post by tsh73 on Nov 21, 2019 8:36:06 GMT -5
You can "hide", but as well you can
#1.image "show" But it should be called somehow. One way it to call it from other event - after button clicked ("Check manually" in example) or just after you changed #1.3 by code (after this line
print #1.3, (val(value1$) + val(value2$)) * val("10") ) or start a timer and check it every X millisecond ("Check by timer" in example)
' Form created with the help of Freeform-J v.261006 ' Generated on Nov 21, 2019 at 16:21:21
nomainwin
WindowWidth = 552 WindowHeight = 175
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #1.groupbox5, "picture goes here", 22, 16, 128, 120
'!!! set this path to real one ' bmpbutton #1.image, "C:\fromOld\C\progs\Just BASIC v1.01\bmp\CHERRY.BMP", [bmpbutton1Click], UL, 46, 46 ' bmpbutton #1.image, "\bmp\CHERRY.BMP", [bmpbutton1Click], UL, 46, 46 bmpbutton #1.image, "a.bmp", [bmpbutton1Click], UL, 46, 46
textbox #1.3, 198, 46, 100, 25 button #1.button3, "Check manually", [button3Click], UL, 350, 36, 122, 25 checkbox #1.checkbox4, "Check by timer", [checkbox4Set], [checkbox4Reset], 350, 81, 128, 20 statictext #1.statictext6, "condition is '>=100'", 190, 16, 144, 20 statictext #1.statictext7, "", 206, 101, 232, 20 'statictext #1.statictext7, "so it is checked every 500 ms", 206, 101, 232, 20 open "untitled" for window as #1 print #1, "trapclose [quit.1]"
print #1, "font ms_sans_serif 10"
#1.image "hide"
wait
[quit.1] Close #1 END
[bmpbutton1Click] 'Perform action for the bmpbutton named 'image' wait
[button3Click] 'Perform action for the button named 'button3' 'button to check condition goto [check] wait
[checkbox4Set] 'Perform action for the checkbox named 'checkbox4' timer 500, [check] 'start timer #1.statictext7, "so it is checked every 500 ms" wait
[checkbox4Reset] 'Perform reset for the checkbox named 'checkbox4' timer 0 'stop timer #1.statictext7, "" wait
[check] #1.3 "!contents? num" 'notice ">";num;"<" if num >= 100 then #1.image "show" else #1.image "hide" end if wait
|
|
|
Post by wexhammer on Nov 21, 2019 11:46:42 GMT -5
Thank you!
|
|