Home AMX User Forum AMX Technical Discussion

NX-1200 and Netlinx

Hi Dears
I have NX-1200 in control system and i need to monitoring or supervise this controller.
I.e when any push any inputs from I/o port in need to log file contain the strings performed due to this push.
thanks.

Comments

  • From NetLinx Keyword help:

    File Operations Example: Writing to a File
    The following example code demonstrates writing to a file (typical usage):

    DEFINE_FUNCTION appendToFile (CHAR cFileName[],CHAR cLogString[])

    {

    STACK_VAR SLONG slFileHandle // stores the tag that represents the file (or and error code)

    LOCAL_VAR SLONG slResult // stores the number of bytes written (or an error code)

    slFileHandle = FILE_OPEN(cFileName,FILE_RW_APPEND) // OPEN OLD FILE (OR CREATE NEW ONE)

    IF(slFileHandle>0) // A POSITIVE NUMBER IS RETURNED IF SUCCESSFUL

         {
    
         slResult = FILE_WRITE_LINE(slFileHandle,cLogString,LENGTH_STRING(cLogString)) // WRITE THE NEW
                                                                                         INFO
    
          FILE_CLOSE(slFileHandle)   // CLOSE THE LOG FILE
    
         }           
    
      ELSE
    
         {
    
         SEND_STRING 0,"'FILE OPEN ERROR:',ITOA(slFileHandle)" // IF THE LOG FILE COULD NOT BE CREATED
    
         }
    

    }

    Which would be called like this:

    appendToFile(‘log.txt’,’Something happened…’)

    when an entry to this file needed to be written.

    Use the FILE_RW_APPEND constant for the IOFlag to append new data to the file.

Sign In or Register to comment.