Quantity per Box, flow control Follow

0
Avatar
Nuno Ferreira

 

Hi, I know my problem here is identical to others that are described here in this comunity, but I couldnt resolve mine

I will start to describe my scenario:

I have 2 data sources of input by user (two number input boxes)

"totalquant" and "quantbybox"

On my label output, I have and object (text object) who will receive "quantbybox" value..Im going to call in "ReceiveQuantByBox"

 

I want to automate it so that it puts the number of labels needed to reach the totalquant and in the "ReceiveQuantByBox" go put the right amount.

Ex: totalquant=100...quantbybox=26

I will have to have 4 labels in total.

3 with ReceiveQuantByBox = 26 and last with ReceiveQuantByBox = 22.

OK.

This is what I've done:

CODE:

 - On Copies per serial number, I made a multiline script

if Format.NamedSubStrings("totalquant").Value Mod Format.NamedSubStrings("quantbybox").Value = 0 then

Value = Format.NamedSubStrings("totalquant").Value / Format.NamedSubStrings("quantbybox").Value

else

Value = Int (Format.NamedSubStrings("totalquant").Value / Format.NamedSubStrings("quantbybox").Value) + 1

end if

END CODE

 - On the output (ReceiveQuantByBox) object, I made an event control script,  and on IdenticalCopies Event, I try to make a flow control and a counter help me reach the total quantity.

If my counter doesnt reached the totalquant, My output will be 26...when the total quantity is reached or exceeded totalquant, my output will be 22

CODE:

Dim a

Do Until a=(totalquant-quantbybox)

   a=a+quantbybox

    value=quantbybox

  

Loop

value=totalquant-a

END CODE

I tryed this last code with Format.NamedSubStrings (ex:Format.NamedSubStrings("totalquant").Value )

and without that to, but nothing...

another question:when i must use Format.NamedSubStrings and just the reference to the data source (ex:just...totalquant for instance)??

And I dont know why, my counter doesnt count in each label, he just count in the first label ...I think.

Sorry for my English and i appreciate some help please.

9 comments

0
Avatar
Bao Van
Comment actions Permalink

I'm curious about this, has anyone replied to you on this ?  Have you made any progress since the OP date?

0
Avatar
Nuno Ferreira
Comment actions Permalink

nop, I tried to get help from seagull support, but they told me they did not support vbscript instructions.
I could not evolve much in this dilemma :-)
my difficulty I think, is where the bartender interprets the code at the level of each label. If I have, for example, a counter to support a function or a routine, a = a + 1 or a = a + "object value", I want it to do the routine and increase the result of label to label.
I have tried to put the code that you saw, in events, without multiple events, but I have not got anything yet.
I do not know how the bartender understands ... and where he understands the code

If by chance someone or even your "Bao Van" can help me too and if you have discovered anything tell me. Thank you so much

0
Avatar
Pete Thane
Comment actions Permalink

For the OP I think the VB would need to be Event Controlled OnPostPrompt rather than multi-line as the VB is reliant on data being entered at print time from the look of it. I will try and mock something up and post it here but may take me a few days to do due to other stuff to do too

0
Avatar
Nuno Ferreira
Comment actions Permalink

Ok, thanks, I'm waiting for your results.
Please tell us about your solutions.

I forgot to tell that my version of the bartender is the Professional 2016

 

0
Avatar
Pete Thane
Comment actions Permalink

I am not a VB programmer so there probably is a neater way of dong it, but the following works:

