|
Post by arryman on Feb 2, 2022 16:18:10 GMT -5
Hi, I'm trying to set font in a list box, and can't get past the errors. The code runs fine until I put in the line setting font in the listbox.
I've tried the following, both before and after opening the window.
print #team.list, "font arial 14 bold"
print #team.list, "!font arial 14 bold"
print #team.list "!font arial 14 bold"
print #team.list "font arial 14 bold"
The errors are "invalid handle" with the comma, and "syntax error" without it. I believe I've seen examples of both in the literature, but have obviously missed something vital. Any advice welcome!
Here is my try-out code:
nomainwin
choice$(0) = "Red"
choice$(1) = "Yellow"
choice$(2) = "Blue"
choice$(3) = "Green"
choice$(4) = "White"
listbox #team.list, choice$(), [selectionMade], 5, 35, 200,150 button #team.cont, "Continue", [selectionMade], UL, 5, 5
button #team.canc, "Cancel", [cancelteamSelection], UR, 15, 5
WindowWidth = 600 : WindowHeight = 700
UpperLeftX = 200 : UpperLeftY = 150
print #team.list "!font arial 14 bold"
open "Team Selection" for window as #team
wait
[selectionMade]
print #team.list, "selection? choice$"
notice selection$ + " chosen"
wait
[cancelteamSelection]
notice selection$ + " selection cancelled"
close #team
end
print #team, "trapclose [quit]"
wait
[quit]
confirm "Are you sure?"; answer$
if answer$ <> "yes" then wait
close #team
end
|
|
|
Post by Brandon Parker on Feb 2, 2022 17:12:05 GMT -5
Try the code below; it should work. A couple of things to note: - First, there is no "!" at the beginning of the font command for a ListBox. The "!" is used where string inputs into controls are directly allowed.
- Second, if you use the "Print" command at the beginning of an LB statement then the comma after the handle is required. If you leave off the "Print" at the beginning, the comma becomes optional.
Number two and it looking cleaner without the "Print" and comma is why I switched to making all of my commands like this: #hWin.hControl "Some Command Here" Also, this section of code needs attention since you have the incorrect string variable receiving information from the ListBox selection command. See the change in my example... [selectionMade]
print #team.list, "selection? choice$"
notice selection$ + " chosen"
wait Here is the code updated to reflect the comments... There are a couple of other minor changes involving the selection$ variable, but nothing you can't obviously figure out. nomainwin
choice$(0) = "Red"
choice$(1) = "Yellow"
choice$(2) = "Blue"
choice$(3) = "Green"
choice$(4) = "White"
listbox #team.list, choice$(), [selectionMade], 5, 35, 200,150 button #team.cont, "Continue", [selectionMade], UL, 5, 5
button #team.canc, "Cancel", [cancelteamSelection], UR, 15, 5
WindowWidth = 600 : WindowHeight = 700
UpperLeftX = 200 : UpperLeftY = 150
open "Team Selection" for window as #team
#team.list "font arial 14 bold"
selection$ = "No selection"
wait
[selectionMade]
print #team.list, "selection? selection$"
notice selection$ + ", chosen"
wait
[cancelteamSelection]
notice selection$ + ", selection cancelled"
close #team
end {:0) Brandon Parker
|
|
|
Post by arryman on Feb 3, 2022 17:02:39 GMT -5
Brandon, Many thanks for putting me right here. Your code works fine, and I've already learnt stuff from it. Working on more of the program now.
|
|
|
Post by Brandon Parker on Feb 3, 2022 19:48:59 GMT -5
Happy to help!! It's always great when we come to the forum and learn something new.
{:0)
Brandon Parker
|
|