MARCEDIT-L Archives

October 2012

MARCEDIT-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Andrew Wright <[log in to unmask]>
Reply To:
MarcEdit support in technical and instructional matters <[log in to unmask]>
Date:
Fri, 5 Oct 2012 13:32:29 -0400
Content-Type:
multipart/mixed
Parts/Attachments:
text/plain (2159 bytes) , Baker & Taylor script.txt (9 kB)
Hi Terry

We have this script that was passed onto us by one of our vendors that you 
wrote that has proved very useful to us. However, a couple of months ago  we  
modified the  processing Marc edit script to use for getting the discount + 
processing for  a different vendor. It worked, but we have now discovered it is 
creating a problem when the POs go into  our financial system  

We download these records at retail price from the vendor . We then want to 
take a 42.5% discount and add $1.45 for processing. So,  we edited this part 
of the  original script:

 

tmpnum = ccur(tmpnum) + ccur(2.59)

 

to do this:

 

tmpnum = ccur(tmpnum*.575) + ccur(1.45)

 

It works, but it carries the price out to 4 decimal spaces in the 970 field  we 
we generate teh order in our ILS (Polaris) 

 

For example see Bib ctrl #1775484 and PO RF1-13 line 20:

            

970         ‡lBLW‡p16.9692‡q1

 

 

(Retail $19.99)

 

 We would like it to either round, round up, or truncate at 2 decimal spaces.  

 970         ‡lBLW‡p16.97‡q1

 

 

When I load the records onto a purchase order Polaris rounds the price and 
shows it as $16.97 in the unit price on the POLI, but it calculates the extended 
price using $16.9692. In this case the extended price for 10 copies was 
$169.69, not $169.70. And that discrepancy is what is throwing  our financial 
system off.

 

 We have tried a number of things with no luck can you help us fix the script to 
round or truncate the price to 2 decimal spaces?

 

Thanks,

Andrew Wright

 


Andrew Wright 
Catalog Division Manager 

City of Dallas 
Public Library 
Catalog Division 
1515 Young St. 
Dallas, Texas 75201 

Tel: 214-671-9269 
Fax: 214-670-7906 
e-mail: [log in to unmask] 


________________________________________________________________________

This message comes to you via MARCEDIT-L, a Listserv(R) list for technical and instructional support in MarcEdit.  If you wish to communicate directly with the list owners, write to [log in to unmask] To unsubscribe, send a message "SIGNOFF MARCEDIT-L" to [log in to unmask]