NUMBER OF LABELS

  • Add a field on the label (off tot he side of the label so it doesn't actually appear when printed) and give this an Embedded Data value of 1 and then name the field via the Change Data Source Name button at the top of the Data Source. I called mine CountUp, Once done come out of the naming screen and select the Transforms tab. 
  • Select the button to the right of the Serialisation and adjust the settings to make the field increment with Reset of Every Job then click Okay and Close to come out of the field. 
  • Add a second field off to the side of the label and for ease of reference give it a name (I used NoOfLabs)
  • Make the field a VB Script > Event Controlled field and press the Edit with Script Editor button and in the OnAutoSelected Event box in the middle of the screen change the code to Value = "1"
  • In the column on the left click on the OnPostPrompt to highlight it. What we no need to to is divide your TotalQuant by  QuantByBox values making sure to round up any remainder and to do this the following code can be used

Value1 = Format.NamedSubStrings("TotalQuant").Value

Value2 = Format.NamedSubStrings("QuantByBox").Value

Value3 = Round((Value1/Value2),1)

Value4 = Right((Value3*10),1)

If Value4 < 1 then
Value4 = 0
Else Value4 = 1
End if

Value3 = Int(Value3)

Value = Value3 + Value4

(NOTE for Value1 = and Value 2 = rather than copy and paste these in I would type in the ValueX = part but then double click on the field name required in Named Data Sources section of the column on the right as this will make sure the link is working correctly)

  • Press Close and Close to come out of the field and return to the Template view.
  • Now to link this to the number of labels to be printed and so open the File>Print screen
  • Next click the button to the left of the entry field where you would normally type in the number of serialised labels and adjust the Quantity Source to Get Quantity from Data Source.
  • When you do this the column on the left will change and include the words Data Source. Click on this and then using the Change Data Source Name button select the NoOfLabs (or whatever you called it) name from the list to link these two together.

RECEIVEDQUANTITYBYBOX value

Next we need to create the VB to allow for the part boxes and for this go into the Properties of this field on your label and

  • Amend the data source to VB Script > Event Controlled Script and press the Edit.... button as previously
  • Give the OnAutoSelected Event a value (I used Value ="0") and then this tine on the left hand column choose the OnSerialise button  
  • The following code can then be added although, as before where a named data source is referenced I would suggest you type in the ValueX = part and double click on the required named data source to create a working link

Value1 = Format.NamedSubStrings("CountUp").Value

If Value1 = 1 then
Value1 =1
Else Value1 = Value1-1
end if

Value2 = Format.NamedSubStrings("TotalQuant").Value

Value3 = Format.NamedSubStrings("QuantByBox").Value

Value = Value2 - (Value1 * Value3)

If Value <= Format.NamedSubStrings("QuantByBox").Value then
Value = Value
Else Value = Format.NamedSubStrings("QuantByBox").Value
end if

Value = Value

  • Then click Close and Close and Test Print / Preview a small label batch to check it is all working. 

 

Pete

0
Avatar
Nuno Ferreira
Comment actions Permalink

Thanks Man. I'll try your solution and report it later.
many many thanks

 

0
Avatar
Nuno Ferreira
Comment actions Permalink

After adapting Peter Thane's solution (thanks one more time, man ) to my needs and my project, there was one more problem to solve.
I'll post here what I've done so far:

 

 

In data entry form: two number input boxes, linked to two data sources ... (quantperbox and quanttotal).

On copiesperserialnumber:I made a multiline script:

if Format.NamedSubStrings("quanttotal").Value Mod Format.NamedSubStrings("quantperbox").Value = 0 then
Value = Format.NamedSubStrings("quanttotal").Value / Format.NamedSubStrings("quantperbox").Value
else
Value = Int (Format.NamedSubStrings("quanttotal").Value / Format.NamedSubStrings("quantperbox").Value) + 1
end if


Then I made a datasource("increment"), an event control script


This data source will serve as a counter for jumping from quantper box in each label (A hidden field...but for testing it stays visible)
Settings for this data source:
on Autoselectevent: Value = Format.NamedSubStrings ("quantperbox"). Value "(to start the first label with the value of per box)"


("The counter") - Onpostprompt: Dim a
Value1 = Format.NamedSubStrings ("quantperbox").
a = a + Value1
Value = a


After I made the "test2" datasource ("Sorry for the name") also event control script:


Onautoselectevent: Value = Format.NamedSubStrings ("quantperbox"). Value
On tab transforms and on Serialization: Increment by datasource ("increment"), and "when to increment" select every copy
I have not modified anything else in these settings

Now the template:
two single lines: the first will fetch the name of the data source test2, (this counter will appear in the output counting from quant per box to quant per box
The second I configured it with an eventcontrolscript:
Onidenticalcopies:
Value1=Format.NamedSubStrings("teste2").Value
Value2=Format.NamedSubStrings("quantperbox").Value
Value3=Format.NamedSubStrings("quanttotal").Value

If CLng( Value1) <= CLng(Value3) Then
Value=Value2
Else
Value=Value3-(Value1-Value2)
End If


This script left me in doubt because it gives me an error when I close it:
"Type mismatch CLng",
But the bartender accepts it, because when I do the test in the preview, it calls the form and the results are right (well more or less right) because now is my mistake, and I will explain


When I make the amount per box up to 999, it works fine (with the counter counting), but if I put more than 999 in the quantbybox, the counter gets stuck on its first value
In this last script I had to put the code in the onidenticalcopies, because only here is that the value of tes2 is recognized (Value1 = Format.NamedSubStrings ("test2").value)


I do not know if it will be this or because of the "Type mismatch CLng" script error,
I'm stuck in this error, try this solution if you want and if you see that I'm doing something wrong say ...
waiting for help please
I hope I have helped someone too
Thank you and sorry for my English

Google translator is my friend :-)

0
Avatar
Pete Thane
Comment actions Permalink

Just had a look back through my code and that wouldn't work for high quantities either, unless the following line woere amended

Value3 = Round((Value1/Value2),1)

to something like

Value3 = Round((Value1/Value2),5)

0
Avatar
Nuno Ferreira
Comment actions Permalink

Looks like I solved the previous problem.
the problem was in the digit separator (check mark option that is in each data source options).
I placed the separator in the data sources of the input objects (quantperbox and quanttotal) and removed this option in the other data sources (increment and test2).
it looks like it's going well now. Once again I have to thanks to Peter for his care.

 

Please sign in to leave a comment.