Text on location?

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: Text on location?

Post by GeorgeMcGinn »

Ricardobytes' original program put out one question and answer box at a time, and you answered the questions sequentially, and after hitting enter on the last question ended the program. In between each question and answer, he printed a sentence using the response you gave.

I modified his original code because I needed to give the user all the questions at once, so they knew how many fields needed to have responses and what the last field was. It gave the user the chance before hitting enter on the last field to change anything. Without knowing the last question, you don't get that chance.

I also used an idea from Dutchman where he colored his input boxes. I changed that a little bit by putting all the labels and the input boxes on the screen and when you were at a question that needed an answer, the input box color changed from white to green, and when you hit enter, it changes back to white and the next field is colored.

This helps to visually see what question needs to be answered, since it is hard to see the cursor. Also, if you go back and make changes, if you have a field that is still green, you need to hit enter to commit that response. If you do not hit enter, the value typed in will not get used.

What I did not do was to make the code more tighter and efficient as in the other changes made by the Dutchman. I left it the way ricardobytes wrote it and expanded on it so it is a clear example of how to use most of the FIELD statements, a benefit for everyone, including beginners just learning Smart Basic. I will in the next version make the coding "more efficient" as in the Dutchman's example.

I will also add in the next release a series of buttons, so when you hit enter in the last field, it will not process the input. Instead, the buttons will give the user options. For example: a SUBMIT button, so even if you hit enter on the last field, you can still make changes, and nothing will be processed until you click the SUBMIT button. There will also be a CANCEL, RESET and CHANGE buttons. CANCEL will end the program without any further processing; RESET will clear all the fields and you will have to enter all the field values again; CHANGE button will repeat the FIELD input process from the top, but leave the vaules in the input fields. If you want to keep the value, you can use the TAB key as the values will have already been committed.

This is a very basic screen input box, where it uses a non-graphical user interface, and from here you can take this data, build a record and write it to a file.

Code: Select all

/*
PROGRAM: Screen Input v3.0

Original program by ricardobytes
The Dutchman changes (some) used here
Modifications by George McGinn

This is a very basic screen input program, where it uses a non-graphical user interface, and from here you can take this data, build a record and write it to a file.

*/


Initialize:

prompt$=""
Answer$=""

SetupInputLabels:


PRINT "What is your name?"
FIELD "z" TEXT prompt$ AT 1,35 SIZE 300, 25

PRINT!PRINT!PRINT!PRINT "Where do you live?"
FIELD "y" TEXT prompt$ AT 1,128 SIZE 300, 25
   
PRINT!PRINT!PRINT!PRINT "How long have you been a Forum member?"
FIELD "x" TEXT prompt$ AT 1,214 SIZE 300, 25

PRINT!PRINT!PRINT!PRINT "What is your favorite feature of the Forum?"
FIELD "w" TEXT prompt$ AT 1,304 SIZE 300, 25
   
PRINT!PRINT!PRINT!PRINT "Have you posted any programs?"
FIELD "v" TEXT prompt$ AT 1,400 SIZE 300, 25

PRINT!PRINT!PRINT!PRINT "Results of input boxes:"!PRINT "-----------------------"


GetInput:

' Create Input Name input box & get value
   FIELD "z" BACK COLOR 0,1,0
   FIELD "z" FONT NAME "Courier"
   FIELD "z" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("z")
   FIELD "z" BACK COLOR 1,1,1

' Create Where Do You Live input box & get value 
   FIELD "y" BACK COLOR 0,1,0
   FIELD "y" FONT NAME "Courier"
   FIELD "y" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("y") 
   FIELD "y" BACK COLOR 1,1,1

' Create Forum Member input box & get value
   FIELD "x" BACK COLOR 0,1,0
   FIELD "x" FONT NAME "Courier"
   FIELD "x" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("x")
   FIELD "x" BACK COLOR 1,1,1

' Create Favorite Forum Feature input box & get value
   FIELD "w" BACK COLOR 0,1,0
   FIELD "w" FONT NAME "Courier"
   FIELD "w" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("w")
   FIELD "w" BACK COLOR 1,1,1

