Left most processing in Crystal reports - crystal-reports-2008

We have a data column, that if the first 2 are alpha and the last is alpha, and the 3-7 are numerical, that is what we want. If this is not the case,then we want to display a blanks.
For now if i can get just the first letter as alpha (from what i have seen either its' good or its not) for testing just the first is ok. but this is not compiling.
left({vwGenPatInfo.Prim_Policy_Certificate_No},1) in ["A" to "Z"] then ({vwGenPatInfo.Prim_Policy_Certificate_No})
else ' '

use isnumeric
Check for Numeric Value in Crystal Reports
if isnumeric(field) = 0 then "not numeric"
else "numeric"

Related

If results are not >= "Number" then show blank

New to building Crystal Reports and SQL.
I'm trying to write a script to where if results is >= 12.1 then show result else show no results.
Same goes for the <=9.9.
Here is what I have so far:
if {Test.Name} = "xyz" and {TestResults.numresult}>= 12.1 then {TestResults.numresult} else "";
Below is an image showing the same results across the board. I just want the results to show when its <=9.9 or >=12.1.
Hope this make sense.
Your statement returns a number from one branch and a string from the other. It must return the same data type.
One option is to use a True/False expression in a Suppress expression.
Another option is to return a zero in the other branch and use number formatting to suppress if zero (it's a built-in option for numbers).
Another option is to modify your expression so it returns a string from both branches. For example:
if {Test.Name} = "xyz" and {TestResults.numresult}>= 12.1 then ToText({TestResults.numresult}, 1, ",") else "";
The 1 argument requests 1 decimal point. The "," argument requests a comma as thousands separator. You can adjust those to match your number formatting requirements.

Autocad Diesel IF expression for sheet number tag

I am trying to automate a sheet tag with a Diesel expression in AutoCad.
This gets me the twelfth character in the drawing name. But as soon as I get to sheet 10 this will say its sheet 0.
$(substr,$(getvar,dwgname),12,1)
Does anyone know a way to get an If statement to see if the eleventh character is a 0 then run the above code else run $(substr,$(getvar,dwgname),11,2)
This is something i have tried.
$(IF,substr,$(getvar,dwgname),11,1)="0"$(substr,$(getvar,dwgname),11,2,substr,$(getvar,dwgname),12,1)
This appears to be similar to excel formulas. Thanks for any help.
The format for the Diesel if statement is:
$(if, expr, dotrue [, dofalse])
If the expr is nonzero, it evaluates and returns dotrue.
You seem to have a lot more going on in your sample. Do the full evaluation (does the 11th character equal 0 in the expr portion and then set your returns, the false portion is optional and can be omitted.
Here is the Diesel expression i got working for auto sheet no. in autocad fields.
$(if,$(substr,$(getvar,dwgname),11,1)"0",$(substr,$(getvar,dwgname),11,2),$(substr,$(getvar,dwgname),12,1))
$(if,$(substr,$(getvar,dwgname),11,1)"0" = Does character 11 = 0
,$(substr,$(getvar,dwgname),11,2) = if no then take character 11 and the next char.
,$(substr,$(getvar,dwgname),12,1)) = if char 11 is = to 0 then take only char 11.
I use two fields in my autocad border. One for the filename without the sheet no and this one for only the sheet number.
Example filename: A150225_S001.dwg
$(substr,$(getvar,dwgname),1, 7) = Use char from position 1 to 7. "A150225"
$(if,$(substr,$(getvar,dwgname),11,1)"0",$(substr,$(getvar,dwgname),11,2),$(substr,$(getvar,dwgname),12,1)) = Use sheet no. at end of filename string. "1"
Hope this helps anyone looking to do something similar.

how to check whether the string taken through gui is a binary string in matlab?

I am working on a watermarking project that embeds binary values (i.e 1s and 0s) in the image, for which I have to take the input from the user, and check certain conditions such as
1) no empty string
2) no other character or special character
3) no number other than 0 and 1
is entered.
The following code just checks the first condition. Is there any default function in Matlab to check whether entered string is binary
int_state = get(handles.edit1,'String'); %edit1 is the Tag of edit box
if isempty(int_state)`
fprintf('Error: Enter Text first\n');
else
%computation code
end
There is no such standard function, but the check can be easily implemented.
Use this error condition:
isempty(int_state) || any(~ismember(int_state, '01'))
It returns false (no error) if the string is non-empty and composed of '0's and '1's only.
The function ismember returns a boolean array that indicates for every character in int_state whether it is contained in the second argument, '01'. The advantage is that this can be generalized to arbitrary sets of allowed characters.
I think the 2nd and 3rd can be combined together as 1 condition: your input string can only be a combination of 0 and 1? If it is so, then a small trick with findstr can do that:
if length(findstr(input_str, '1')) + length(findstr(input_str, '0')) == length(input_str)
condition_satisfied;
end
tf = isnumeric(A) returns true if A is a numeric array and false otherwise.
A numeric array is any of the numeric types and any subclasses of those types.
isnumeric(A)
ans =
1 (when A is numeric).

struggling with my pseudocode

I'm about to build a program written in pseudocode. I've already done most of the work , but I'm stuck on the code and I don't know what to do exactly. im a begginer and not everything is clear to me ...in one of the tasks i have to do , i have to make the program ask for the players name , which will be stored as a string then the program has to check if it exceeds the limit between 2/20 characters and inform the user if the input is wrong . i have researched and tried to figure out how i might be able to fix my code but i have a really short amount of time left and coudn't find anything regarding my problem :/ . this is the code ive done for this specific task. i know its wrong but i just dont know how to fix it . any help with be much appreciated . Thanks in advance :)
pseudocode:
// Getting user's name
valid = false
loop until valid is equal to true
Output" please enter your name "
Input playName
If (playName is => 1)AND(=<20)then
Valid = true
Otherwise
output "name exceeds the character limit"
I'm not sure what the syntax of your pseudo code is but :
assuming tabulation has meaning, you may have forgot to indent some lines to include them in the loop
'valid' is first declared with a lower case first letter so you may continue referencing it same way in line "Valid = true" -> "valid = true"
In the 'If' you want to test the lenght of the String and not compare the string to an int so maybe call a function length(String) that would return the length of the string or access a string.length attribute (as you wish in pseudo code)
You want the playName to be superior or equal to 2 "length(playName) >= 2" and inferior or equal to 20 "length(playname) <= 20"
The commonly used keyword meaning Otherwise is 'Else' as in
IF (Condition) THEN (code) ELSE (code)
I may modify you code like this :
// Getting user's name
valid = false
loop until valid is equal to true
Output" please enter your name "
Input playName
If (length(playName) >= 2) AND (length(playName) <= 20)
Then
valid = true
Else
output "name exceeds the character limit"

Check for dates consistency in MATLAB

Is there any straight forward way to do that? I want to give an array of dates as an input (for example 1997-01-02 1997-01-03... using the format yyyy-mm-dd) and get 1 if all the elements of the given array are consistent and 0 otherwise.
Any idea?
Here is one idea:
d = {
'1997-01-02'
'1997-01-03'
'1111-99-99'
'not a date'
}
isDateValid = false(size(d));
for i=1:numel(d)
try
str = datestr(datenum(d{i},'yyyy-mm-dd'),'yyyy-mm-dd');
isDateValid(i) = isequal(str,d{i});
catch ME
end
end
The result:
>> isDateValid
isDateValid =
1
1
0
0
The reason I do the conversion back and forth is that MATLAB will carry values outside the normal range of fields to the next one -- third example will actually be parsed as: 1119-06-07. While the last one will throw an exception
Many ways to do this using regexp. A couple of simple ones:
str = '1917-01-23';
regexp(str,'\d\d\d\d-\d\d-\d\d')
ans =
1
If the string matches exactly that pattern, you will get 1, else empty.
Or do this:
regexp(str,'-','split')
ans =
'1917' '01' '23'
Now you can verify the first piece is a valid year, the second a valid month, etc.

Resources