|
Problem
Nov 22, 2019 11:55:59 GMT -5
Post by wexhammer on Nov 22, 2019 11:55:59 GMT -5
Hello again, another slight program with the code below its just not running as intended. The custom spinner control is working however i would like in the text box the word "Day" to remain in there and when i press the plus button the text Day stays the same but the numeral next to it in the same textbox go up. Eg; Day 1, Day 2 , Day 3, Day 4 etc.... Does anyone know were i am going wrong?
#1.1, "!contents? val3"
val3=val3+1
print #1.1, val("Day") + val3
Main Code:
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, 40, 20, 90,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
button #1.plus, "+", [plus], UL, 140, 20, 88, 21
open "Splash Screen" for window as #1
print #1.1, value1$
print #1.2, value2$
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
[plus]
#1.1, "!contents? val3"
val3=val3+1
print #1.1, val("Day") + val3
wait
|
|
|
Problem
Nov 22, 2019 13:34:04 GMT -5
Post by tsh73 on Nov 22, 2019 13:34:04 GMT -5
change
print #1.1, val("Day") + val3 to
print #1.1, "Day"+str$(val3) or
print #1.1, "Day";val3
(actually ";" converts val13 to string, as str$(val13))
|
|
|
Problem
Nov 22, 2019 15:19:19 GMT -5
Post by wexhammer on Nov 22, 2019 15:19:19 GMT -5
Thank you. However when i press the button again the value 1 doesn't increase for example; day1, day2, day3 etc... How would i achieve this?
|
|
|
Problem
Nov 22, 2019 15:30:56 GMT -5
Post by tsh73 on Nov 22, 2019 15:30:56 GMT -5
Have a look at comments here.
[plus] 'so you want it have "Day 1" etc, with number increasing 'then !contents? will be a string. 'val("Day 1") is 0 (it is not a number) - you have to get number first 'so first get it as string #1.1, "!contents? val3$" 'if it empty then just start from Day 1 if trim$(val3$) = "" then val3=0 'then we add 1, it'll became day 1 else 'number supposed to be second word val3=val(word$(val3$,2)) end if 'now increase day val3=val3+1 'and print it to textbox, with Day and space (so WORD$ will work) print #1.1, "Day ";val3 wait
|
|
|
Problem
Nov 22, 2019 15:51:42 GMT -5
Post by wexhammer on Nov 22, 2019 15:51:42 GMT -5
Thanks, now i understand the concept. So if i was to read that value for example the contents of that textbox. If it is Day 3 then notice "hello". How would i do that? My snippet doesnt seem to work.
#1.1 "!contents? Day3 " if num <= 100 then Notice "Brilliant" else Notice "Not so good!" end if
|
|
|
Problem
Nov 22, 2019 16:13:59 GMT -5
Post by wexhammer on Nov 22, 2019 16:13:59 GMT -5
Not to worry i have solved it. Thanks for the help!
|
|