Any way to supply a default input when using INPUT

Blitz3D Forums/Blitz3D Beginners Area/Any way to supply a default input when using INPUT

hollifd(Posted 2016) [#1]
Is there a way to provide a default answer when using an INPUT box?

Like: Ans$ = input("What is your name?", "David")

Example output:
What is your name? David


RustyKristi(Posted 2016) [#2]
Ans$ = Input("What is your name?")

valid = Len(Ans$)

If valid Then
	Name$ = Ans$
Else
	Name$ = "David"	
End If

Print "Hello, " + Name$
WaitKey


You can make a function using that.


RustyKristi(Posted 2016) [#3]
Try this:


g$ = inputx("What is your name?","David")

Print "Hello, " + g$

WaitKey

End

Function inputx$(label$,def$,minchar = 5)
	Ans$ = Input(label$)
	valid = Len(Ans$) 
	If valid >= minchar Then
		Name$ = Ans$
	Else
		Name$ = def$
	End If
        Return Name$

End Function


You can set a minimum number of characters like this: inputx("Name?","David",3) or just change 5 in minchar to your default


hollifd(Posted 2016) [#4]
What I was trying to do is supply an answer for the user and if that answer is what the user wants, then just hit the enter key to accept it.

In Visual Basic you can do something like the following...

Prompt$ = "What is your name?"
Title$ = "Answer the question..."
Default$ = "David"

Ans$ = InputBox(Prompt$, Title$, Default$)

When you run this code, you get an inputbox with a prompt, title, and "David" prefilled in. If this is what the user wants, then he can just click the OK button.

Is there a way to supply an answer to the "INPUT" command in Blitz? I am thinking there is no way to duplicate the visual basic Inputbox functionality.

In my example, I would want "David" to appear on the screen and if that is the user's name, then he would just hit enter to accept it. I know my example doesn't actually make sense but still I am looking for a way to supply an answer to the user and let the user accept it or type a new answer.


RustyKristi(Posted 2016) [#5]
I think you can do this with WinBlitz3D if you're ok with a GUI app. Console should work too maybe by auto-filling the name in input prompt.

Not sure if the download links works here http://www.blitzbasic.com/Community/posts.php?topic=67339

but search for WinBlitz3D


hollifd(Posted 2016) [#6]
Thanks. I am feverishly trying to create a pressbrake simulation program for my team at work so I'll continue on with Blitz3D for the moment but may circle back at some point to investigate WinBlitz3D as I am struggling with a good User Interface for my program. I have yet not come up with any really good ways to get information from the user. My current strategy is to create a small text file containing the information that I want to get from the user, pop open the text file, let the user change/add anything they want and then read that text file back in. Don't laugh too much!


RustyKristi(Posted 2016) [#7]
WinBlitz3D is very similar to VB's forms afaik. If you have experience in VB then I think it will be easy to make the transition.

If you need a 3d window gadget inside a windows form then you need to use BlitzPlus and B3D at the same time, disregard WinBlitz3D as blitzplus already has this feature. I should note that the method is sort of a hack and you can search the code in archives or forum.

If you need a clean solution, just use BlitzMax with MaxGUI (Winforms) and either OpenB3D or MiniB3D. Example already provided inside mod package.


hollifd(Posted 2016) [#8]
Ok and Thanks.


Matty(Posted 2016) [#9]
Yes you can duplicate the inputbox functionality.....you just have to build it all yourself and most likely without using the input command. Blitz kind of requires for some of these things a lot more work from the developer because it is more aimed at collecting individual keystrokes as in a game with scancodes....but it can be done....just requires you to build it from scratch yourself.