Sage 100

 View Only
  • 1.  Button script to create .DAT file

    Posted 10-04-2022 16:11
    Hello! I am looking to use a button script to gather a few pieces of data from a screen & send it to a .DAT file. Has anyone ever done this before & know the code to execute that?
    Thx!

    #script #scripting #buttonscript #Sage100 #SagePremium​​​​​​

    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    ------------------------------


  • 2.  RE: Button script to create .DAT file
    Best Answer

    Posted 10-05-2022 10:45
    Assuming your output file is text, try this:
    https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/filesystemobject-object

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    ------------------------------



  • 3.  RE: Button script to create .DAT file

    Posted 10-05-2022 13:26
    Edited by Alnoor Cassim 10-05-2022 16:21
    Generally a .DAT file is not defined to mean anything specific and usually refers to a TXT file. On a related note, last week when I was in NOLA where our merry gang ate a place on Magazine St in the Garden District called Dat Dog. Highly recommend it. Below is an example of creating and writing to a CSV log file:

    DLM="," : QUO=CHR(34)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    CSVLogFile1 = oSession.PathTextout & oSession.CompanyCode & "-" & _
    "SetElectronicConsentToNo-" & CurrentVBDateFullYMD & "-" & _
    Replace(CurrentTime,":","-") & ".csv"
    Set objFile1 = objFSO.CreateTextFile(CSVLogFile1, True) 'True means overwrite
    
    sHdrRow = _
    QUO & "Company" & QUO & DLM & QUO & sNow & QUO & DLM & QUO & "Division" & QUO & DLM & _
    QUO & "VendorNo" & QUO & DLM & QUO & "Msg Type" & QUO & DLM & QUO & "Message" & QUO
    objFile1.WriteLine sHdrRow
    
    ' blah blah blah .... 
    'Later within an AP_Vendor loop
    rV = oVendor.GetValue("ElectronicConsentSigned1099$", ElectronicConsent)
    r=oScript.DebugPrint("ElectronicConsent for " & CurrentVendor & " = " & ElectronicConsent)
    
    If ElectronicConsent = "Y" Then
    	retVal = oVendor.SetValue("ElectronicConsentSigned1099$", "N")
    If retVal = 0 Then
    	sMsgType = "Error on SetValue"
    	sMessage  = oVendor.LastErrorMsg
    End If
    If retVal = -1 Then
    	sMsgType = "Warning on SetValue"
    	sMessage  = oVendor.LastErrorMsg
    End If
    If retVal = 0 Then
    	sMsgType = "Passed"
    	sMessage = "Successful"
    End If
    sDataRow = _
    QUO & sCompany & QUO & DLM & QUO & sNow & QUO & DLM & QUO & sVend & QUO & DLM & _
    QUO & sVend & QUO & DLM & QUO & sMsgType & QUO & DLM & QUO & sMessage   & QUO
    objFile1.WriteLine sDataRow						
    rWrite = oVendor.Write()
    
    ' blah blah blah .... 
    End If​


    ------------------------------
    Alnoor Cassim
    ------------------------------



  • 4.  RE: Button script to create .DAT file

    Posted 10-05-2022 17:50


    ------------------------------
    Jeff Schwenk
    Bottomline Software, Inc.
    (540) 221-4444
    ------------------------------