User input in a matlab GUI - user-interface

Hey all,
I am building a gui in wich there is an edit box, waiting for the user to write a name.
Currently I force the user to give a legitimate name with this code :
NewPNUName = get(handles.nameOfNewPNU, 'String');
if ( isempty(NewPNUName) ||...
strcmp(NewPNUName,'Enter the name for the new PNU') )
errordlg('Please enter a name for the new PNU.');
elseif (~ischar(NewPNUName(1)))
errordlg('The PNU name should start with a letter.');
else
handles.NewPNUName = NewPNUName;
end
if (~isempty(handles.NewPNUName))
% Do all the things needed if there is a legit name
end
What it does is nothing if the user didn't write a legit name.
What I want it to do is to make a popup with an edit box, asking the user to input the wanted name again, until it is a legitimate name.
Thanks for the help!
EDIT:
following #woodchips advice I corrected my code to the foloowing:
NewPNUName = get(handles.nameOfNewPNU, 'String');
ValidName = ~isempty(NewPNUName) && isletter(NewPNUName(1)) &&...
~strcmp(NewPNUName,'Enter the name for the new PNU');
while (~ValidName)
if ( isempty(NewPNUName) ||...
strcmp(NewPNUName,'Enter the name for the new PNU') )
NewPNUName = char(inputdlg('Please enter a name for the new PNU.','No name entered'));
elseif (~isletter(NewPNUName(1)))
NewPNUName = char(inputdlg('The name of the new PNU should start with a letter. Please enter a new name',...
'Invalid name entered'));
else
allConds = 'are met'
end
ValidName = ~isempty(NewPNUName) && isletter(NewPNUName(1)) &&...
~strcmp(NewPNUName,'Enter the name for the new PNU');
end

So, put a while loop around a block of code, that generates an inputdlg box. Set the condition on the while loop to be that the result is a valid one.

Related

Not able to update the tester name in a Test Set from vbscript

I am been trying to search online for a solution but due to lack of knowledge in HP ALM I am not able to search proper hit tags
Set RunFactory = tsTest.RunFactory
Set obj_theRun = RunFactory.AddItem(CStr(testrunname))
obj_theRun.Status = sExecutionStatus '"Passed" '-- Status to be updated
obj_theRun.Tester = strTesterName
Getting error in this line object does not support obj_theRun.Tester
I just want to update the Tester column(Not Responsible tester) in Test set via vbscript. Please refer to the attached image at the very last column (TesterAny help is appreciated. Thank you in advance.
The documentation for ALM says the Tester Name can be specified by passing an array as the argument to AddItem.
https://admhelp.microfocus.com/alm/api_refs/ota/Content/ota/topic8805.html?Highlight=tester
An array consisting of the following elements:
Name - The name of the run (string. required).
Tester - The name of the user responsible (string. optional)
Location - The host name (string. optional). The default is the host name of the current machine
So change your code to this:
Set runFactory = tsTest.RunFactory
Dim newRunArgs(3)
newRunArgs(0) = testrunname ' `testrunname` is already a string so you don't need CStr.
newRunArgs(1) = "tester name goes here"
Set newRunArgs(2) = Nothing
Set newRun = RunFactory.AddItem( newRunArgs )
newRun.Status = sExecutionStatus '"Passed" '-- Status to be updated

How to check whether a file contains "." (dot) operator

I have a code which asks user to upload a file. The file may be audio or image or anything. I asks user to enter file name. If he Enter file name my code adds extension to it. It is working fine. But if user enters extension say audio.mp3 then it saves as audio.mp3.mp3. So I have to check if user entered name contains dot then it should not take extension.
I used pregmatch but it is not working.
My code
$splitOptions = explode(',',$request->input('mediaName'));
$fileExtension = pathinfo($file[$i]->getClientOriginalName(),PATHINFO_EXTENSION);
$checkExtension = explode('.',$request->input('mediaName'));
if(preg_match("/[.]/", $checkExtension)){
$mediaName = $splitOptions[$i];
}
else
{
$mediaName = $splitOptions[$i]."_$fileExtension";
}
Please use laravel helper
$value = str_contains('This is my name', 'my');
// true

Python winappdbg getting process name from event object

I'm developing a debugging automation system using https://github.com/MarioVilas/winappdbg.
I would like to retrieve process name from event object. Here is my code:
def EventHandler(event):
print 'Inside event handler'
# I want to print the process name here, In this case which should be somefile.exe
debug = Debug( EventHandler, bKillOnExit = True )
proc = debug.execv(['c:\somefile.exe','arg'])
debug.loop()
The tool author answered my question on github : Here is the solution
We can do event.get_process().get_filename(), or if we want to be more fancy:
process = event.get_process()
name = process.get_filename()
print "Process: %s" % name

How do I keep a value within QLineEdit to retain its value after program is closed?

I am using Qt Ruby
How do I keep the value of a user entered QlineEdit to keep its state even after the program is closed, in that way, the user can access the contents the next time he opens the program.
Solution 1 - using File.write/read:
edit_widget = Qt::LineEdit.new(parent)
File.write(filename, edit_widget.text)
exit
After the program re-start:
text = File.read(filename)
edit_widget.setText text
Solution 2 - using QSettings:
settings = Qt::Settings.new(filename, Qt::Settings::NativeFormat)
edit_widget = Qt::LineEdit.new(parent)
edit_widget.text = "abcde"
settings.setValue("field1", Qt::Variant.fromValue(edit_widget.text))
settings.sync
exit
After the program re-start:
settings = Qt::Settings.new(filename, Qt::Settings::NativeFormat)
edit_widget = Qt::LineEdit.new(parent)
edit_widget.text = settings.value("field1").toString

Password Changer using VAccess

Hey I am working on a password changer. User logs in ( successfully), loads a global var with user initials, then launch a password expired form. I try and use those initials on the password expired form to retrieve user info from DB.
vaUserLog.FieldValue("USERINIT") = UserInitials
vaUserLog.GetEqual
vaStat = vaUserLog.Status
vaStat keeps giving me an error of 4. I am using pervasive v9. Connection with VA looks like:
With vaUserLog
.RefreshLocations = True
.DdfPath = DataPath
.TableName = "USERLOG"
.Location = "USERLOG.MKD"
.Open
If .Status <> 0 Then
ErrMsg = "Error Opening File " + .TableName + " - Status " + str$(.Status) + vbCrLf + "Contact IT Department"
End If
End With
In DB table, USERINIT is Char, 3. UserInitials is a String.
Probably missing something small but can't think right now. Any help is appreciate. Lemme know if you require more info.
Cheers
Status 4 means that the record could not be found. In your case, it could be the case of the value being searched is wrong, there's a different padding (spaces versus binary zero), or that the UserInitials value just isn't in the data file.
You can use MKDE Tracing to see what's actually being passed to the PSQL engine. Once you've done that, make sure the value you're using works through the Function Executor where you can open the file and perform a GetEqual.
Here are my suggestions:
- Make sure you're pointing to the right data files.
- Make sure you're passing the right value into the GetEqual (by setting the FieldValue).

Resources