Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Locate" in the program
#1
Hello, is there a way to set the distance from the edge for the whole program with "Locate"?

So far I've only found the way, see screenshot. Pretty laborious. Thanks!

[Image: Locate2022-06-07-215135.jpg]
Reply
#2
Are you trying to get the width of the screen you are using?


If so it is _Width in text screens maybe even console, _Width/8 for graphics screens.
(Assuming default font when get _Width and _Height)
Likewise _Height gives you rows in text screens not console! and _Height/16 for graphics screens.

So:
DistanceToEdgeInChars = _Width/8 - ColumnYouAreAt ' for graphics screens
or
DistanceToEdgeInPixels = _Width - Xpixel ' for graphics
b = b + ...
Reply
#3
Unfortunately, that doesn't work - or I'm doing something wrong.

The input/output should be 2 columns from the margin. I guess I have to do it with "Locate". Thanks for the tip.

[Image: Angebotkalk-Ausf2022-06-08.jpg]
Reply
#4
Sorry, I do not really understand what you are after. If you are trying to control output printing onto the screen, you could look into Window or View Print.
b = b + ...
Reply
#5
Right align a number input:
Code: (Select All)
_Title "Right align a number input to a column number" ' b+ 2022-06-08

'expecting numbers up to 10 digits including dot or minus sign for this demo
Locate 5, 10: Print "Number 1:" ' column 19 leave blank if max 10 digits used
Locate 6, 10: Print "Number 2:"
a = getNumber(5, 30)
b = getNumber(6, 30)
t$ = Str$(a + b)
Locate 7, 10: Print "   Total:"
Locate 7, 30 - Len(t$): Print t$

Function getNumber (row, lastDigitCol) ' might need to control length of output
    k$ = InKey$
    While k$ <> Chr$(13)
        If Len(k$) Then
            If InStr("-123456789.", k$) Then
                num$ = num$ + k$
                Locate row, lastDigitCol - Len(num$) - 1: Print Space$(Len(num$));
                Locate row, lastDigitCol - Len(num$): Print num$;
            ElseIf Asc(k$) = 8 Then
                If Len(num$) Then
                    num$ = Left$(num$, Len(num$) - 1)
                    Locate row, lastDigitCol - Len(num$) - 1: Print Space$(Len(num$));
                    Locate row, lastDigitCol - Len(num$): Print num$;
                End If
            End If
        End If
        k$ = InKey$
    Wend
    getNumber = Val(num$)
End Function
b = b + ...
Reply
#6
Yes, apparently I really have a problem describing what I mean in English.

I'll write the program to end and then show the result. Then one can see what I meant.  Wink
Reply
#7
Or you could keep me guessing and I could write up all kinds of utilities ;-))
b = b + ...
Reply
#8
(06-08-2022, 08:39 PM)Kernelpanic Wrote: Yes, apparently I really have a problem describing what I mean in English.

I'll write the program to end and then show the result. Then one can see what I meant.  Wink

Oder beschreibe dein Problem einfach mal auf deutsch, vielleicht kan ich dir ja weiterhelfen. Smile

Schon mal ein paar Infos vorweg:
- LOCATE ist Satzaktiv, nicht modal, d.h. ein LOCATE für ein PRINT (USING)
- Wenn du immer 2 Zeichen Rand haben willst, dann kannst du entweder deine PRINTs mit TAB kombinieren,
z.B. TAB(2);PRINT USING ....
- oder füge einfach 2 Leerzeichen am Anfang der Ausgabetexte ein:
"  Fertigungsmaterial"
"  +8% Gemeinkosten...."
"  -----------------------"
Reply
#9
(06-07-2022, 08:04 PM)Kernelpanic Wrote: Hello, is there a way to set the distance from the edge for the whole program with "Locate"?

So far I've only found the way, see screenshot. Pretty laborious. Thanks!

[Image: Locate2022-06-07-215135.jpg]

Is this what you re looking for?

Code: (Select All)
PRINT "horse"
PRINT "cow"
PRINT "mule"
PRINT "pig"
PRINT "Why bring Steve's farm into this?"

PRINT: PRINT: PRINT
' Now do it again but so it indents 5 spaces...

printx "horse"
printx "cow"
printx "mule"
printx "pig"
printx "Why bring Steve's farm into this?"

SUB printx (x$)
    LOCATE , 5
    PRINT x$
END SUB


Pete
Reply
#10
(06-09-2022, 01:50 AM)Pete Wrote:
(06-07-2022, 08:04 PM)Kernelpanic Wrote: Hello, is there a way to set the distance from the edge for the whole program with "Locate"?

So far I've only found the way, see screenshot. Pretty laborious. Thanks!

[Image: Locate2022-06-07-215135.jpg]

Is this what you re looking for?

Code: (Select All)
PRINT "horse"
PRINT "cow"
PRINT "mule"
PRINT "pig"
PRINT "Why bring Steve's farm into this?"

PRINT: PRINT: PRINT
' Now do it again but so it indents 5 spaces...

printx "horse"
printx "cow"
printx "mule"
printx "pig"
printx "Why bring Steve's farm into this?"

SUB printx (x$)
    LOCATE , 5
    PRINT x$
END SUB


Pete

And extending that symmetrically the other way:
Code: (Select All)
Print "horse"
Print "cow"
Print "mule"
Print "pig"
Print "Why bring Steve's farm into this?"

Print
' Now do it again but so it indents 5 spaces...

printx "horse"
printx "cow"
printx "mule"
printx "pig"
printx "Why bring Steve's farm into this?"
Print
printY "horse", 50
printY "cow", 50
printY "mule", 50
printY "pig", 50
printY "Why bring Steve's farm into this?", 50
Print
printY "horse", 78
printY "cow", 78
printY "mule", 78
printY "pig", 78
printY "Why bring Steve's farm into this?", 78

Sub printx (x$)
    Locate , 5
    Print x$
End Sub

Sub printY (x$, RightPosition)
    Locate , RightPosition - Len(x$) + 1
    Print x$
End Sub
b = b + ...
Reply




Users browsing this thread: 1 Guest(s)