'BEGIN 'END '======================================================== ' Generated 8/16/2011 by the MarcEdit Script Maker. ' Description: The MarcEdit Script Maker is an separate but add-on ' utility that can be used to quickly generate vbscripts to process ' MARC files. ' ' Author: Terry Reese ' Oregon State University ' [log in to unmask] ' (541) 737-6384 ' Copyright: Users may freely use, modify, distribute scripts created by ' the MarcEdit Script Maker so long this header remains in the ' file. '========================================================= '=========================== ' Declare Global Constants '=========================== Const For_Reading = 1 Const For_Writing = 2 Const For_Appending = 8 '=========================== ' Declare Global Variables '=========================== Dim fso Dim lret Dim obj_Reg Set fso = CreateObject("scripting.FileSystemObject") Set obj_Reg = new RegExp '====================================== ' Enter the Main Function '====================================== lret = Main(GetUserInput()) msgbox lret & " records have been processed. The Script has completed." '===================================================== ' Function: GetUserInput ' Description: This function allows users to either drag a file ' to the script and have it run automatically or prompt for a source file. '===================================================== Function GetUserInput     '=================================     ' Trap the Error. If no file is specified, then     ' we assume that a file needs to be given     ' manually. Prompt for an input box.     '=================================        Const cdlOFNFileMustExist = &H1000        Const cdlOFNExplorer = &H80000     Dim str_Source     Dim dlg_Open ' This holds the Dialog object property if available     On Error Resume Next     GetUserInput = Wscript.Arguments(0)     If Err<>0 then     On error resume next     Set dlg_Open = CreateObject("MSComDlg.CommonDialog.1")     if Err=0 then        with dlg_Open            .Filter = "All files (*.*)|*.*|"            .FilterIndex = 1            .Flags = cdlOFNFileMustExist Or cdlOFNExplorer            .DialogTitle = "Select a file"            .FileName = ""            .CancelError = False            .MaxFileSize=255            .ShowOpen            str_Source = .FileName ' retrieve the result        end with            if str_Source = chr(0) or len(trim(str_source))=0 then               wscript.quit            end if            GetUserInput = str_Source     else       str_Source = InputBox("Enter your Source path (Remember that this file must be in tab delimited format)")               if Len(trim(str_Source))=0 then                 msgbox "You must enter a path name....Program stopping."                 Wscript.Quit               Else                 If Instr(str_Source, "\")=0 then                   str_Source = Mid(WScript.ScriptFullName, 1, InstrRev(WScript.ScriptFullName, "\")) & str_Source                   GetUserInput = str_Source                 Else                   GetUserInput = str_Source                 End if               End if      End if      End if End Function '====================================================== 'FUNCTION/SUB: Marc_Break 'Description: Encapsulates the MarcBreaker functions '====================================================== Function Marc_Break(source, dest) Dim obj_MB Dim lret if fso.FileExists(source)=false then     msgbox "Local MarcFile Could not be located. Quitting"     wscript.quit end if Set obj_MB=CreateObject("MARCEngine5.MARC21") lret=obj_MB.MarcFile(source, dest) set obj_MB=Nothing Marc_Break=lret end Function '====================================================== 'FUNCTION/SUB: Marc_Make 'Description: Encapsulates the MarcMaker Functions '====================================================== Function Marc_Make(source, dest) Dim obj_MK Set obj_MK=CreateObject("MARCEngine5.MARC21") lret=obj_MK.MMaker(source, dest) Set obj_MK=Nothing Marc_Make=lret end function '======================================================= ' FUNCTION/SUB: CreateTempFile ' Description: Retrieves the Name of a Temporary file located in the ' Temp. Directory. '======================================================= Function CreateTempFile Dim tfolder, tname Const TemporaryFolder = 2 Set tfolder = fso.GetSpecialFolder(TemporaryFolder) tname = fso.GetTempName CreateTempFile = tname End Function '========================================================== ' FUNCTION/SUB: CJoin ' Description: Custom join command to make certain that the MarcData is ' re-created correctly '========================================================== Function CJoin(t(), del)   Dim lx   Dim tMarc   for lx = 0 to Ubound(t)       if len(trim(t(lx)))<>0 then          tMarc = tMARC & t(lx) & vbcrlf       end if    next    CJoin = tMARC End Function '========================================================== ' FUNCTION/SUB: SortListL ' Description: Sorts MARC Fields '========================================================== Sub SortListL(l(), max)     Dim count     Dim x     Dim inc     Dim temp     Dim y     'Get out if there's nothing to do.     If max < 1 Then         Exit Sub     End If     inc = max \ 2     Do Until inc < 1         For x = inc + 1 To max             temp = l(x)             For y = x - inc To 1 Step -inc                 If temp >= l(y) Then                     Exit For                 End If                 l(y + inc) = l(y)             Next             l(y + inc) = temp         Next         inc = inc \ 2     Loop End Sub '========================================================== ' FUNCTION/SUB: IsMARC ' Description: A crude method to quickly see if the file ' is MARC (included so that scripts can access files that ' are both MARC or mnemonic '=========================================================== Function IsMARC(sFile) Dim tString, tfile Set tfile = fso.OpenTextFile(sFile, 1) tString = tfile.read(5) tfile.close if isnumeric(tString)=TRUE then     IsMARC = TRUE else     IsMARC = FALSE end if End Function '==================================================== ' Function: Main ' Description: Main is the Main procedure for the script. '==================================================== Function Main(str_Source) '================ ' Declare Objects '================ Dim obj_Source Dim obj_Dest(1) Dim Matches '================ ' Declare Variables '================ Dim retval Dim str_Dest Dim str_Data Dim Marc_String Dim tmp_Dest(1) Dim str_Pattern Dim tmp_array Dim tmp_string Dim bool_isMarc Dim tlcount '========================== ' Declare variables for the ' 001, 949 and 229 fields '========================== Dim str_001 Dim str_229 Dim str_949 tmp_Dest(0) = CreateTempFile tmp_Dest(1) = CreateTempFile tmp_string = Mid(str_source, 1, instrrev(str_source, "\")) '==================================================== ' We need to set the Temp Destinations because the ' script engine will fill in the path, but the path ' has to be explicitly defined for MarcEdit's Functions '===================================================== tmp_Dest(0) = tmp_string & tmp_Dest(0) tmp_Dest(1) = tmp_string & tmp_Dest(1) '======================================================= ' Set the Destination File '======================================================= str_Dest = tmp_string & Mid(str_Source, Instrrev(str_Source, "\")) If IsMARC(str_Source)=TRUE then      str_Dest = Mid(str_Dest, 1, Len(str_dest) - 4) & "rev.mrc"      retval = Marc_Break(str_Source, tmp_Dest(0))      bool_IsMARC=TRUE else      str_Dest = Mid(str_Dest, 1, Len(str_Dest) - 4) & "rev.mrk"      fso.CopyFile str_Source, tmp_Dest(0) end if Set obj_Dest(0) = fso.OpenTextFile(tmp_Dest(0), For_Reading) Set obj_Dest(1) = fso.OpenTextFile(tmp_Dest(1), For_Writing, TRUE) Do while not obj_Dest(0).AtEndOfStream     str_Data = obj_Dest(0).ReadLine     if len(trim(str_Data))=0 then                                          obj_Dest(1).Write Marc_String & vbcrlf                                 tlcount = tlcount + 1                                 Marc_String = ""                                 str_001 = ""                                 str_949 = ""                                 str_229 = ""     else                 if left(str_Data, 4) = "=970" then                    tmparr = split(str_Data, "$")                    for x=1 to Ubound(tmparr)                        if left(tmparr(x), 1) = "p" then                                    tmpnum = Mid(tmparr(x), 2)                                    tmpnum = ccur(tmpnum*.575) + ccur(1.45) ' tmpnum = FormatCurrency(tmpnum, 2)                                    tmparr(x) = Mid(tmparr(x),1,1) & cstr(tmpnum)                                    exit for                        end if                   next                   str_Data = join(tmparr, "$")                 end if                                                                  if Len(Trim(str_Data))<>0 then                                                 Marc_String = Marc_String & str_Data & vbcrlf                                 End if     end if Loop For x = 0 to Ubound(obj_Dest)   obj_Dest(x).Close Next if bool_IsMARC=TRUE then    Main = Marc_Make(tmp_Dest(1), str_Dest) else    fso.CopyFile tmp_Dest(1), str_Dest    Main = tlcount end if For x = 0 to Ubound(tmp_Dest)   fso.DeleteFile (tmp_Dest(x)) Next End Function ________________________________________________________________________ This message comes to you via MARCEDIT-L, a Listserv(R) list for technical and instructional support in MarcEdit. If you wish to communicate directly with the list owners, write to [log in to unmask] To unsubscribe, send a message "SIGNOFF MARCEDIT-L" to [log in to unmask]

ATOM RSS1 RSS2