'************************************************************************************************** '* Script: UserTypeDemo.iss '* Date: Dec 31, 2021 '* Author: Brian Element - ideascripting.com '* Purpose: Demo script on how to use the user type, part of a youtube video '* Disclaimer: This script is purely a demo and not intended for production. Users should '* validate the working of the script before using it. '************************************************************************************************** Option Explicit Type Field fDecimals As Integer fDescription As String fEquation As String fHasActionField As Boolean fIsCharacter As Boolean fIsDate As Boolean fIsImpliedDecimals As Boolean fIsNumeric As Boolean fIstime As Boolean fIsVirtual As Boolean fLength As Integer fName As String fProtected As Boolean fType As Integer End Type Dim sFilename As String Dim fields() As field Sub Main sFilename = selectFile() Call getFields() Call displayFields() MsgBox "Script complete" End Sub Function displayFields() Dim i As Integer Dim msg As String For i = 0 To UBound(fields) msg = "Name: " & fields(i).fName & Chr(13) msg = msg & "Decimals: " & fields(i).fDecimals & Chr(13) msg = msg & "Description: " & fields(i).fDescription & Chr(13) msg = msg & "Equation: " & fields(i).fEquation & Chr(13) msg = msg & "Has action field: " & fields(i).fHasActionField & Chr(13) msg = msg & "Is Character: " & fields(i).fIsCharacter & Chr(13) msg = msg & "Is Date: " & fields(i).fIsDate & Chr(13) msg = msg & "Is Implied Decimals: " & fields(i).fIsImpliedDecimals & Chr(13) msg = msg & "Is Numeric: " & fields(i).fIsNumeric & Chr(13) msg = msg & "Is Time: " & fields(i).fIstime & Chr(13) msg = msg & "Is Virtual: " & fields(i).fIsVirtual & Chr(13) msg = msg & "Length: " & fields(i).fLength & Chr(13) msg = msg & "Protected: " & fields(i).fProtected & Chr(13) msg = msg & "Type: " & fields(i).fType & Chr(13) MsgBox msg Next i End Function Function getFields() Dim db As database Dim table As table Dim field As field Dim count As Integer Dim i As Integer Set db = client.OpenDatabase(sFilename) Set table = db.TableDef count = table.count ReDim fields(count - 1) For i = 0 To count - 1 Set field = table.GetFieldAt(i + 1) fields(i).fDecimals = field.Decimals fields(i).fDescription = field.Description fields(i).fEquation = field.Equation fields(i).fHasActionField = field.HasActionField fields(i).fIsCharacter = field.IsCharacter fields(i).fIsDate = field.IsDate fields(i).fIsImpliedDecimals = field.IsImpliedDecimal fields(i).fIsNumeric = field.IsNumeric fields(i).fIstime = field.Istime fields(i).fIsVirtual = field.IsVirtual fields(i).fLength = field.Length fields(i).fName = field.Name fields(i).fProtected = field.Protected fields(i).fType = field.Type Next i Set field = Nothing Set table = Nothing Set db = Nothing End Function Function selectFile() As String Dim obj As Object Set obj = client.CommonDialogs selectFile = obj.FileExplorer() Set obj = Nothing End Function