Author |
Topic: STRINGWIDTH? (Read 291 times) |
|
Dacite
New Member
member is offline
Posts: 6
|
|
STRINGWIDTH?
« Thread started on: Apr 13th, 2015, 11:38pm » |
|
Oops - My bad... Works great!
Stringwidth? sounded like the neatest thing since the Large Hadron Collider, but I get X = 0 when I use it. Code:GRAPHICBOX #g.gb 5, 5, 100, 100
TEXTEDITOR #g.te 115, 5, 100, 200
open "Init" for Window as #g
#g.gb "trapclose [Done]"
#g.gb "font lucida_console 12"
#g.gb "backcolor green"
#g.gb "color yellow"
#g.gb "place 0 0"
#g.gb "\" ''' Write a line feed
#g.gb "posxy X Y" ''' Get graphics cursor position (font height)
Char$ = "X"
#g.te "!STRINGWIDTH? ";Char$;" "; X
print X, Y '* Prints 0 20 *
#g.te "!STRINGWIDTH? Char$ X"
print X, Y '* Prints 0 20 *
#g.gb "\"; Char$ '* Write a char *
wait
[Done]
CLOSE #g
END Is the code I'm using. I also tried a literal "X", all variables inside the quotes, forum search for STRINGWIDTH?, restarting LBB... Without specifying the texteditor all I got was the "Mistake" box. Without the ! it prints STRINGWIDTH?.
|
« Last Edit: Apr 16th, 2015, 3:09pm by Dacite » |
Logged
|
|
|
|
RobM
Junior Member
member is offline
Posts: 91
|
|
Re: STRINGWIDTH? not working
« Reply #1 on: Apr 14th, 2015, 02:59am » |
|
STRINGWIDTH is a graphics command. It isn't intended to work with texteditors.
Code:GRAPHICBOX #g.gb 5, 5, 100, 100
TEXTEDITOR #g.te 115, 5, 100, 200
open "Init" for Window as #g
#g.gb "trapclose [Done]"
#g.gb "font lucida_console 12"
#g.gb "backcolor green"
#g.gb "color yellow"
#g.gb "place 0 0"
#g.gb "\" ''' Write a line feed
#g.gb "posxy X Y" ''' Get graphics cursor position (font height)
Char$ = "X"
#g.gb "STRINGWIDTH? ";Char$;" X"
print X, Y '* Prints 0 20 *
#g.gb "STRINGWIDTH? Char$ X"
print X, Y '* Prints 0 20 *
#g.gb "\"; Char$ '* Write a char *
wait
[Done]
CLOSE #g
END
|
« Last Edit: Apr 14th, 2015, 03:02am by RobM » |
Logged
|
|
|
|
Dacite
New Member
member is offline
Posts: 6
|
|
Re: STRINGWIDTH? not working
« Reply #2 on: Apr 14th, 2015, 04:44am » |
|
Thank you. For anyone else looking for a solution, here is the correct syntax: Code:#g.gb "STRINGWIDTH? Char$ X" I will have to test it, but I am assuming that the font width is the same in other display controls...
|
|
Logged
|
|
|
|
|