|
Post by factor23 on Mar 27, 2016 8:21:27 GMT 1
Hello,
I have imported a program developped in GFABASIC With Atari ST, and I have a problem with Input instruction.
When I use an input with several variables separed by comma and enter value separed also by comma before <Enter> key, only the first value is taken and request with a ? is displayed for the following data.
I have seen this in the documentation of Input command.
Is there a solution ?
Jean-Jacques
|
|
|
Post by dragonjim on Mar 28, 2016 14:44:59 GMT 1
Hi,
If I understand you question correctly, you are having problems using the INPUT command with more than one variable to be input. That is odd as this behaviour is supported in GB32 as shown in the following example:
OpenW 1 Local a$, a%, b$ Local Double x, y HTab 10 : VTab 9 Print "First Name:"; : Form Input 20 As a$ HTab 10 : VTab 10 Line Input "Surname:", b$ Print AT(40, 20); Input "Enter two numbers: ";x, y Print a$`b$`x`y Do : Sleep : Until Win_1 Is Nothing
When you get to the line Input "Enter two numbers: ";x, y then one input box should appear to the right of the text and then, once you have pressed 'Enter', another box should appear at the start of the next line.
GFABASIC32 offers only limited support for the old INPUT command and, sadly, the help file is incorrect when it states: "It is also possible to separate individual variables in the list with commas and confirm them all with one single press of the <Return> or the <Enter> key." - this was copied from the original German help file so should be correct, but isn't, and should have been removed from the literature (I shall add it to my list).
As a replacement, you could always enter your multiple values as a string and split them up according to where the commas are placed in the inputted variable, as in the example below:
Local a$, p As Int32, x As Double, y As Double Input "Enter two values:";a$ p = InStr(a$, ",") If p = 0 // No commas x = Val(a$) Input "...and the second value:";y Else x = Val(Left(a$, p - 1)) y = Val(Mid(a$, p + 1)) EndIf Print x, y
I hope that is of some help.
|
|
|
Post by factor23 on Mar 29, 2016 16:51:48 GMT 1
Hej,
Thank you for your reply and your solution.
I have writen a procedure to replace input "a,b : ",a,b with InputBox (I display the text and the input values )
Proc entree(t$, ParamArray p()) Local h As Hash String, s As String, l$, i = LBound(p()) l$ = InputBox(t$) Split h[] = l$, "," For i = LBound(p()) To UBound(p()) DblPoke p(i) , Val(h[% i + 1]) Next i Print t$; " : "; l$ End Proc
it is called in the program like this : entree("a,b",*a,*b) number of arguments is variable.
I have try an other solution also but I was obliged to do a shift of 12 (length of input box ) to display input values after the text.
Proc entree(t$, ParamArray p()) Local h As Hash String, s As String, l$, i = LBound(p()) Print t$; cc = CrsCol Line Input l$ Split h[] = l$, "," For Each s In h[] DblPoke p(i) , Val(s) Inc i Next s Print AT(cc + 12, CrsLin - 1); l$ End Proc
Jean-Jacques
|
|
|
Post by dragonjim on Mar 30, 2016 13:43:35 GMT 1
Hi,
An excellent workaround - much more direct (low-level) and flexible than mine when dealing with 16-bit integers. Could I use it as an example in the help file?
|
|
|
Post by factor23 on Mar 30, 2016 16:32:24 GMT 1
Hej, Thank you for your comment. You can use it in the help file Jean-jacques
|
|