' Create Have You Posted input Box & get value
   FIELD "v" BACK COLOR 0,1,0
   FIELD "v" FONT NAME "Courier"
   FIELD "v" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("v")
   FIELD "v" BACK COLOR 1,1,1

   GOSUB GetAnswers

STOP
  


'Get and print out all the results
'
'

GetAnswers:


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

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

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

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

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

RETURN
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)

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: Text on location?

Post by GeorgeMcGinn »

No problem. I'll write up a Programmer's Guide instead. It will have all the examples, smart programming techniques, and also be a companion to the Reference Manual you wrote.

I don't understand the commercial printing part, as I only planned to create a PDF file. Are you physically printing the manual? I just printed yours on my printer and put it in a binder.

George.
Dutchman wrote:
GeorgeMcGinn wrote: … If you would like, I would like to see more examples in the next version of the manual, and I am willing to help …
No thank you, keeping the PDF-manual updated gives me enough extra work. Even the size is already large and requires commercial printing. I suggest you contribute to a PDF document entitled "Examples of smart programming". The forum-members you mentioned will certainly assist in correcting and cleaning your proposals. :D
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)

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: Text on location?

Post by GeorgeMcGinn »

In this minor revision, I made the following changes:

The FIELD TEXT and SELECT now appear next to the label.
Used the TAB(N) option of the PRINT statement to move text to the right instead of hitting the space bar many times inside a string.
And I created a function that acts as a new statement: PRINTLINE(N). This simple function will print N number of blank lines instead of having to type, say 5 PRINT statements.

I keep a LIB called System.lib that I put all these functions in, including some of the PowerBASIC commands I wrote functions for instead of converting them, such as the INCR X (Increments X by 1, or X=X+1) and DECR X (Decrease X by 1 or X=X-1, but X can never be a negative number). Sometimes it is easier to write a function that has a PowerBASIC command rather than converting all. A program I am converting uses 150 INCR and DECR for different variables. Now I just have to put () around the variable and the function does it for me.

This type of input screen matches what many Visual or Graphic do. You put a label/question and right next to it is an input box. Sometimes it could be a checkbox or radio button, but this example shows how you can build a screen with labels and input boxes next to each other.

George.


Code: Select all

/*
PROGRAM: Screen Input v3.1

Original program by ricardobytes
The Dutchman changes I used differently
Modifications by George McGinn

This program nows aligns the labels and FIELD TEXT so that the input boxes appear next to the question or label, thus reducing the number of lines needed on the screen (by 10).

I also introduced the TAB(N) option to the PRINT statement. This performs N number of tabs then prints the text that follows, starting on N tabs + 1 position. This is better than putting all those spaces in front of the text just to get them to align up.

Also, I created a new command - PRINTLINE(N). This is a simple function that, instead of typing 4 or 5 PRINT statements, I now only have to write one print and tell it how many blank lines I want. Your code can get very messy looking if you have tons of "PRINT!PRINT!PRINT!PRINT!PRINT" statements all over in conditional logic (IF/THEN/ESEIF statements).

This is a very basic screen input box, where it uses a non-graphical user interface, and from here you can take this data, build a record and write it to a file.

*/


Initialize:

prompt$=""
Answer$=""

SetupInputLabels:


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

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

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

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

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


GetInput:

' Create Input Name input box & get value
   FIELD "z" BACK COLOR 0,1,0
   FIELD "z" FONT NAME "Courier"
   FIELD "z" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("z")
   FIELD "z" BACK COLOR 1,1,1

' Create Where Do You Live input box & get value 
   FIELD "y" BACK COLOR 0,1,0
   FIELD "y" FONT NAME "Courier"
   FIELD "y" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("y") 
   FIELD "y" BACK COLOR 1,1,1

' Create Forum Member input box & get value
   FIELD "x" BACK COLOR 0,1,0
   FIELD "x" FONT NAME "Courier"
   FIELD "x" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("x")
   FIELD "x" BACK COLOR 1,1,1

