While Loop in Crystal 'More than maximum' when printing Pallet labels - crystal-reports

I am trying to get pallet tickets printed. I have a stored field {Paperdetails.TotalPalletCount} that is the total number of pallets, ie the number of labels I need.
I have a loop
LOCAL NUMBERVAR i :=1;
WHILE i < {Paperdetails.TotalPalletCount}
DO
(i = i+1)
but I get the error
A loop was evaluated more than the max number of time allowed
Any help appreciated
Ewan

The last line is not assigning a new value to i but is comparing it to i+1.
Just change the last line as follows (notice the colon :)
(i := i+1)
It should also be noted that loops in Crystal Reports may be evaluated a maximum of 100'000 times.

Related

Total function does not compile

I am trying to provide a total of all outstanding voucher amounts.
In one place I have this code:
=DSum("[Voucher_Balance]"|"tblVoucherInfo"|"[Patient_number] = " & [No])
I try to mimic this code at the end of the page but it gives an error.
'the expression you entered has invalid vertical bars'
Is there any way to fix this? We want to show the total of voucher balance per each patient.
I have tried changing the 'Region and LAnguage' list separator on the PC to a comma but that has no effect.
i tried changing the | to a comma, !, . - all to no effect.
Remove those bars:
=DSum("[Voucher_Balance]","tblVoucherInfo","[Patient_number] = " & [No] & "")
If that doesn't sum, your field names or table are misspelled, or no valid value for [No] is passed.

Group by formula field in report

To start from the beginning I had a long memo line that I needed to strip down to only show me a specific name in the string. Here is an example of the original memo line my report was giving me:
Ex. PLUMBERS-ACH distribution from share suffix 9 [2] 19.00 01DEC2017
I created three different formulas to strip down the memo line to only show me text before the "-". Here are those formulas:
Formula 1:
Left({SH_HIST.trn_memo}, instr(1,{SH_HIST.trn_memo},"-")-1)
Formula 2:
replace({Formula 1}, "-", " ")
Formula 3:
If instr({SH_HIST.trn_memo}, "-")>0 then {#Formula 2} else {SH_HIST.trn_memo}
I then placed Formula 3 into the report to give me the desired output from the memo line (this returns output successfully). Now I need to sort by that field because I need to be able to group all like items and sum them. When I click on "Insert Group" and select Formula 3 then try to preview the report I get the following message:
string length is less than 0 or not an integer
Can anyone lead me in the right direction to fix this, please? I've googled my heart out.
Instead of 3 formulas why don't you try this:
Split(Column,"-")[1] //Provided the format you gave applies for all records
Now group by this formula

Looking for a way to calculate time lapse in openrefine

This is the given expression of GREL language on OpenRefine.
diff(date d1, date d2, optional string timeUnit)
For dates, returns the difference in given time units.
So the question is how to get the access to the values of both columns, that is not clear on presented on the documentation.
Thanks
The formula for accessing another column is:
cells.YourColumnName.value
If your column name contains spaces or non-ascii characters :
cells['Your Column Name'].value
So, assuming your two columns are named "date1" and "date2", and you want the difference in days, the GREL formula is as follows :
diff(cells.date1.value, cells.date2.value, "days")
or
diff(cells['date1'].value, cells['date2'].value, "days")
I found a way myself here is the example of the working command, the GREL documentation is not that explicit treating this procedure.
Here is the commend I used, I multiplied the result by -1 to make it positive.
diff(cells["DATA_COMPRA"].value, cells["DATA_VENCIMENTO"].value, "days") * -1
Hope that helps, I my have to come back here sometimes to get this script again and again.

Adding zero in front of a number python

I am making program which will go through all possible choices.
Range is from 00000 to 99999.
For example:
00001,00002...01000,01001,01002...99999.
The problem is that i can make string as '00000' but as i convert it to int in order to add extra 1 to keep cycle going only one 0 appears. In that case i will get 0+1 = 1 and i need 00001.
Not completely sure how should i do it with lists because i might need it in the future for certain operations (to get one element from a current number 00450, 01004, 94571...)
Any advice/help would be greatly appreciated! :)
You can use zfill(num) on strings to add leading zeros
def convert_int(number,decimals) :
return str(number).zfill(decimals)
print convert_int(1,6) #prints 000001
I don't know if this is exactly what you want, but you can use string formatting. For example, this will turn int('00000') + 1 into '00001':
new_i = '%05d'%(int('00000')+1)
where %05d adds as many trailing zeros as necessary to whatever comes after % so the total length of the final string formatted number is 5.

What does this piece of Perl code do in laymans terms?

Found this inside a loop. I've read up about splice but it just confused me more.
I'm not familiar with Perl, but am trying to translate an algorithm to another language.
my $sill = splice(#list,int(rand(#list)),1);
last unless ($sill);
To be more specific: What will be inside $sill if it doesn't exit the loop from the last?
Thanks for any help!
This randomly removes one element from the array #list. That value is assigned to $sill. If that was a false value, the enclosing loop (not shown) is broken out of.
splice takes an array, an offset, and a length, plus a replacement list. If the replacement is omitted, the elements are deleted.
The length is constant (1 element), but the offset is calculated as a random integer smaller between 0 and the length of #list.
That means :
remove a random element from the array list (0 -> numbers of element of the list) and
assign the sill variable with the removed element (pop() like) and
exit the loop if sill variable is false
See http://perldoc.perl.org/functions/splice.html