Switch from GRAPHICS to Text Output

Matteo
Posts: 16
Joined: Thu Jan 19, 2017 1:14 pm
My devices: iPhone 5S
Flag: Italy

Re: Switch from GRAPHICS to Text Output

Post by Matteo »

Hi, thank you, for the first question I cant scroll up the text output after the end of calculation, while if I try with other source code without BUTTON command I can scroll up. Please try if you want the code : after the end of calculation , if you switch to txt page you cant scroll up the txt page. Have you experienced about that?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Switch from GRAPHICS to Text Output

Post by Mr. Kibernetik »

Matteo wrote:
Sat Feb 04, 2017 6:49 am
Hi, thank you, for the first question I cant scroll up the text output after the end of calculation, while if I try with other source code without BUTTON command I can scroll up. Please try if you want the code : after the end of calculation , if you switch to txt page you cant scroll up the txt page. Have you experienced about that?
Yes, page with interface objects blocks the scroll.
You can hide it with
PAGE "" HIDE
command before you stop your program.
Please read about pages if the above advice sounds strange for you.

Matteo
Posts: 16
Joined: Thu Jan 19, 2017 1:14 pm
My devices: iPhone 5S
Flag: Italy

Re: Switch from GRAPHICS to Text Output

Post by Matteo »

Hi Mr. Kibernetik, ok thanks, but after to have hidden the page, I can't to re-show the key TXT and RGB, so after the scroll operation I cant switch between graph and txt. I'm learning a bit about TOUCH_X...that command can work also in TEXT page or only in GRAPHICS environment?
Thanks
Matteo

Matteo
Posts: 16
Joined: Thu Jan 19, 2017 1:14 pm
My devices: iPhone 5S
Flag: Italy

Re: Switch from GRAPHICS to Text Output

Post by Matteo »

Hi! the only way to reload the RGB key in text page with scrolling capability is to use GET ORIENTATION command, the code below:

Code: Select all

REM --- We start in the graph page:
GRAPHICS
button_text$ = "TXT"
BUTTON "a" TEXT button_text$ AT 250,10


i=0
LOOP:
IF i<50 THEN
i=i+1
x=i
y=2*x+4
REM --- What I want to see in the text page:
PRINT x, y
REM --- and what I want to see in the graph page:
DRAW PIXEL x,y COLOR 1,0,0
DRAW CIRCLE x,y SIZE 2
PAUSE 0.05

REM calculation terminated:
ELSE
SLOWDOWN



IF button_text$="RGB" THEN
GET ORIENTATION P
IF P=4 THEN
PAGE "" HIDE
ELSE
PAGE "" SHOW
ENDIF
ENDIF



GOTO switch_page
ENDIF


switch_page:
IF button_text$ = "TXT" AND BUTTON_PRESSED("a") THEN
 button_text$ = "RGB"
 BUTTON "a" TEXT button_text$
 TEXT
 GOTO LOOP
ENDIF
IF button_text$ = "RGB" AND BUTTON_PRESSED("a") THEN
 button_text$ = "TXT"
 BUTTON "a" TEXT button_text$
 GRAPHICS
 GOTO LOOP
ENDIF
GOTO LOOP
Do you know if a better way exists, maybe with other commands in SB? I'd prefer avoiding to rotate by 90 degrees the phone to disable RGB key and to be able to scroll up and down the text page and re-rotate the phone to re-enable the RGB key to switch to graph view. Thanks for the help
Matteo

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Switch from GRAPHICS to Text Output

Post by Mr. Kibernetik »

You can set exact size of a page to avoid full screen blocking.

Matteo
Posts: 16
Joined: Thu Jan 19, 2017 1:14 pm
My devices: iPhone 5S
Flag: Italy

Re: Switch from GRAPHICS to Text Output

Post by Matteo »

ok! I will try thanks

davey110
Posts: 82
Joined: Mon Dec 26, 2016 11:01 pm
My devices: iPod touch 6
iPad mini 2
Flag: Canada

Re: Switch from GRAPHICS to Text Output

Post by davey110 »

Is there a simple way to INPUT on the graphics screen? I have been using INPUT x$, which automatically switches to TEXT mode, then you have to switch back to GRAPHICS to print (DRAW) x$ on the graphics screen. The FIELD commands seem to be for text fields. I can't find any graphics or interface command that does this on the existing GRAPHICS page. Can you create an INPUT field on a graphics page? I can't find anything in the examples.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Switch from GRAPHICS to Text Output

Post by Mr. Kibernetik »

davey110 wrote:
Mon Feb 06, 2017 11:36 pm
Is there a simple way to INPUT on the graphics screen? I have been using INPUT x$, which automatically switches to TEXT mode, then you have to switch back to GRAPHICS to print (DRAW) x$ on the graphics screen. The FIELD commands seem to be for text fields. I can't find any graphics or interface command that does this on the existing GRAPHICS page. Can you create an INPUT field on a graphics page? I can't find anything in the examples.
You can use FIELD command to input text in graphics screen.
You can check sample program "Interactive Interface > sin + cos.txt" - function parameters are set using FIELD interface objects.

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: Switch from GRAPHICS to Text Output