' Create Favorite Forum Feature input box & get value
   FIELD "w" BACK COLOR 0,1,0
   FIELD "w" FONT NAME "Courier"
   FIELD "w" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("w")
   FIELD "w" BACK COLOR 1,1,1

' Create Have You Posted input Box & get value
   FIELD "v" BACK COLOR 0,1,0
   FIELD "v" FONT NAME "Courier"
   FIELD "v" SELECT
   DO
      SLOWDOWN
   UNTIL FIELD_CHANGED("v")
   FIELD "v" BACK COLOR 1,1,1

   GOSUB GetAnswers


STOP
  


'Get and print out all the results
'
'

GetAnswers:


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

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

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

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

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

RETURN


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)

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Text on location?

Post by rbytes »

I tested your code on my iPad Air in both portrait and landscape. In portrait mode, it works perfectly. In landscape mode, the text still scrolls up, so that it is ambiguous which field should be entered. I tried removing the print 4 lines function, and then the text stayed put when the program ran in landscape.

If text is printed within one line's distance from the keyboard, it is automatically pushed up to maintain a bottom margin of one line space. So you would get different results on different devices. Setting toolbar off would give a bit more print space above the kb
Attachments
IMG_6125.PNG
IMG_6125.PNG (166.53 KiB) Viewed 3965 times
The only thing that gets me down is gravity...

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Text on location?

Post by rbytes »

This program is the closest I have come yet to creating a natural question and answer flow, which can have an unlimited number of questions and responses. The text will continually scroll up to keep the last line above the keyboard. You can reuse previous responses in later questions or comments.

There are some issues still. Let me know any that you notice.

Thanks

Code: Select all

REM Chat Page
REM by ricardobytes
REM October 2016

OPTION BASE 1
GET SCREEN SIZE sw, sh
cr$=CHR$(10)
DIM answer$(50)

' create full-screen field
dl$="dialogue"
FIELD dl$ TEXT a$ AT 1,1 SIZE sw,sh*.45 ML
FIELD dl$ FONT NAME "Courier"
FIELD dl$ FONT SIZE 24
FOR t=1 TO 100
  blank$&=CHR$(10)
NEXT t
blanklen=LEN(blanks$)

a$="*****  OUR CHAT GROUP *****"&cr$&cr$

' read first question
READ temp$
a$&=temp$&cr$&"? "
endfld=LEN(a$)
pg$&=blank$&"limit"

' display it in the field
FIELD dl$ TEXT a$

LOOP:
n+=1
prevend=endfld

' place cursor after the ? Prompt
FIELD dl$ SELECT endfld

loop2:
test$=FIELD_TEXT$(dl$)

' check if user has pressed Enter
IF RIGHT$(test$,1)=cr$ THEN
   a$=FIELD_TEXT$(dl$)
   endfld=LEN(a$)+1
   
   ' extract last answer from field contents
   answer$(n)=RIGHT$(a$,endfld-prevend)
   templength=LEN(answer$(n))
   
   ' trim off the carriage return
   answer$(n)=LEFT$(answer$(n),templength-1)
   templength=LEN(answer$(n))
   
   ' trim off the leading space
   answer$(1)=RIGHT$(answer$(n),templength-1)
   templength=LEN(answer$(n))
   
   IF n = 1 THEN nam$=answer$(n)
   
   ' read the next question
   READ temp$
   
   ' check temp$ for # and replace it with last answer
   templength=LEN(temp$)
   replace=INSTR (temp$, "#")
   IF replace<>-1 THEN
     temp$=LEFT$(temp$,replace-1)&answer$(n)&RIGHT$(temp$,templength-replace)          
   ENDIF
   
   ' check temp$ for ~ and replace it with chatter's name
   templength=LEN(temp$)
   replace=INSTR (temp$, "~")
   IF replace<>-1 THEN
     temp$=LEFT$(temp$,replace-1)&nam$&RIGHT$(temp$,templength-replace)          
   ENDIF
   
   a$&=cr$&temp$&cr$
      
   ' if no more data, then final dialogue is a statement, not a question
   IF DATA_EXIST() THEN a$&="? "
   endfld=LEN(a$)+1
   FIELD dl$ TEXT a$
   
   ' wait for user to press Enter
   ' if no more data then pause, hide keyboard, expand field and end
   IF DATA_EXIST() THEN
     GOTO LOOP
   ELSE
     PAUSE 2
     FIELD dl$ TEXT a$ AT 1,1 SIZE sw,sh ML
     FIELD dl$ FONT NAME "Courier"
     FIELD dl$ FONT SIZE 24
     FIELD dl$ DESELECT
     PAUSE 8
     END
   ENDIF
