Originally posted by James C Morgan
View Post
Announcement
Collapse
No announcement yet.
InputBox$ and the cancel button
Collapse
X
-
-
Each section has a "+ New Topic" button.
In the Samples\DDT\FileFind directory where PB is installed is code to search for a file. That can be modified for the second dialog.
(copy the files before changing, the samples will stay original)
Cheers,
Leave a comment:
-
I need some help to create a dialog like window so I can add 2 textboxes
to find a file name and then search within that file
I would like to have a second dialog popup called from the first dialog or inputbox$
i could not find a place to start a new topic
thanks
James Morgan
Leave a comment:
-
I think it's equal.
VERIFY giveth position of offending character and does not require explicit MID$/ASC code; VERIFY taketh away what seems more natural to me:
Code:IF ISTRUE VERIFY (myString, "0123456789") THEN MSGBOX "All characters of mystring are numeric digits" .....
MCM
Leave a comment:
-
Originally posted by Michael Mattias View Post>validates a "numbers only" setting
(...)
The PB VERIFY function is kind of funky... it returns FALSE (zero) on a "good" verification. Probably why it's often overlooked for this kind of editing.
(...)
The "plus offset" is, you get the position of the first offending character.
(...)
So, I do not exactly understand your message. Did you just want to point me to an equal-worthy alternative or to a "far better solution"?
Leave a comment:
-
>validates a "numbers only" setting
Code:IF ISTRUE(iNumerals) THEN ' flag "digits only" is set FOR iPos = 1 TO LEN(sResult) SELECT CASE AS LONG ASC(sResult, iPos) CASE < 48, > 57 ...
Code:IF Istrue (iNumerals) THEN IF ISTRUE VERIFY(sResult, "0123456789") THEN ...
The PB VERIFY function is kind of funky... it returns FALSE (zero) on a "good" verification. Probably why it's often overlooked for this kind of editing.
The "plus offset" is, you get the position of the first offending character.
Or, in COBOL....
Code:IF sResult IS NOT NUMERIC THEN ...
Leave a comment:
-
Safe wrapper in SC forum now
Given some incertainties throughout this thread, especially in respect with the cancel button, I've tried to create a "safe" wrapper for Power Basic's INPUTBOX$ function. Although it is a string function, my wrapper function also validates a "numbers only" setting.
You'll find it here: http://www.powerbasic.com/support/pb...221#post306221
Leave a comment:
-
LATER: Sorry, didn't read the help file very well. It is documented. See: ASC in Keyword Reference.
Leave a comment:
-
Originally posted by Dave Biggs View Post"If the string passed is null (zero-length) or the position is zero or greater than the length of the string, the value -1 is returned".
Apart from that, a zero-length string obviously returns ascii -1. That's exactly what I said in my previous message. What I want to know is whether it's a documented feature or not.
LATER: Sorry, didn't read the help file very well. It is documented. See: ASC in Keyword Reference.
Leave a comment:
-
Code:sResult = "" MsgBox "Ascii code: " & FORMAT$(ASC(sResult)), 64, "Test Ascii code"
Leave a comment:
-
Empty string with ascii code -1?
Originally posted by Fred Harris View PostIt seems the InputBox$ function returns an empty string
when the Cancel button is clicked, even if a default string
is in the entry field. (...)
Code:' run this code and press the Cancel button to see that an empty string ' returns an ascii value of minus one #COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG LOCAL sResult AS STRING sResult = INPUTBOX$("First Name", "Test Inputbox$", "Egbert") MSGBOX "String content: " & sResult & $CRLF & _ "String length: " & FORMAT$(LEN(sResult)) & $CRLF & _ "Ascii code: " & FORMAT$(ASC(sResult)), 64, "Test Inputbox$" END FUNCTION
Leave a comment:
-
if cancel or the x to close, causes the returned string to be nothing.
Maybe that should be called an "initial" value instead of a "default" value.
Regardless, this behavior should documented.
Leave a comment:
-
You are right. Dummy me staring at the same block of code so long that until
I came home and took a break, it was then obvious that if cancel or
the x to close, causes the returned string to be nothing.
My other problem was a check to verify that the value of the string would not be
zero (and obviously the value of nothing is zero)
Thanks to all
------------------
Leave a comment:
-
It seems the InputBox$ function returns an empty string
when the Cancel button is clicked, even if a default string
is in the entry field. That makes sense kind of. Just tried
it with my code above.
------------------
Fred
"fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"
Leave a comment:
-
If you need to know if he canceled rather than simply 'did not changed the default,' perhaps INPUTBOX$ is not the optimal choice of functions here.
Code:Prompt [editable default] <OK> <Cancel>
Leave a comment:
-
Just tried this and it seems to work
Code:#Compile Exe #Dim All Function PBMain() As Long Local strText As String, strResult As String strText="December" strResult=InputBox$("Enter A Month",,strText) If Len(strResult) Then MsgBox("User Entered " & strResult) Else MsgBox("User Cancelled!") End If PBMain=0 End Function
Fred
"fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"
Leave a comment:
-
Cliff,
Couldn't you just compare the default string before and
after? If it isn't the same, then the user changed something.
If it is the same, perhaps he hit cancel. Havn't tried it,
that's just my guess.
------------------
Fred
"fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"
Leave a comment:
-
InputBox$ and the cancel button
This should be simple but I can find no information via search or in POFFS
If I use an inputbox$, how do I know if the user pressed the cancel button?
(Checking the length of the string is no good because I set a default value)
Do I have to make my own custom input dialog so that I can check which button was pressed?
should be a simple answer, but I am guessing I will have to go custom?
------------------
Tags: None
Leave a comment: