Passa al contenuto principale

WriteTextFileToLocalFileSection

Structure

WriteTextFileToLocalFileSelection(sFileName,sStartFlag,sEndFlag,sToWrite,sSectionStartFlag,sSectionEndFlag,sIDStartFlag,sIDEndFlag,sIDValue)

Parameters

| Parameter | Type | Description
| sFileName | String | the name of the file in the IndySoft temporary directory that should be read. This is simply the file name plus the extension - this should NOT include the full directory pathsStartFlag | String | the text that should be searched to begin the return text. The return text will NOT include this sStartFlag textsEndFlag | String | the text that should be searched to end the return text. The return text will NOT include this sEndFlag.sToWrite | String | the text that will be replaced into the text file, in between sStartFlag and sEndFlag.sSectionStartFlag | String | the text that should be searched to begin the appropriate section.sSectionEndFlag | String | the text that should be searched to end the appropriate section.sIDStartFlag | String | the text that should be searched (in the sSection returned from above 2 parameters) to find the beginning of the ID fieldsIDEndFlag | String | the text that should be searched (in the sSection returned from above 2 parameters) to find the end of the ID fieldsIDValue | String | the text that should be compared to the returned ID text, to see it we have found the appropriate item. If so, the sStartFlag and sEndFlags are used to find the appropriate piece of information from this section. |

Return Value

Char

'1' = Success, '0' = Failure

Description

Functions in the 'Local File Read/Write Functions' group are used typically to create and read xml (or other) files from a common network directory to sync IndySoft's data/functionality with another system, like an accounting system. This function requires that a fie having the name sFileName exists in the current IndySoft temp directory - likely copied there from the 'GetLocalFile' function. Typically this is an xml file with data from another database application. This function is similar to WriteTextToLocalFile, but it only writes to a particular section of the file, and checks each section for an exact ID. As an example, say you are reading an xml file that returns cost information for a group of parts. The xml file might appear as below:
 
<?xml version='1.0' encoding='UTF-8' ?>

<PriceResponse>

<Header>

<Customer>100078</Customer>

<Code>AIT</Code>

</Header>

<PartDetailItem>

<LineNo>1</LineNo>

<PartNumber>PA0234</PartNumber>

<UnitPrice>10.23</UnitPrice>

</PartDetailItem>

<PartDetailItem>

<LineNo>2</LineNo>

<PartNumber>PA4343</PartNumber>

<UnitPrice>23.45</UnitPrice>

</PartDetailItem>

<PartDetailItem>

<LineNo>3</LineNo>

<PartNumber>PA8974</PartNumber>

<UnitPrice>56.45</UnitPrice>

</PartDetailItem>

</PriceResponse>
 
To continue the example, say you need to update the UnitPrice for PartNumber = 'PA4343' to a new value of '24.01'. You would only be interested in looking at the 'PartDetailItem' sections, and specifically only the detail section that had the 'PartNumber' field equal to 'PA4343'. Below is the custom script you would use:
 
if WriteTextToLocalFileSection('FromMyAccountingSystem.xml', '<UnitPrice>', '</UnitPrice>', '24.01', '<PartDetailItem>', '</PartDetailItem>', '<PartNumber>', '</PartNumber>', 'PA4343')

Example

No example provided

Application Compatibility

IndySoft Calibration Management, IndySoft Commercial Lab Management, IndySoft Tool Management

Also See

No related topics |