Getting numbers separate from letters from a field in Crystal Reports SAP when the format changes - crystal-reports

I'm sorry if this has already been solved, I cant seem to find anything for my specific issue.
We have job numbers that use the following formats: 011111, 11111A, and 11A111. For all of these, I need to export to a new field that just reads 11111. I know I can use right({table.job},5) for the first, left({table.job},5) for the second, or even val({table.job}) but I can not find anything that works to get just the numbers out of the last format.
I have tried using val({table.job}) but it only gives me the first set before the letter. I have tried using the join function and using left 2 + right 3, but I'm still new to this and I'm not certain that I have been using the correct syntax.
I also tried using an array to find the third character to see if it was a specific letter, but it is not accepting the code, and I scrapped it.
When I typed all of it out, I kept getting the error "The ) is missing" but no words were highlighted and I have double checked the opening and closing parenthesis. I know it might be something simple, but I am stumped. Any ideas?

Here's one possible solution:
local stringvar JobN := "011A111";
local stringvar result := "";
local numbervar i;
For i := 1 to Len(JobN) do
(IF isnumeric(JobN[i]) Then result := result + JobN[i]) ;
ToText(Val(result),0,"");

Related

In LibreOffice Basic, how to condition for a non-empty string variable

I recently started using Macros in Libreoffice Calc and stumbled upon a quite basic problem, I simply can't find a solution to. I want to check if a string variable is non-empty in an if ... then condition
Currently in a Macro for Libreoffice Calc the code reads in 6 cells as variables
for I = 1 to 6
column(I) = oDoc.Sheets.getByName(K).getCellByPosition(I-1,J).String 'read column 1-6
next I
checks for some conditions
if column(4) = "" OR column(5) = "" OR column(6) != "" then
then writes those strings into new cells.
for I = 1 to 6
oDoc.Sheets.getByName("evalution").getCellByPosition(I,currentline+2).setString(column(I))
next I
if the conditions are not meat an else ... then moves the read entries somewhere else and writes them down there. By working in a loop of increasing J per sheet K and working trough all sheets K I can go trough the whole document an paste the lines with those 6 entries in a sorted in the evalution sheet.
If cells are empty, then when read the string is also just empty so I can check with = "".
But I can't find any way to check if the cell was not empty, so the string has anything in it and is not null.
I tried with a simple NOT condition so column(6) NOT = "" then, but no matter where I would place the NOT, LibreOffice always spits out an error. I tried using != like in the example as another way to negate the condition. Then the other way around tried if I could use = "*" or = "\w" as placeholder for any character. Nothing worked.
After also googling quite a bit and finding nothing to my problem, I turn to the hivemind of the internet itself, if anyone can help me.

matlab 'evidence removio': delete last shown command

I would like to remove whatever I just typed - and the last shown command - from the matlab console display. Needless to say, this would be ideal for pranksters (but this is of course strictly for academic purposes only). This is as far as I have gotten (based on this related answer):
hist = com.mathworks.mlservices.MLCommandHistoryServices.getSessionHistory; %get history
last = strjoin(cell(hist(end-2:end)),' '); %convert history to string
fprintf(repmat('\b',1,numel(last))); %replace characters of string with whitespace
However I can only access the last typed command (through the command history) - not the last displayed command (which would be ideal). Any ideas how to solve this?
Disclaimer: I don't advise doing this.
The MATLAB CommandWindow contents are stored as a CmdWinDocument, which is an extension of the Java PlainDocument type, and an interface of the Document type. The current window can be accessed using the command:
com.mathworks.mde.cmdwin.CmdWinDocument.getInstance
In theory, you should be able to remove text from the command window using something like:
doc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance
endpos = doc.getEndPosition
doc.remove(endpos-10,10)
which would, in theory, remove the last 10 character from the document. You may have to call the removeUpdate function as well. Obviously problems will be caused by the fact that these commands will be appended to the document during this process. I have not tested this, and you're likely to cause problems with internally stored offsets within the CmdWinDocument class, so use at your own risk.

How do i open a number of xlsx files when I only know part of the filename in Matlab?