ELSE
  SLOWDOWN
  GOTO loop2
ENDIF

DATA "What is your name","Hello, #. How long have you been a Forum member","# is a long time. What is your favorite Forum feature","I like # too. What is your most recent program posted","I will have to try # soon. What are your other interests","Those sound like interesting hobbies. What new feature would you like to see in smart Basic","# would be a great feature, ~. What iOS device do you write your programs on","Good choice! It has been nice chatting with you, ~. Goodbye."
Attachments
IMG_6126.PNG
IMG_6126.PNG (206.12 KiB) Viewed 3954 times
IMG_6127.PNG
IMG_6127.PNG (226.6 KiB) Viewed 3954 times
IMG_6128.PNG
IMG_6128.PNG (226.01 KiB) Viewed 3954 times
The only thing that gets me down is gravity...

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: Text on location?

Post by GeorgeMcGinn »

Have you ever heard of the program ELIZA?

If not, or for those of you who were not born in 1977, it was a program that was based just like yours, written also in BASIC back then, and it was a program that asked you questions a psychiatrist would and give you some diagnosed disorder that you suffered from.

It was one of the earliest attempts at artificial intelligence. The program, based on keywords from your answers, would actually branch off and ask you more detailed questions, then come back to the more mundane ones.

It was pretty good at carrying on a conversation, but it was a great novelty program (We, and I mean me included) wrote one of the first real AI systems. It took notes from doctors, clinicians, family members, and questionnaires from the patient, and based on the information we determined what the patient was suffering from (we gave 2 or 3 possible diagnosis), and it even found information that was missing and overlooked and produced a chart that had a follow-up sheets and even suggested follow up questions.

It also suggested potential therapies, including drug therapy, which the research group I worked for, head by Dr. Nathan S. Kline, whom I worked for directly until his untimely death during quadruple bypass surgery, was the leading pioneer in drug therapy for mental illness.

The system and one of my first published papers in the journals of psychiatry was on NOEL, named after the computer scientist who was the brainchild of this system. And it was not developed by a private research firm, but one that was part of the NY State Department of Mental Hygiene, Rockland Research Institute. The best 10 years of my life in computer science, system programming and working with the researchers and clinicians, designing computer systems to aid them in their research or studies.

What i learned in the research field made me indispensable to corporate America who wanted what they called "Smart Systems" that were capable of spotting weaknesses in their business. Hence I perfected the Data Dictionary Engine, where the data and not the code determined what to do.