Post by GeorgeMcGinn »

davey110 wrote:
Mon Feb 06, 2017 11:36 pm
Is there a simple way to INPUT on the graphics screen? I have been using INPUT x$, which automatically switches to TEXT mode, then you have to switch back to GRAPHICS to print (DRAW) x$ on the graphics screen. The FIELD commands seem to be for text fields. I can't find any graphics or interface command that does this on the existing GRAPHICS page. Can you create an INPUT field on a graphics page? I can't find anything in the examples.
I've used the techniques in the source code below with GRAPHICS ON, and it works. You may have to tinker with it, but I will see if I can find a program that Ricardo wrote where I turned his text boxes to work in GRAPHICS.

This program was part of a post awhile back when Ricardo, Dutchman and I were trying to give the user the ability to continue scrolling from field to field until the button was pushed. You can use either the TAB or ENTER key. However, ENTER will highlight the next field where TAB leaves the lighlight in the last field ENTER was hit, but advances the cursor to the next FIELD.

The highlighting was part of what Dutchman wrote in his code. When I use it in my programs, I remove the highlight. Since TAB doesn't advance it, it makes more sense to just follow the cursor.

George.

Code: Select all

SBMain:

prompt$=""
Answer$=""
.FALSE=0
.TRUE=1
BUTTON.SELECTED=.FALSE

GOSUB GetScreen

GetFieldInput:
'*** Loop through the input fields. If the button isn't pressed and we are at
'*** the last field, go back to the top
    X=1
    DO 
          IF BUTTON_PRESSED ("updt") THEN
             BUTTON.SELECTED=.TRUE
             GOTO 100
          ENDIF
          F$=X
          GET_INPUT(F$)
          X+=1
          IF X=6 THEN X=1
    UNTIL BUTTON.SELECTED

100 GOSUB GetAnswers

SBEnd:
STOP
  


'Get and print out all the results
'
'

GetAnswers:
 
   Answer$=FIELD_TEXT$("1")
   PRINT "What is your name: "&Answer$

   Answer$=FIELD_TEXT$("2")
   PRINT "Where do you live: "&Answer$

   Answer$=FIELD_TEXT$("3")
   PRINT "How long have you been a forum member: "&Answer$

   Answer$=FIELD_TEXT$("4")
   PRINT "Yes, "&Answer$&" is a nice feature."

   Answer$=FIELD_TEXT$("5")
   PRINT "Interesting: "&Answer$

RETURN


GetScreen:

PRINT!PRINT TAB(14);"What is your name:"
FIELD "1" TEXT prompt$ AT 380,30 SIZE 300, 25

PRINT!PRINT TAB(14);"Where do you live:"
FIELD "2" TEXT prompt$ AT 380,75 SIZE 300, 25

PRINT!PRINT "How long a member of the Forum:"
FIELD "3" TEXT prompt$ AT 380,120 SIZE 300, 25

PRINT!PRINT " Favorite feature of the Forum:"
FIELD "4" TEXT prompt$ AT 380,165 SIZE 300, 25
   
PRINT!PRINT "  Have you posted any programs:"
FIELD "5" TEXT prompt$ AT 380,210 SIZE 300, 25

BUTTON "updt" TEXT "Update" AT 380,270 SIZE 100,30

PRINTLINE(4)!PRINT "Results of input boxes:"!PRINT "-----------------------"


RETURN

DEF GET_INPUT(FIELD$)
    FIELD FIELD$ BACK COLOR 1,1,0
    FIELD FIELD$ FONT NAME "Courier"
    FIELD FIELD$ SELECT
    DO
          IF BUTTON_PRESSED ("updt") THEN
             BUTTON.SELECTED=.TRUE
          ENDIF
          SLOWDOWN
    UNTIL FIELD_CHANGED(FIELD$) OR BUTTON.SELECTED
    FIELD FIELD$ BACK COLOR 1,1,1   
ENDDEF
   
   
DEF PRINTLINE (A)
    N=1
    DO 
       PRINT
       N=N+1
    UNTIL N > A   
ENDDEF   
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

davey110
Posts: 82
Joined: Mon Dec 26, 2016 11:01 pm
My devices: iPod touch 6
iPad mini 2
Flag: Canada

Re: Switch from GRAPHICS to Text Output

Post by davey110 »

Thank you. I read the help notes, but couldn't quite get it all together. Now I see how to integrate the FIELD commands, as in the following code:

x$="Type here"
1 FIELD "name" TEXT x$ AT 200,200 SIZE 200,60 ' draw the field box
FIELD "name" FONT SIZE 50 ' optional
FIELD "name" SELECT ' selects any text already in the field, so it will delete when you start typing new input. Optional.

2 DO
3 UNTIL FIELD_CHANGED("name")=1 ' waits for input
4 x$ = FIELD_TEXT$("name") ' read the new text in the field

The numbered lines are the essential commands. The other 2 lines are "cosmetic", or optional, depending on what you need.

Thanks for getting me on the right track.

Post Reply