It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to check my item to became unique in my database and the item exist in the databasemit must be clear(this item).
So I use trigger when-validate-item for this item and trigger when-timer-expired for the form global.
This is my code :
//trigger when-Validate-item :
declare
i number;
vTimer TIMER;
begin
IF //condition then
i := show_alert('ERROR');
/* Create a timer with a 10 Millisecond delay */
vTimer :=create_timer('TEMP',10,no_repeat);
END IF;
end;
//trigger when-timer-expired
GO_BLOCK ('name_block');
:name_block.item1:=NULL;
DELETE_TIMER('TEMP');
But in runtime, I get this error:
FRM-40202 Field must be entered
to enforce uniqueness, you should use a unique constraint on the table.
to clear the item, you can just assign NULL to it in your w-v-i trigger, you don't need a timer; but this is not recommended because it is likely to confuse and irritate your users.
you're probably getting FRM-40202 because your timer tries to navigate away from the item which is marked as Required.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Given this Hash:
myXML = {:_id=>BSON::ObjectId('51ad8d83a3d24b3b9f000001'),
"Comment"=>nil,
"Line"=>
[{"LineNumber"=>"3.1",
"Item"=>"fruit-004",
"Description"=>"Peach",
"Quantity"=>"1",
"UnitCost"=>"1610",
"DeclaredValue"=>"0",
"PointValue"=>"13"},
{"LineNumber"=>"8.1",
"Item"=>"fruit-001",
"Description"=>"Fruit Set",
"Quantity"=>"1",
"UnitCost"=>"23550",
"PointValue"=>"105",
"PickLine"=>
[{"PickLineNumber"=>"8.1..1",
"PickItem"=>"fruit-002",
"PickDescription"=>"Apple",
"PickQuantity"=>"1"},
{"PickLineNumber"=>"8.1..2",
"PickItem"=>"fruit-003",
"PickDescription"=>"Orange",
"PickQuantity"=>"2"}]}],
"MemberId"=>"A00000001",
"MemberName"=>"Bruce",
"DeliveryId"=>"6377935",
"ShipToAddress1"=>"123-4567",
"OrderDate"=>"05/08/13",
"Payments"=>
[{"PayType"=>"Credit Card", "Amount"=>"1000"},
{"PayType"=>"Points", "Amount"=>"5390"}]}
I'm able to remove the key/value pair with "Comment" key that has nil value with the code:
myXML.each do |key, value|
myXML.delete(key) if myXML[key] == nil
end
I believe there's a much better way to do this with less code in Ruby.
Does the following code work as you expect?
myXML.delete_if{|key, value| value.nil?}
This is not appropriate of course if you intend to delete recursively.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
If I wanted to use a Try-Catch for a char and to make sure that it wouldn't have the program run when I typed in a numeric value how would I do that in visual basic? Example of a small snippet of code would be great.
You should not use a Try/Catch for normal program control flow. Exceptions are for just that: exceptional circumstances you do not expect to occur normally.
Rather than use an exception to blow up when a character contains a numeric, prevent it being stored
in the first instance.
A good way to achieve this is by adding a KeyPress handler.
Here's an example of a KeyPress handler that allows only Numerics and backspace (it's in C# but it is easy to convert to VB.NET):
private void txtTimeout_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b');
}
Set KeyPressEventArgs.Handled to true to cancel the KeyPress event.
This keeps the control from processing the key press.
There are further examples here and on StackOverflow.
Private Sub textBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) _
Handles textBox1.KeyPress
' Determine what is a valid key press
If Char.IsNumber(e.KeyChar) = True Then
' Stop the character from being entered into the control since it is numeric
e.Handled = True
End If
End Sub
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have the following code:
def test_compare()
if true
condition = true
else
condition = false
end
assert_equal(true, condition)
end
In Ruby, variables inside of an if block have the same scope as variables declared outside of the if block according to "I don't understand ruby local scope".
Is it common practice to initialize variables inside of a control structure without first declaring them or initializing them outside of a control structure?
Coming from a Java.NET background this seems to make the code less readable and more prone to logic mistakes.
I am doing my best to "not write .NET code in Ruby", but want to understand why the above makes more sense than declaring scope variables at the beginning of the scope, or outside of the control structure.
if returns value. It's cleaner to use this behaviour.
x = if condition
# several lines of calculations can be here
'true value'
else
# several lines of calculations can be here
'false value'
end
Or, in this concrete case it's better to use ternary operator. It does the same thing and is shorter.
x = condition ? 'true value' : 'false value'
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Here's what I am trying to do: The user enters a string. The string contains 2 parts and will look like this:
{EventClass: someMethod=>arg1, arg2, arg3....}, {Action: someMethod=>arg1, arg2, arg3....}
A concrete example of this would be:
{TwitterEvent: newTweet=>arg1, arg2, arg3....}, {PersistenceAction: saveToHardDrive=>arg1 arg2...}
Then I will parse this string, instantiate an instance of TwitterEvent, call that method on it. Then do the same thing for PersistenceAction
What the best "design" for this type of application? How would I dynamically instantiate classes from parsed string and then call method? And potentially, the method will have arguments? How would I detect/handle errors?
Get class object from name string:
Kernel.const_get('TwitterEvent')
Invoke arbitrary method on object:
event.send(:new_tweet)
The rest is up to you. :-)
You want to use respond_to? and send . Send allows you to invoke a method using a symbol. You can use to_sym to convert a string to a symbol.
Here you go
str = "{TwitterEvent: newTweet=>arg1, arg2, arg3}, {PersistenceAction: saveToHardDrive=>arg1, arg2}"
regexp = /^{(\w+):\s*(\w+)=>([^}]+)},\s*{(\w+):\s*(\w+)=>([^}]+)}$/
regexp.match(str).to_a[1..-1].each_slice(3) do |s|
# s[0] .. class name
# s[1] .. class method
# s[2] .. method parameters as a single string
# do something similar to Sergio Tulentsev suggestion
end
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
"true"? "Yes" : "No" , I am using ruby language
This is taking by deafult "yes" even I select "no"
value = condition ? value-if-true : value-if-false
is a shortcut for this
if condition == true
value = value-if-true
else
value = value-if-false
If you have a condition that is always evaluated as true, you will always have value-if-true. In the example code "true" is always a true expression. The only values which are treated as false in an expression are false and nil.
It's a little hard to tell what you're taking, but the value "true" is a string. For the boolean value, you want just true, with no quotation marks.