Anyway, we used to improve on the ELIZA program, and it went by a variety of names. And we were not the only ones who improved on the code. I remember it was the basis for early computer games. (https://en.m.wikipedia.org/wiki/ELIZA).

Also, here some more details on the Chatter Box programs, which ELIZA was one of if not the first to develop this field of computer science, and it still today a valid field worth looking into: https://en.m.wikipedia.org/wiki/Chatterbot

One day someone will produce the original source code (The last time I saw it, the code was stored both on paper tape and those big old 8-inch floppy disks!

One bug - on my iPad Air 2, you only use 1/2 of the screen. Is that because it is coded for iPhones, or is your code for detecting devices and screen sizes not working or not there yet?

Keep working at it, and I'll make some phone calls to some really old friends and past coworkers to see if any of them saved the source code (Boy will some be surprised, as most are retired, some maybe even dead, as only a few I stayed in contact with).

Great work, and I can't wait to see how this develops.

George.


ricardobytes wrote:This program is the closest I have come yet to creating a natural question and answer flow, which can have an unlimited number of questions and responses. The text will continually scroll up to keep the last line above the keyboard. You can reuse previous responses in later questions or comments.

There are some issues still. Let me know any that you notice.

Thanks

Code: Select all

REM Chat Page
REM by ricardobytes
REM October 2016

OPTION BASE 1
GET SCREEN SIZE sw, sh
cr$=CHR$(10)
DIM answer$(50)

' create full-screen field
dl$="dialogue"
FIELD dl$ TEXT a$ AT 1,1 SIZE sw,sh*.45 ML
FIELD dl$ FONT NAME "Courier"
FIELD dl$ FONT SIZE 24
FOR t=1 TO 100
  blank$&=CHR$(10)
NEXT t
blanklen=LEN(blanks$)

a$="*****  OUR CHAT GROUP *****"&cr$&cr$

' read first question
READ temp$
a$&=temp$&cr$&"? "
endfld=LEN(a$)
pg$&=blank$&"limit"

' display it in the field
FIELD dl$ TEXT a$

LOOP:
n+=1
prevend=endfld

' place cursor after the ? Prompt
FIELD dl$ SELECT endfld

loop2:
test$=FIELD_TEXT$(dl$)

' check if user has pressed Enter
IF RIGHT$(test$,1)=cr$ THEN
   a$=FIELD_TEXT$(dl$)
   endfld=LEN(a$)+1
   
   ' extract last answer from field contents
   answer$(n)=RIGHT$(a$,endfld-prevend)
   templength=LEN(answer$(n))
   
   ' trim off the carriage return
   answer$(n)=LEFT$(answer$(n),templength-1)
   templength=LEN(answer$(n))
   
   ' trim off the leading space
   answer$(1)=RIGHT$(answer$(n),templength-1)
   templength=LEN(answer$(n))
   
   IF n = 1 THEN nam$=answer$(n)
   
   ' read the next question
   READ temp$
   
   ' check temp$ for # and replace it with last answer
   templength=LEN(temp$)
   replace=INSTR (temp$, "#")
   IF replace<>-1 THEN
     temp$=LEFT$(temp$,replace-1)&answer$(n)&RIGHT$(temp$,templength-replace)          
   ENDIF
   
   ' check temp$ for ~ and replace it with chatter's name
   templength=LEN(temp$)
   replace=INSTR (temp$, "~")
   IF replace<>-1 THEN
     temp$=LEFT$(temp$,replace-1)&nam$&RIGHT$(temp$,templength-replace)          
   ENDIF
   
   a$&=cr$&temp$&cr$
      
   ' if no more data, then final dialogue is a statement, not a question
   IF DATA_EXIST() THEN a$&="? "
   endfld=LEN(a$)+1
   FIELD dl$ TEXT a$
   
   ' wait for user to press Enter
   ' if no more data then pause, hide keyboard, expand field and end
   IF DATA_EXIST() THEN
     GOTO LOOP
   ELSE
     PAUSE 2
     FIELD dl$ TEXT a$ AT 1,1 SIZE sw,sh ML
     FIELD dl$ FONT NAME "Courier"
     FIELD dl$ FONT SIZE 24
     FIELD dl$ DESELECT
     PAUSE 8
     END
   ENDIF
ELSE
  SLOWDOWN
  GOTO loop2
ENDIF

DATA "What is your name","Hello, #. How long have you been a Forum member","# is a long time. What is your favorite Forum feature","I like # too. What is your most recent program posted","I will have to try # soon. What are your other interests","Those sound like interesting hobbies. What new feature would you like to see in smart Basic","# would be a great feature, ~. What iOS device do you write your programs on","Good choice! It has been nice chatting with you, ~. Goodbye."
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)

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Text on location?

Post by rbytes »

Yes, I remember Eliza, and some of the other programs that imitated it. It was my inspiration to create Chat Page. Another inspiration was seeing the frequent complaints from sB users that they would prefer the sequential input method that most other basics use.

With that type of input, it is dead simple to create a dialogue, because every time you issue an input command with a prompt, they appear below the previous text, ready for the next user response. If the text is about to disappear below the viewable area it scrolls up.

But for some reason Smart Basic was coded so that the input prompt and input field can only appear at the top of the screen. I know some chat pages that only let you input in a field at the bottom of the screen, but to me the best chat format is one where the conversation proceeds down the page, and can be scrolled up and down to see the history.

If you look at my code, you will see the hoops I had to jump through to get the proper flow. A smart Basic field contains just a single string, so that has to constantly be parsed to extract each consecutive answer. The field could occupy the entire screen if it wasn't for one serious limitation. When you place the cursor on a certain line in a field by using a command, the field contents do not scroll up into view if they are hidden by the keyboard. (That would make a great Suggestion for Improvement.)

But the field text will scroll up when it reaches the bottom of the field's window. That's why the window has to fit the space above the on-screen keyboard. If you use an external Bluetooth keyboard, then the field can be made the size of the entire screen. Just before Chat Page ends, I hide the keyboard and resize the field to full screen so that the user can have an unobstructed view of the entire chat.

There are other drawbacks to using a field that I am still working out. If the user clicks the cursor earlier within their current answer to correct the spelling, that causes no problems. But if they then hit return before returning their cursor to the end of their answer, they will split it into two lines, and the input will not be registered!

Clicking the cursor back even earlier in the chat will cause further problems, especially if the user types something there. I'm not sure there are enough commands and parameters available to totally bomb-proof the input. :roll: :shock: :o :lol:
The only thing that gets me down is gravity...

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: Text on location?

Post by GeorgeMcGinn »

I know why it is not working for you.

1) I am using an iPad Air 2, and there are differences in the screen. And I haven't yet added the code to simulate an iPhone.