I am using Matlab 2013b. I have a list of excel files in a directory and I want to open chosen ones within a loop to read out the data.
I only know the start of each of the file names however, not the ending. I have a vector of numbers that provide the identifying portion of the file's name (filenumber), and I want to loop through the excel files one by one, opening them and extracting the data, then closing them.
There are 500 files, each of the format: img_****ff*******.xlsx, where the first set of asterisks is my filenumber, while the second set of asterisks is unknown.
So far, I have tried listing what is in the directory using:
list=dir('E:\processed\Img*');
filenames={list.name}
This provides with with the full file names.
I tried then within a loop to create the part of the filename I know exists:
x = sprintf('Img_%d_FF_',img(1,1));
I then thought I could use 'Find' to look for my my partial filename/string in the 'filenames' structure above. I don't think I have the code correct for this datatype though:
index = find(strcmp({list.name}, x)==1)
You're pretty close, but the issue is that strcmp compares the whole string and since you only have the beginning part, it is not going to match. I would use strncmp to compare only the first n characters of the string. We can determine what n is based upon the length of your string x.
matches = strncmp({list.name}, x, numel(x));
thisfile = list(matches).name;

Excel/VBA - Copy and paste data into a worksheet in a specific row based on date

I have what I think is a pretty simple question.
I have a report that is updated daily. A specific range (B5:AC5) from one worksheet needs to be copied to a different worksheet on a daily basis. This doesn't need to be done automatically, I'd just like to add the code for it into a formatting macro I've created.
I have two issues with this:
I want the data to be pasted in the row that corresponds with that specific day. Column A in worksheet "Daily" has the list of working days for that month. So all I need is for the macro to find today's date in Column A in "Daily", and paste b5:AC5 from "Matrix" in b?:ac? in that row on "Daily".
I also need it to be a paste special, with only the values being pasted.
I'm very new to VB, but can usually follow code logic pretty well. Let me know if you need any more information from me. Thank you so much!
Assuming that your range will always be in B5:AC5, here is what I came up with:
Sub FindToday()
Dim FoundDate As Range
Set FoundDate = Worksheets("Daily").Columns("A").Find(DateValue(Now), LookIn:=xlValues, lookat:=xlWhole)
If Not FoundDate Is Nothing Then ' if we don't find the date, simply skip.
Worksheets("Matrix").Range("B5:AC5").Copy
FoundDate.Offset(0, 1).PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, False, False ' You can see that the first argument in PasteSpecial is set to only paste values.
End If
End Sub
I tested this as best I could given your information. I put a set of ascending numbers in the B5:AC5 range, with formulas, put a set of ascending dates for one month in the Daily sheet, and it seems to do what you're looking for.
Hope this helps.

How to write formula in Excel sheet which is stored in the perl variable

use strict
use Spreadsheet::WriteExcel;
my $Workbook = Spreadsheet::WriteExcel->new('cw.xls');
my $Worksheet = $Workbook->add_worksheet('MRD');
my $Formula= "A10+B10/2";
$Worksheet->write_formula(1,2,'='.($Formula));
exit;
Error getting:
Couldn't parse formula: =A10+B10/2;
Note : In the Formula that I am using contain across sheet data calling.
When I am Pasting it in the excel sheet manually its working fine but through program I am unable to put it in the sheet.
Please if any one came across this problem or has solution let me know.
If you see the documentation of Spreadsheet::WriteExcel module, it states in the DIAGNOSTICS section that:
Couldn't parse formula ...
There are a large number of warnings which relate to badly formed formulas and functions. See the "FORMULAS AND FUNCTIONS IN EXCEL" section for suggestions on how to avoid these errors. You should also check the formula in Excel to ensure that it is valid.
There is no problem storing a formula in a variable and passing it to write_formula(). In fact your own snippet above proves that it works.
So the problem is with the formula that you are trying to write. Since you haven't posted the formula it is hard to guess what the problem might be but here are some formula debugging tips from the docs:
Verify that the formula works in Excel (or Gnumeric or OpenOffice.org).
Ensure that it isn't on the Caveats list shown above. (In the docs).
Ensure that cell references and formula names are in uppercase.
Ensure that you are using ':' as the range operator, A1:A4.
Ensure that you are using ',' as the union operator, SUM(1,2,3).
Ensure that the function is in the above table. (In the docs).
P.S. The leading '=' isn't required when you are using write_formula() so you can just use:
$Worksheet->write_formula(1, 2, $Formula);