LB Booster
« STRINGWIDTH? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:49am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: STRINGWIDTH?  (Read 291 times)
Dacite
New Member
Image


member is offline

Avatar




PM


Posts: 6
xx 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 » User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx 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 » User IP Logged

Dacite
New Member
Image


member is offline

Avatar




PM


Posts: 6
xx 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...
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls