Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SquiderDragon

macrumors newbie
Original poster
Dec 29, 2022
2
0
I have the Smart Basic app on my iPad and trying to port and older basic program I wrote years ago to work on iPad. It is basically a text adventure game with different options so the user interface needs to provide the ability to receive text input via the keyboard.

The support help for the app suggests INKEY$() ‘returns output from physical keyboard. This command I am familiar with however it goes on to say Physical keyboard support should be turned on (OPTION KEYBOARD ON command) for this function to operate.

My Q therefore is in Smart Basic what is the correct syntax to code this?

Here is an example I would like to code for a simple Y/N selection option as follows :-

OPTION KEYBOARD ON

DIM IN$(1)
IN$(1) = INKEY$()
IF IN$(1) <> "" THEN
PRINT "Hello Mum"
ENDIF
IF ASC(IN$(1))> 90 THEN
IN$(1)= CHR$(ASC(IN$(1)) - 32)
ENDIF
IF IN$(1) = "Y" THEN
RETURN
ENDIF
IF IN$ (1) = "N" THEN
RETURN
ELSE
PRINT "No Y/N selected"
END IF
REM ENDP ynsel

It’s not clear how the statement INKEY$() should work as I receive this syntax error

Index array is out of bounds

IN$(1) = INKEY$.()

If anyone could provide a corrected example I would appreciate it as all the subroutines I previously coded should all work in the same way if I can understand the syntax rules of Simple Basic for iPad.

Regards

David S
 
I have the Smart Basic app on my iPad and trying to port and older basic program I wrote years ago to work on iPad. It is basically a text adventure game with different options so the user interface needs to provide the ability to receive text input via the keyboard.

The support help for the app suggests INKEY$() ‘returns output from physical keyboard. This command I am familiar with however it goes on to say Physical keyboard support should be turned on (OPTION KEYBOARD ON command) for this function to operate.

My Q therefore is in Smart Basic what is the correct syntax to code this?

Here is an example I would like to code for a simple Y/N selection option as follows :-

OPTION KEYBOARD ON

DIM IN$(1)
IN$(1) = INKEY$()
IF IN$(1) <> "" THEN
PRINT "Hello Mum"
ENDIF
IF ASC(IN$(1))> 90 THEN
IN$(1)= CHR$(ASC(IN$(1)) - 32)
ENDIF
IF IN$(1) = "Y" THEN
RETURN
ENDIF
IF IN$ (1) = "N" THEN
RETURN
ELSE
PRINT "No Y/N selected"
END IF
REM ENDP ynsel

It’s not clear how the statement INKEY$() should work as I receive this syntax error

Index array is out of bounds

IN$(1) = INKEY$.()

If anyone could provide a corrected example I would appreciate it as all the subroutines I previously coded should all work in the same way if I can understand the syntax rules of Simple Basic for iPad.

Regards

David S

The array IN$ is declared in line 1 with a length of 1 (DIM IN$(1)).
In most computer languages arrays are zero based. That means the count starts with 0 and not with 1. I don't know this particular smart basic dialect, but I assume it is the same there.

Assigning IN$(1) a value points to the second place in the array which generates an error, because the array can only hold 1 element.
If you change line 2 to IN$(0) = INKEY$(), this wil likely solve the problem. You need to change all the lines with IN$(1) after that to IN$(0) also.
 
Last edited:
Yes this is the app. I still cannot get input$() to work. I am using the input$ () to work that creates a prompt for input. I however with struggling however with labels as label: with an alpha reports syntax so it’s not clear how Gosub is supposed to work with e.g return. I should be able to recode but without and understanding of the loops and returns it is probably going to be fruitless. I also was used to coding CLS to clear the screen many times but again this or it’s equivalent I cannot see. The help seems comprehensive enough but the examples referred to I cannot get working. Thanks for the reply. The forum too mentioned just links to an all foreign series of unreadable foreign text so no help via that route is possible. Thanks for the response and any help. I did find this app does refer to itself as smart basic but maybe a marketing ploy as it appears to be coded by the app developer.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.