### RequestProperty GET Method Example
Source: https://docs.indysoft.com/scripting/hm-requestproperty
An example demonstrating how to check if the request method is GET and respond accordingly.
```text
if RequestProperty("Method") = "GET" then
ResponseStatusCode(606)
ResponseBodyAsText("Thanks for sending a GET request")
End If
```
--------------------------------
### Web-Tier Tools installer filename examples with SERVER and port
Source: https://docs.indysoft.com/webtiertools/admins-setting-up-webtier-t
These are example installer filenames for the IndySoft Web-Tier Tools. The first specifies an SQL Server connection to server indysoft.ninja on port 9501. The second adds HTTPS and Unicode support by including the HTTPS and UNI codes before SERVER. The database type code (SQL, ORA, HTTPS, UNI) must appear before the word SERVER in the filename.
```text
IndySoftWebTierToolsSQLSERVERindysoft.ninja,9501.exe
```
```text
IndySoftWebTierToolsSQLHTTPSUNISERVERindysoft.ninja,9501.exe
```
--------------------------------
### LaunchFile Example
Source: https://docs.indysoft.com/scripting/hm-launchfile
An example demonstrating how to launch Notepad.exe from the C:\Windows directory.
```pascal
' this would launch an empty Notepad document
LaunchFile('Notepad.exe', 'C:\Windows', '')
```
--------------------------------
### WebTierDownloadFile example
Source: https://docs.indysoft.com/scripting/hm-webtierdownloadfile
Example call that downloads the file at C:\MyFiles\MyFileToDownload.txt.
```plaintext
WebTierDownloadFile("C:\MyFiles\MyFileToDownload.txt")
```
--------------------------------
### Example: Setting up parameters and calling SyncImportFromFiles
Source: https://docs.indysoft.com/scripting/hm-syncimportfromfiles
Example usage of SyncImportFromFiles. Sets up parameters and then calls the function, logs the result, and sends an email with the result.
```plaintext
sSyncMapName = "TEST1"
sToDirectory = "C:\Temp\Downloaded\100009"
sCompanyMap = "ABC COMPANY=12345;CDE COMPANY=545A781"
sSQLUpdateAfterImport = "UPDATE GAGES SET STATUS3 = '0'"
dtDateTime = (Now - 20)
bLab = False
bDeleteLocalAfterImport = False
```
```plaintext
sResult = SyncImportFromFiles(sSyncMapName, sToDirectory, sCompanyMap, sSQLUpdateAfterImport, dtDateTime, bLab, bDeleteLocalAfterImport)
DebugLog(sResult)
SendEMail("notreal@notgmail.com", "", "", "SyncImportFromFiles Results", "", "SYNCMAP", sResult, False, False)
```
--------------------------------
### ReturnYear usage example
Source: https://docs.indysoft.com/scripting/hm-returnyear
Example of calling ReturnYear with the Date function to get the current year and display it in a message.
```plaintext
ShowMessage('ReturnYear = ' & ReturnYear(Date))
```
--------------------------------
### Mid function example
Source: https://docs.indysoft.com/scripting/mid
Example usage of Mid to extract six characters starting at position 3 from the string "VBScript is fun!". The result is stored in MyVar and contains 'Script'.
```vbscript
Dim MyVar
MyVar = Mid("VBScript is fun!", 3, 6) ' MyVar contains 'Script'.
```
--------------------------------
### CreateEquipmentReport example call
Source: https://docs.indysoft.com/scripting/hm-createequipmentreport
Launches the Equipment search/report named "STANDARD". Replace the argument with the name of the desired PrintBuilder...Equipment template.
```unknown
CreateEquipmentReport("STANDARD")
```
--------------------------------
### Get Current Second
Source: https://docs.indysoft.com/scripting/second
Example demonstrating how to use the Second function with the Now function to retrieve the current second.
```vbscript
Dim MySec
MySec = Second(Now) ' MySec contains the number representing the current second.
```
--------------------------------
### Example: Get or initialize last export date
Source: https://docs.indysoft.com/scripting/hm-syncexportandupload
Retrieves the last export date from COMPANY_VARS, or initializes it if not present.
```plaintext
if tdDoSQLRecords(1, "SELECT VARIABLE_DATE FROM COMPANY_VARS WHERE COMPANY = '" & sCompany & "' AND VARIABLE_NAME = 'LAST EXPORT DATE'") then
dtCompanyLastExport = tdFieldByNameAsDateTime(1, "VARIABLE_DATE")
Else
dtCompanyLastExport = 0
RunSQL("INSERT INTO COMPANY_VARS (COMPANY, VARIABLE_NAME) VALUES ('" & sCompany & "', 'LAST EXPORT DATE')")
End If
```
--------------------------------
### Example usage of ExportAssetsAndUploadToCloud
Source: https://docs.indysoft.com/scripting/hm-exportassetanduploadtodropbox
This example demonstrates how to call the function, including setting up the service, company, and archive directory, and handling the result.
```text
sService = "DROPBOX" sCompany = "TEST COMPANY"
sArchiveDirectory = "C:\Temp\Uploaded\" & sCompany
if tdDoSQLRecords(1, "SELECT VARIABLE_DATE FROM COMPANY_VARS WHERE COMPANY = '" & sCompany &
"' AND VARIABLE_NAME = 'LAST EXPORT DATE'") then
dtCompanyLastExport = tdFieldByNameAsDateTime(1, "VARIABLE_DATE")
Else
dtCompanyLastExport = 0 RunSQL("INSERT INTO COMPANY_VARS (COMPANY, VARIABLE_NAME) VALUES ('" & sCompany & "', 'LAST EXPORT DATE')") End If
dtExport = Now
sResult = ExportAssetsAndUploadToCloud("COMPANY = '" & sCompany & "' AND LAST_MODIFIED_DATE >= '" &
FormatDateTimeForSQL(dtCompanyLastExport) & "'", "(EVENTS.EVENT_DATE > '01/01/2013 12:00:00 AM')", sService,
sCompany, sArchiveDirectory, True, True)
```
DebugLog(sResult)
SendEMail("myemail@notreal.com", "", "", "Export and Upload Results", "", "CLOUD", sResult, False, False)
if Pos("ERROR:", sResult) = 0 then
RunSQL("UPDATE COMPANY_VARS SET VARIABLE_DATE = '" & FormatDateTimeForSQL(dtExport) & "' WHERE COMPANY = '" &
sCompany & "' AND " & "VARIABLE_NAME = 'LAST EXPORT DATE'")
End If
```
--------------------------------
### LoadFileList usage example
Source: https://docs.indysoft.com/scripting/hm-loadfilelist
Example showing how to load .TXT files from a directory and iterate through them using GetFileFromList.
```pascal
iCount = LoadFileList("*.TXT", "C:\temp")
for i = 0 to (iCount - 1)
ShowMessage(GetFileFromList(i))
```
--------------------------------
### Example: Assign RequestBodyAsText to variable
Source: https://docs.indysoft.com/scripting/hm-requestbodyastext
Assigns the return value of RequestBodyAsText to the variable sMessageBody. Use this to get the message body as text when the content-type is text-based.
```plaintext
sMessageBody = RequestBodyAsText
```
--------------------------------
### Weekday function example
Source: https://docs.indysoft.com/scripting/weekday
Assigns a date to MyDate and calls Weekday to get the day of the week. The comment notes that MyWeekDay contains 6 because the date is a Friday.
```vb
Dim MyDate, MyWeekDay
MyDate = #October 19, 1962# ' Assign a date.
MyWeekDay = Weekday(MyDate) ' MyWeekDay contains 6 because MyDate represents a Friday.
```
--------------------------------
### Replace function usage examples
Source: https://docs.indysoft.com/scripting/replace
Demonstrates the Replace function with two calls. The first uses a binary comparison (default) and replaces all occurrences of 'p' from the start. The second uses a textual comparison (compare=1) starting at position 3, replacing all occurrences from that point. The comments show the expected return values.
```text
The following example uses the Replace function to return a string:
```
```vb
Dim MyString
```
```vb
' A binary comparison starting at the beginning of the string.
MyString = Replace("XXpXXPXXp", "p", "Y") ' Returns 'XXYXXPXXY'.
```
```vb
' A textual comparison starting at position 3.
MyString = Replace("XXpXXPXXp", "p", "Y", 3, -1, 1) ' Returns 'YXXYXXY'.
```
--------------------------------
### ReturnFromSQLComplex usage example
Source: https://docs.indysoft.com/scripting/hkm-returnfromsqlcomplex
Example showing how to retrieve a gage owner using ReturnFromSQLComplex and display the result.
```text
sOwner = ReturnFromSQLComplex("SELECT GAGE_OWNER FROM GAGES WHERE COMPANY = '" &
LookupEquipmentCompany & "' AND GAGE_SN = '" & LookupEquipmentID & "'", "OPEN")
ShowMessage("This gage is owned by " & sOwner)
```
--------------------------------
### Example usage of ExcelGetColCount with error handling
Source: https://docs.indysoft.com/scripting/excelgetcolcount
Demonstrates opening an Excel file, getting sheet count, selecting a sheet by index, and showing row and column counts. Includes error handling for file open failures.
```vbnet
Try
ExcelOpen("C:\Temp\TestExcel.xlsx")
ShowMessage(ExcelGetSheetCount)
ExcelGetSheetByIndex(1)
ShowMessage(ExcelGetRowCount&","&ExcelGetColCount) ' shows the number of rows and columns on the current sheet
ExcelClearSheet
ShowMessage(ExcelGetRowCount&","&ExcelGetColCount) ' shows 0,0
Except
ShowMessage(LastExceptionMessage) 'would display an error message from Windows if the file doesn't exist or cannot be opened.
End Try
```
--------------------------------
### LaunchScriptProject Example
Source: https://docs.indysoft.com/scripting/hm-launchscriptproject
Conditionally launches the script project 'MY PROJECT' when the current event step is 'tsChooseEquipment'.
```plaintext
if LookupCurrentEventStep = "tsChooseEquipment" then
LaunchScriptProject("MY PROJECT")
End If
```
--------------------------------
### Update UnitPrice for a specific part using WriteTextToLocalFileSection
Source: https://docs.indysoft.com/scripting/writetextfiletolocalfilesectio
Custom script example that updates the UnitPrice for PartNumber 'PA4343' to '24.01' in the XML file. It uses WriteTextToLocalFileSection with the file name, start and end flags for UnitPrice, the new value, section flags for PartDetailItem, and ID flags for PartNumber with the value 'PA4343'.
```text
if WriteTextToLocalFileSection('FromMyAccountingSystem.xml', '', '', '24.01', '', '', '', '', 'PA4343')
```
--------------------------------
### SyncImport usage example
Source: https://docs.indysoft.com/scripting/hm-syncimport
Example demonstrating how to define parameters and call the SyncImport function, followed by logging and email notification.
```text
sFileName = "C:\Temp\100003-TEST1-03-02-2015 13-43-02.ZIP"
sCompanyMap = ""
sSQLUpdateAfterImport = ""
bLab = True
```
```text
sResult = SyncImport("SYNCIMPORT TEST", sFileName, sCompanyMap, sSQLUpdateAfterImport, bLab)
DebugLog(sResult)
SendEMail("notreal@notgmail.com", "", "", "SyncImport Results", "", "SYNCMAP", sResult, False, False)
```
--------------------------------
### RequestHeader Usage Example
Source: https://docs.indysoft.com/scripting/hm-requestheader
An example demonstrating how to check for a specific custom header and respond accordingly.
```pascal
if RequestHeader("X-CustomHeader") = "E12" then
ResponseStatusCode(607)
ResponseBodyAsText("E12 scenario - appropriately handled")
End If
```
--------------------------------
### LoadExternalExcelFileResults Example
Source: https://docs.indysoft.com/scripting/hkm-loadexternalexcelfileresults
An example call to the LoadExternalExcelFileResults procedure.
```text
LoadExternalExcelFileResults("C:\MyDir\MyExcelFile.xls", 1)
```