2) And this is a biggie I have to start testing for – I use an external keyboard exclusively, and I need to start testing for it.

I designed it in landscape mode, and with something like this I will have to lock that in place. And in a real App, you do not display Results at the bottom. Once your screen's data is used in whatever processing, then if you want you can do a TEXT CLEAR and print that from the top of a new screen. Also, I can remove the extra space between fields for iPad users using the virtual keyboards or for iPhone users.

Besides the buttons that I am working on adding, I am actually writing a sample address/contact book application that will have indexes to the files so you can get read the record directly. I am researching whether or not I can rewrite over the old record with the changes made (the program will actually make sure that the record changed before attempting to do this.

This sample will go into the new manual I am writing, the Programmer's Guide that will show more of how the statements work in sample or in this case I am going to give them a real app to view the code.

Also, I can use your help with samples and some writing about them. Like I have yet to get into Graphics or Music. I have been concentrating on screens and files, scope variables, Global vs. Local (there is a trick to make variables truly Global) and I am working on an App for the group that my doctor belongs to. It has close to 200 doctors, 3 labs, two MRI and imaging labs, and they created on the web a patient portal. They said I can build an app but I can't even have access to variables, so I am building a web-browser wrapper around their website, no URL box, when they start the app it takes them directly to the login page, and it will use the website pages as my screens. And they will allow me to sell this to their patients and they are not taking a cut of the profits or some places charge a one-time fee.

Because of my disability, it's difficult to work steady, and they said they have thousands of patients who asked about an App. I plan on selling it for either $1.99 or $2.99.

Anyway, thanks for the input and I will work on detecting virtual keyboards and different devices. So this one sample program can be its own chapter in the programmer guide.

Again, thanks for running it and giving me feedback.

George McGinn
ricardobytes wrote:I tested your code on my iPad Air in both portrait and landscape. In portrait mode, it works perfectly. In landscape mode, the text still scrolls up, so that it is ambiguous which field should be entered. I tried removing the print 4 lines function, and then the text stayed put when the program ran in landscape.

If text is printed within one line's distance from the keyboard, it is automatically pushed up to maintain a bottom margin of one line space. So you would get different results on different devices. Setting toolbar off would give a bit more print space above the kb
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)

Post Reply