Terminal Usage - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Terminal Usage (/thread-4615.html) |
Terminal Usage - toml_12953 - 09-01-2015 04:52 PM Is there any way to determine the current column an item is being printed in? I need a TAB function in my programs to align output. Example; PRINT(A+TAB(20)+B); Variable B would always print starting in column 20 no matter how large or small A was. I don't see any way to do something like that. If there was a function such as LLOC() that gave the current position of the cursor, I could do this: Code:
If A was two characters long, TAB(20) would return a string of 18 blanks. If A was 5 characters long, TAB(20) would return 15 blanks. You get the idea. RE: Terminal Usage - eried - 09-01-2015 06:35 PM Since the font in the terminal for any number has the same width per number, and each number is 2 spaces wide, why don't you pass the first number to that function? Example: Code: spaces (var,len) You could optimize that but is an idea. RE: Terminal Usage - toml_12953 - 09-02-2015 05:57 PM (09-01-2015 06:35 PM)eried Wrote: Since the font in the terminal for any number has the same width per number, and each number is 2 spaces wide, why don't you pass the first number to that function? Thanks a lot! I still have the problem of minus signs and decimal points (one space instead of two) messing up the columns but it's a lot better than it was. I still wish for a real TAB function, though, where TAB(10) would always start printing in column 10 no matter what had been printed before. LOCATE(X,Y) to start printing at a given column and row would also be handy. Especially if you had a way to determine what row and column you were on to begin with. RE: Terminal Usage - eried - 09-02-2015 06:47 PM Terminal is just an line/output you could create a whole complete UI drawing each text in the display where you want, check: Code: Syntax: TEXTOUT_P(text, [G], x, y, [font], [textColor], [width], [backgroundColor]) Code: Syntax: BLIT_P([trgtG], [dx1, dy1], [dx2, dy2], srcG, [sx1, sy1], [sx2, sy2], [c]) RE: Terminal Usage - toml_12953 - 09-03-2015 12:29 PM Thanks to eried, I created this simple LOCATE function. It only uses the default font. Code: EXPORT LOCATE(TEXT,X,Y) Both X and Y start at 1 and (1,1) is the upper left corner of the display. 19 lines fit on the display. Here's a calling program: Code: EXPORT LOCTEST() Thanks again, eried! Tom L RE: Terminal Usage - eried - 09-03-2015 12:55 PM Notice that _P means "pixels", so TEXTOUT_P will use pixel positions, and TEXTOUT will use coordinates (these could change) |