Home AMX User Forum NetLinx Studio
Options

Receiving Record Sets in Netlinx

Greetings...

working on a module that will send back record sets and curious about your thoughts on preferred ways to deal with them once they arrive in Netlinx. The program will submit a query to the module and the module will return some number of records. Number of records returned could be 0 to MAX_RECORDS (not bounded at this point)

Ways I've considered include...

- comma separated list in one string...ie. '1,Bob,2,Dave,3,Mary'

- XML records in one string ie...'<records><record><id>1</id><name>Bob</name></record>....</records>' I could format this so that XML_TO_VARIABLE will work. This would work well because the server application sends the data to me over the network in this fashion. I haven't played with the XML stuff inside Netlinx much, but it seems a little picky about formation of the XML records.

- finally, each record in an individual string message...i.e. 'record-1,Bob', with a start and stop message. kind of an enumeration routine.

The Netlinx program must parse accordingly, then populate a user interface and report back the id of the record selected in a command...ie. 'LoadRecord-1'

Any thoughts, ideas or experiences would be greatly appreciated.

Thanks...Sonny

Comments

  • Options
    viningvining Posts: 4,368
    I don't think the XML_TO_VARIABLE will work in your situation. If you have a structure or array you could do a VARIABLE_TO_XML and then take that .xml file and load it into the same or different structure or array as long as it is formatted identically. In your case you have a .xml file whose tags and format won't match a thing. You could create a structure or array based on the fields you'll need to populate and create a parsing routine that with take the .xml provided by the server and use that to write a correctly formatted .xml that could work in netlinx but that would twice the work with no added benefit. Your best bet is just to parse the .xml from the server and have the parsing routine populate your array or structure directly. I would probably use a sencond structure or array to load the parsed data and then if all completes well and the closing /xml> tag is received then copy the temp structure to the working structure.
  • Options
    sonnysonny Posts: 208
    I'm actually parsing the XML stream in Cafe Duet when it comes in from the server, so I can send it over to Netlinx several ways. Obviously would like to limit the amount of Netlinx code required, so I'm leaning towards the individual message method right now since that only required a few lines to parse and place into a structure or array.
  • Options
    Spire_JeffSpire_Jeff Posts: 1,917
    I'm a little involved at the moment with some code, so I'll have to reread this and reply in more depth later, but the problem that caught my eye immediately was the unbound MAX_RECORDS. I am not aware of a way to generate an array in netlinx that is not bound. You will have to pick a value as the max and have a way to view only a subset of the data based on the MAX_RECORDS value.

    You might consider only retrieving only the number of records you will be working with. Your request could then include a max number of records to return and an offset to be applied.
    For example: REQUEST:10,52 could request 10 records starting from record number 52.

    You could also have a command to request the record count to prevent out of bounds requests, or handle the out of bounds within the module as needed.

    Jeff
  • Options
    joelwjoelw Posts: 175
    sonny wrote:
    The Netlinx program must parse accordingly, then populate a user interface and report back the id of the record selected in a command...ie. 'LoadRecord-1'

    Any thoughts, ideas or experiences would be greatly appreciated.

    How about maintain the data in your Duet module, and use Netlinx interface to exchange only the required data to present on UI.

    So use send_commands to define list size to duet, then send list update commands such as first, next, prev, last.
  • Options
    sonnysonny Posts: 208
    Thanks guys...

    the unknown number of records is an issue since there is no dynamic memory allocation within NetLinx. Keeping the data on the Duet side is a good idea (thanks)....basically all I need it for in Netlinx is to populate a list box, which has only a limited number of records displayed at a time anyway.
Sign In or Register to comment.