Board Logo
« STATICTEXT won't accept variables for x,y position »

Welcome Guest. Please Login or Register.
Jan 16th, 2018, 3:31pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: STATICTEXT won't accept variables for x,y position  (Read 67 times)
DrOldies
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 1
xx STATICTEXT won't accept variables for x,y position
« Thread started on: Nov 1st, 2017, 07:23am »

Just started writing my 1st JB test apps and have a problem with STATICTEXT. x,y positioning works with real numbers, but when I try to use variables for positioning, only the last text line appears in the box. Looking at a few dozen JB apps, I did not find one that used variables x,y.

I have an array of dozens of strings of 30 characters each, I would like to translate pixel positions to text 'lines' to easily change line spacing.

If this a problem with JB v1.01, any idea of when v2 will be released? JB is ideal for my apps with easy coding for window creation and file I/O.

Code:
'place text:  STATICTEXT #handle, "string", xpos, ypos, wide, high

yLine = 15          'pixels per line
 xChar = 6          'character width

    nomainwin
    gosub [openMainWindow]


[inputLoop]             'input?
    input r$
    goto [inputLoop]

[openMainWindow]
    WindowWidth = 300
    WindowHeight = 300

statictext #main1, "Line 1 test",6,15, 60, 20
statictext #main1, "Line 2 test", 6,30, 60, 20

 'open the main window
open "Test Window 1" for dialog as #main1

row = 1     'leave upper left space
char = 1

x = char * xChar
y = row * yLine
statictext #main2, "Line 1 test", x,y, 60, 20
row = row + 2
y = row * yLine
statictext #main2, "Line 2 test", x,y, 60, 20

 'open the main window
open "Test Window 2" for dialog as #main2

return
 

User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: STATICTEXT won't accept variables for x,y posi
« Reply #1 on: Nov 1st, 2017, 08:42am »

Quote:
If this a problem with JB v1.01,

Nope. It just don't work this way - never was supposed to work this way, by design.

If you want to easily change spacing, use graphicbox to print text at any given pixel position.

Quote:
any idea of when v2 will be released

You are lucky. It happeneed TODAY
- go to announctments board.

EDIT
text with different spacing: example
Code:
'   Form created with the help of Freeform-J v.261006
'   Generated on Nov 01, 2017 at 16:42:24

    nomainwin

    WindowWidth = 550
    WindowHeight = 410

    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    graphicbox #main.graphicbox1, 6, 6, 368, 365
    button #main.button2, "singleSpacing", [button1Click], UL, 382, 16, 122, 25
    button #main.button3, "1.5 Spacing", [button2Click], UL, 382, 51, 122, 25
    button #main.button4, "doubleSpacing", [button3Click], UL, 382, 86, 122, 25
    open "text in graphicbox - push those buttons!" for window as #main
    print #main.graphicbox1,"down; fill white; flush"
    print #main, "trapclose [quit.main]"

    print #main, "font ms_sans_serif 10"
    'get spacing
    #main.graphicbox1 "place 0 0"
    #main.graphicbox1 "\"
    #main.graphicbox1 "posxy dummy vSpace"

    wait

[quit.main]
    Close #main
    END


[button1Click]
'single spacing - normal print
     #main.graphicbox1 "cls"
     #main.graphicbox1 "place 0 0"
     #main.graphicbox1 "\"  'new line
     restore
     for i = 1 to 4
         read a$ 
         #main.graphicbox1 "\";a$
    next
    #main.graphicbox1 "flush"
wait

[button2Click]
'1.5 spacing
     #main.graphicbox1 "cls"
     #main.graphicbox1 "place 0 0"
     #main.graphicbox1 "\"  'new line
     restore
     for i = 1 to 4
         read a$ 
         #main.graphicbox1 "posxy dummy vPos"   'current position
         #main.graphicbox1 "\";a$ 
         #main.graphicbox1 "place 0 ";vPos+1.5*vSpace   '1,5 lines down
    next
    #main.graphicbox1 "flush"
wait

[button3Click]
'double spacing - just print extra empty line ("\")
     #main.graphicbox1 "cls"
     #main.graphicbox1 "place 0 0"
     #main.graphicbox1 "\"  'new line
     restore
     for i = 1 to 4
         read a$ 
         #main.graphicbox1 "\";a$
         #main.graphicbox1 "\"
    next
    #main.graphicbox1 "flush"
wait

data "Old MacDonald had a farm"
data "E-I-E-I-O"
data "And on his farm he had a cow"
data "E-I-E-I-O"
 
« Last Edit: Nov 1st, 2017, 08:57am by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls