Printing a label containing a VBScript via SDK

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
mvbs
Newcomer
Posts: 2
Joined: Fri Jan 25, 2019 4:12 pm

Printing a label containing a VBScript via SDK

Post by mvbs » Fri Jan 25, 2019 4:21 pm

Hello,

I am trying to print a label containing a simple variable field made with a VBScript as follows:

"$"+vIXRPRC

It concat the "$" character to the content of the vIXRPRC variable.

I got the SDK detailed error message:
Impossibile impostare il contenuto dell'elemento "CP__15", in quanto il suo valore non è valido. Si è verificato un errore durante il tentativo di esecuzione dello script.
Messaggio di errore di sistema: Impossibile trovare l'endpoint di pipe 'net.pipe://localhost/ScriptingService5548' nel computer locale.

I cannot figure out what's wrong. I am using Nice2019 from VB.NET 2017 via SDK.

Printing the label from Nicelabel works fine.

Here is the code:

Code: Select all

            NL_PrintEngine = NiceLabel.SDK.PrintEngineFactory.PrintEngine
            NL_PrintEngine.Initialize()
            LOGtextAdd("Nicelabel PrintEngine initialized !", False, False)

            ' Ricavo parametri passati all'eseguibile
            ' Stampante
            Dim mPrinter As String
            mPrinter = My.Application.CommandLineArgs(0)
            LOGtextAdd("Printer: " + mPrinter, False, False)
            ' Numero della stampante
            Dim mPrinterN As String
            mPrinterN = My.Application.CommandLineArgs(1)
            LOGtextAdd("Printer ID: " + mPrinterN, False, False)
            'Etichetta
            Dim mLabel As String
            mLabel = My.Application.CommandLineArgs(2)
            LOGtextAdd("Label: " + mLabel, False, False)
            'Numero etichette
            Dim mCount As Integer
            mCount = My.Application.CommandLineArgs(3)
            LOGtextAdd("Count: " + mCount.ToString, False, False)
            ' Variabili
            Dim mVar As String
            Dim mVal As String

            ' Apro l'etichetta
            NL_Label = NL_PrintEngine.OpenLabel(mLabel)

            ' Setto le variabili
            LOGtextAdd("Setting variables...", False, False)
            For i = 4 To My.Application.CommandLineArgs.Count - 1
                ' Solo dispari visto che il parametro del nome variabile è seguito dal parametro del valore variabile
                If (i Mod 2) = 0 Then
                    mVar = My.Application.CommandLineArgs(i)
                    mVal = My.Application.CommandLineArgs(i + 1)
                    LOGtextAdd("Var:" + mVar + " = " + mVal, False, False)

                    ' Faccio sempre passare tutte le variabili dell'etichetta
                    For j = 0 To NL_Label.Variables.Count - 1
                        If NL_Label.Variables.Item(j).Name = mVar Then NL_Label.Variables.Item(j).SetValue(mVal)
                    Next

                End If

            Next

            ' Imposto la stampante
            bFound = False
            For Each NL_Printer In NL_PrintEngine.Printers
                If NL_Printer.Name = mPrinter Then bFound = True
            Next
            If Not bFound Then
                LOGtextAdd("NL_Printer not found:" & mPrinter, False, True)
            Else
                NL_Label.PrintSettings.PrinterName = mPrinter
            End If

            ' Imposto le caratteristiche della preview
            NL_PreviewSettings = New NiceLabel.SDK.LabelPreviewSettings With {
                .Height = 740,
                .Width = 740,
                .ImageFormat = "BMP",
                .Destination = My.Application.Info.DirectoryPath + "\Preview" + mPrinterN + ".bmp",
                .PreviewToFile = True
            }

            ' Stampo l'etichetta
            If Not bError Then

                LOGtextAdd("Generating label preview ('" & mLabel & "' printed on '" & mPrinter & "')", False, False)
                NL_Label.GetLabelPreview(NL_PreviewSettings)

                NL_Label.PrintSettings.JobName = "iControl_Print"
                NL_Label.Print(mCount)


                LOGtextAdd("Label '" & mLabel & "' printed on '" & mPrinter, False, False)
            Else
                LOGtextAdd("Label '" & mLabel & "' could not be printed", False, False)
            End If

            LOGtextAdd("Job done!", False, True)
           

User avatar
Saso
NiceLabel
NiceLabel
Posts: 2963
Joined: Mon Sep 04, 2006 8:09 am
Contact:

Re: Printing a label containing a VBScript via SDK

Post by Saso » Tue Jan 29, 2019 3:58 pm

VBScript cannot be used from 64-bit NiceLabel .API NET process.

There are two options:
  1. Recompile your application as 32-bit application (to use 32-bit NiceLabel .API NET).
  2. Convert your VBScript code into Python code. Python will run in 64-bit process.
Saso Fleiser
Senior Technical Product Specialist

mvbs
Newcomer
Posts: 2
Joined: Fri Jan 25, 2019 4:12 pm

Re: Printing a label containing a VBScript via SDK

Post by mvbs » Fri Feb 01, 2019 6:54 pm

It worked recompiling my project as 32bit.

Thank you very much!
Matteo

Kalthoff_Support
Valued Contributor
Posts: 23
Joined: Tue Sep 27, 2016 1:54 pm

Re: Printing a label containing a VBScript via SDK

Post by Kalthoff_Support » Wed Mar 06, 2019 2:30 pm

same problem by me - same solution !

Well, compiling to 32bit solved the problem, but I'm getting several warnings (see attachment),
so I can't use the context typing no longer.

How can I solve this ?
Attachments
2019-03-06_142854.jpg
2019-03-06_142854.jpg (31.21 KiB) Viewed 1009 times
2019-03-06_142814.jpg
2019-03-06_142814.jpg (13.25 KiB) Viewed 1009 times

Kalthoff_Support
Valued Contributor
Posts: 23
Joined: Tue Sep 27, 2016 1:54 pm

Re: Printing a label containing a VBScript via SDK

Post by Kalthoff_Support » Wed Mar 06, 2019 3:00 pm

Problem was solved by updating to current Version.
Maybe a reference was broken ...

Post Reply