diff --git a/books/CSharp-readme.html b/books/CSharp-readme.html new file mode 100644 index 0000000..37fc771 --- /dev/null +++ b/books/CSharp-readme.html @@ -0,0 +1,255 @@ + + +CodeBase for C# + + + + + +

CodeBase for C# - ReadMe

+ +

Copyright ©1988-2007 Sequiter Inc.  All rights reserved.

+ +
+ +

This document contains useful information on how to use the CodeBase CSharp API with +Microsoft Visual Studio.

+ +

Installation

+ +

The files within this ZIP file are intended to add C# support to the base CodeBase for Windows installation. Before extracting this ZIP file, download and install one of the builds on the CodeBase for Windows download page.

+ +

Once you have downloaded and installed one of the builds on the CodeBase for Windows download page, extract this ZIP file to the same location as where you installed CodeBase for Windows. For example, if you installed CodeBase to C:\codebase\, extract this ZIP file to C:\codebase\. + +

Installed Files

+ +

After extracting this ZIP file, you should have +the following additional files and folders. (The list below includes only the files and folders that this ZIP file adds to the CodeBase installation; it does not describe the components of the base CodeBase installation.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
C:\codebase 
\books 
+ CSharp_Reference_Guide.chm
+ CSharp_User_Guide.chm +
Documentation for the CodeBase C# API
\examples 
\Source 
\CSharpSample source code featured in the documentation.
\source 
+ codebase.cs + CodeBase class module
+ +

Required Files

+ +

To use CodeBase in a C# project, use the Project|Add Existing Item... +menu command in your Visual Studio IDE to add codebase.cs to the +project.  Then, add

+ +

using CodeBase;

+ +

to your source code files that will be using the CodeBase C# classes.

+ +

After you have built your C# application, copy the files in CodeBase's DLL32 folder to a location where +your application can access it, ideally in the same folder as the +application or in the Windows System32 folder.

+ +

Building and Running Examples

+ +

The examples featured in the documentation are included as +.CS files in the Examples\Source\CSharp +folder.

+ +

To build and run these examples, the project c4ap.csproj has +been included for you in the Examples\Projects\CSharp folder. +The c4ap project +includes a dummy source file called example.cs. To build one of the +examples, you would do one of the following.

+ + + +

Information for Users Transitioning from CodeBase for C++ to CodeBase for C#

+ +

If you have been using CodeBase previously with C++ and are making a +transition to C#, the following information will be useful for understanding +the differences between the two.

+ +

This version of CodeBase for C# includes classes corresponding to the most +often used classes from the C++ version:

+ + + +

Almost all the class descriptions in the CodeBase C++ Reference Guide are applicable +to the C# classes. The minor differences are outlined below:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
In the C++ APIIn the C# API
+ Parameters and return values + implemented as long data type (e.g. Data4::go(long)) + + Implemented as int data type + (e.g. Data4::go(int)) +
+ Parameters and return values + implemented as char pointer (e.g. char *Data4::alias()) + + Implemented as string (e.g. string Data4::alias()) +
Constants (e.g. r4success) + Constant members of the Code4 class + (e.g. Code4.r4success) +
Code4::unlockAuto(), Code4::unlockAuto(int)Code4.unlockAuto class property
Data4::check()Data4.checkIndex()
Data4::lock()Data4.lockRecord()
Data4::log()Data4.log class property
Data4::position(), Data4::position(double)Data4.position class property
Data4::record()Not available
Expr4::null()Expr4.isNull()
Expr4::true()Expr4.isTrue()
Field4::assignLong(long)Not available
Field4::operator charField4.getChar()
Field4::operator doubleField4.getDouble()
Field4::operator intField4.getInt()
Field4::operator longNot available
Field4::null()Field4.isNull()
Field4::true()Field4.isTrue()
Field4::ptr()Not available
Index4::create()Not available; index creation is done through the Data4::create() method
Index4::tagAdd()Not available
+ + + diff --git a/books/CSharp_Reference_Guide.chm b/books/CSharp_Reference_Guide.chm new file mode 100644 index 0000000..499930c Binary files /dev/null and b/books/CSharp_Reference_Guide.chm differ diff --git a/books/CSharp_User_Guide.chm b/books/CSharp_User_Guide.chm new file mode 100644 index 0000000..27cfab9 Binary files /dev/null and b/books/CSharp_User_Guide.chm differ diff --git a/books/VBNET-readme.html b/books/VBNET-readme.html new file mode 100644 index 0000000..64a484a --- /dev/null +++ b/books/VBNET-readme.html @@ -0,0 +1,132 @@ + + +CodeBase for VB.NET + + + + + +

CodeBase for VB.NET - ReadMe

+ +

Copyright ©1988-2008 Sequiter Inc.  All rights reserved.

+ +
+ +

This document contains useful information on how to use the CodeBase VB.NET API with +Microsoft Visual Studio.

+ +

Installation

+ +

The files within this ZIP file are intended to add VB.NET support to the base +CodeBase for Windows installation. Before extracting this ZIP file, download +and install one of the builds on the CodeBase for Windows download page.

+ +

Once you have downloaded and installed one of the builds on the CodeBase +for Windows download page, extract this ZIP file to the same location as +where you installed CodeBase for Windows. For example, if you installed +CodeBase to C:\codebase\, extract this ZIP file to C:\codebase\.

+ +

Installed Files

+ +

After extracting this ZIP file, you should have the following +additional files and folders. (The list below includes only the files +and folders that this ZIP file adds to the CodeBase installation; it +does not describe the components of the base CodeBase installation.)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
C:\codebase 
\books 
+ VB_Reference_Guide.chm
+ VB_Users_Guide.chm +
Documentation for the CodeBase VB.NET API
\examples 
\Source 
\VBNETSample source code featured in the documentation.
\source 
+ codebase.vb + CodeBase VB.NET module
+ +

Required Files & References

+ +

To use CodeBase in a VB.NET project, add the following components to your project: +

+

+ +

After you have built your application, copy the files in CodeBase's DLL32 folder to a location where +your application can access it, ideally in the same folder as the +application or in the Windows System32 folder.

+ +

Building and Running Examples

+ +

The examples featured in the documentation are included as +.vb files in the Examples\Source\VBNET +folder.

+ +

To build and run these examples, the project EXAMPLE.vbproj has +been included for you in the Examples\Projects\VBNET folder. +This project +includes a dummy source file called example.vb. To build one of the +examples, you would do one of the following.

+ + + + + diff --git a/examples/Projects/CSharp/c4ap/App.ico b/examples/Projects/CSharp/c4ap/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/examples/Projects/CSharp/c4ap/App.ico differ diff --git a/examples/Projects/CSharp/c4ap/AssemblyInfo.cs b/examples/Projects/CSharp/c4ap/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/examples/Projects/CSharp/c4ap/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/examples/Projects/CSharp/c4ap/c4ap.csproj b/examples/Projects/CSharp/c4ap/c4ap.csproj new file mode 100644 index 0000000..f9f8164 --- /dev/null +++ b/examples/Projects/CSharp/c4ap/c4ap.csproj @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/Projects/VB.NET/EXAMPLE.vbproj b/examples/Projects/VB.NET/EXAMPLE.vbproj new file mode 100644 index 0000000..a5d2862 --- /dev/null +++ b/examples/Projects/VB.NET/EXAMPLE.vbproj @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/Projects/VB.NET/ExampleFrm.resX b/examples/Projects/VB.NET/ExampleFrm.resX new file mode 100644 index 0000000..063f434 --- /dev/null +++ b/examples/Projects/VB.NET/ExampleFrm.resX @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + Public + + + Public + + + Public + + + Public + + + Form1 + + \ No newline at end of file diff --git a/examples/Projects/VB.NET/ExampleFrm.vb b/examples/Projects/VB.NET/ExampleFrm.vb new file mode 100644 index 0000000..c067d33 --- /dev/null +++ b/examples/Projects/VB.NET/ExampleFrm.vb @@ -0,0 +1,121 @@ +Option Strict Off +Option Explicit On +Friend Class Form1 + Inherits System.Windows.Forms.Form +#Region "Windows Form Designer generated code " + Public Sub New() + MyBase.New() + If m_vb6FormDefInstance Is Nothing Then + If m_InitializingDefInstance Then + m_vb6FormDefInstance = Me + Else + Try + 'For the start-up form, the first instance created is the default instance. + If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then + m_vb6FormDefInstance = Me + End If + Catch + End Try + End If + End If + 'This call is required by the Windows Form Designer. + InitializeComponent() + End Sub + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean) + If Disposing Then + If Not components Is Nothing Then + components.Dispose() + End If + End If + MyBase.Dispose(Disposing) + End Sub + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + Public ToolTip1 As System.Windows.Forms.ToolTip + Public WithEvents Command1 As System.Windows.Forms.Button + Public WithEvents Label1 As System.Windows.Forms.Label + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Public WithEvents ListBox1 As System.Windows.Forms.ListBox + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() + Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) + Me.Command1 = New System.Windows.Forms.Button() + Me.Label1 = New System.Windows.Forms.Label() + Me.ListBox1 = New System.Windows.Forms.ListBox() + Me.SuspendLayout() + ' + 'Command1 + ' + Me.Command1.BackColor = System.Drawing.SystemColors.Control + Me.Command1.Cursor = System.Windows.Forms.Cursors.Default + Me.Command1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Command1.ForeColor = System.Drawing.SystemColors.ControlText + Me.Command1.Location = New System.Drawing.Point(170, 300) + Me.Command1.Name = "Command1" + Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.Command1.Size = New System.Drawing.Size(111, 31) + Me.Command1.TabIndex = 0 + Me.Command1.Text = "CLICK" + ' + 'Label1 + ' + Me.Label1.BackColor = System.Drawing.SystemColors.Window + Me.Label1.Cursor = System.Windows.Forms.Cursors.Default + Me.Label1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label1.ForeColor = System.Drawing.SystemColors.WindowText + Me.Label1.Location = New System.Drawing.Point(60, 340) + Me.Label1.Name = "Label1" + Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No + Me.Label1.Size = New System.Drawing.Size(342, 22) + Me.Label1.TabIndex = 1 + Me.Label1.Text = "Click the button to execute the example code" + ' + 'ListBox1 + ' + Me.ListBox1.ItemHeight = 16 + Me.ListBox1.Location = New System.Drawing.Point(8, 8) + Me.ListBox1.Name = "ListBox1" + Me.ListBox1.Size = New System.Drawing.Size(432, 276) + Me.ListBox1.TabIndex = 2 + ' + 'Form1 + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(7, 15) + Me.BackColor = System.Drawing.SystemColors.Window + Me.ClientSize = New System.Drawing.Size(451, 398) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListBox1, Me.Command1, Me.Label1}) + Me.Font = New System.Drawing.Font("Arial", 7.8!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.ForeColor = System.Drawing.SystemColors.WindowText + Me.Location = New System.Drawing.Point(73, 128) + Me.Name = "Form1" + Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual + Me.Text = "Form1" + Me.ResumeLayout(False) + + End Sub +#End Region +#Region "Upgrade Support " + Private Shared m_vb6FormDefInstance As Form1 + Private Shared m_InitializingDefInstance As Boolean + Public Shared Property DefInstance() As Form1 + Get + If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then + m_InitializingDefInstance = True + m_vb6FormDefInstance = New Form1() + m_InitializingDefInstance = False + End If + DefInstance = m_vb6FormDefInstance + End Get + Set + m_vb6FormDefInstance = Value + End Set + End Property +#End Region + + Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click + ExCode(Me) + End Sub +End Class \ No newline at end of file diff --git a/examples/source/CSharp/Append.cs b/examples/source/CSharp/Append.cs new file mode 100644 index 0000000..30012ab --- /dev/null +++ b/examples/source/CSharp/Append.cs @@ -0,0 +1,49 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class APPEND + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4(); + cb.optimize = Code4.OPT4ALL ; + cb.optimizeWrite = Code4.OPT4ALL ; + + Data4 dataFrom = new Data4( cb, "from_dbf") ; + Data4 dataTo = new Data4( cb, "to_dbf" ) ; + + cb.exitTest( ) ; + + Field4 infoFrom = new Field4( dataFrom, "NAME" ) ; + Field4 infoTo = new Field4( dataTo, "FNAME" ) ; + + cb.optStart( ) ; + + cb.lockAttempts = 1 ; + int rc1 = dataFrom.lockAll( ) ; + int rc2 = dataTo.lockAll( ) ; + + if( rc1 != 0 || rc2 != 0 ) + { + Console.WriteLine( "Locking Failed" ) ; + cb.exit( ) ; + } + + for( int rc = dataFrom.top( ); rc == 0; rc = dataFrom.skip( ) ) + { + dataTo.appendStart( ) ; + infoTo.assignField( ref infoFrom ) ; + dataTo.append( ) ; + } + + dataFrom.unlock( ) ; + dataTo.unlock( ) ; + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} diff --git a/examples/source/CSharp/BANK.cs b/examples/source/CSharp/BANK.cs new file mode 100644 index 0000000..746810c --- /dev/null +++ b/examples/source/CSharp/BANK.cs @@ -0,0 +1,78 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class BANK + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Field4 acctNo ; + static Field4 balance ; + static Tag4 acctTag = new Tag4() ; + static Tag4 balTag = new Tag4() ; + + static Field4info fieldInfo = new Field4info( ref codeBase ) ; + static Tag4info tagInfo = new Tag4info( codeBase ) ; + + static void OpenDataFile( ) + { + fieldInfo.add( "ACCT_NO", Code4.r4num, 5, 0, 0) ; + fieldInfo.add( "BALANCE", Code4.r4num, 8, 2, 0) ; + + tagInfo.add( "ACCT_TAG", "ACCT_NO", "", 0, 0 ) ; + tagInfo.add( "BAL_TAG", "BALANCE", "", 0, 0 ) ; + + dataFile.create( ref codeBase, "BANKDATA.DBF", ref fieldInfo, ref tagInfo ) ; + + acctNo = new Field4( dataFile, "ACCT_NO" ) ; + balance = new Field4( dataFile, "BALANCE" ) ; + + acctTag.init( dataFile, "ACCT_TAG" ) ; + balTag.init( dataFile, "BAL_TAG" ) ; + } + + static void PrintRecords( ) + { + Console.WriteLine("printrecords\n") ; + for( int rc = dataFile.top( ); rc == Code4.r4success; + rc = dataFile.skip( )) + { + Console.WriteLine("-------------------------------\n" + + "Account Number: {0}\nBalance : {1}\n", + acctNo.str( ), balance.str( ) ) ; + } + } + + static void AddNewRecord(int acct, double bal ) + { + dataFile.lockAll( ) ; + dataFile.appendStart( ) ; + dataFile.blank( ) ; + + acctNo.assignInt( acct ) ; + balance.assignDouble( bal ) ; + + dataFile.append( ) ; + dataFile.unlock( ) ; + } + + [STAThread] + static void Main(string[] args) + { + codeBase.errOpen = 1; + codeBase.safety = 0; + + OpenDataFile( ) ; + + AddNewRecord(12345,600.00); + + AddNewRecord(55555,300.00); + + PrintRecords( ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/CHAP14EG.cs b/examples/source/CSharp/CHAP14EG.cs new file mode 100644 index 0000000..8dd52da --- /dev/null +++ b/examples/source/CSharp/CHAP14EG.cs @@ -0,0 +1,30 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class CHAP14EG + { + static int openFileEx( ref Code4 codeBase, Data4 data, string name) + { + short oldAccessMode = codeBase.accessMode ; + codeBase.accessMode = Code4.OPEN4DENY_RW ; + + data.open( ref codeBase, name ) ; + + codeBase.accessMode = oldAccessMode ; + + return data.isValid( ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 db = new Data4() ; + openFileEx( ref cb, db, "INFO" ) ; + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/COPYDAT2.cs b/examples/source/CSharp/COPYDAT2.cs new file mode 100644 index 0000000..b773ca2 --- /dev/null +++ b/examples/source/CSharp/COPYDAT2.cs @@ -0,0 +1,45 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class COPYDAT2 + { + [STAThread] + static void Main(string[] args) + { + if(args.Length != 2) + { + Console.WriteLine( "USAGE: COPYDATA " ) ; + } + else + { + Code4 codeBase = new Code4(); + codeBase.safety = 0; + Data4 dataFile = new Data4( codeBase, args.GetValue(0).ToString( ) ) ; + codeBase.exitTest( ) ; + + Field4info fields = new Field4info( dataFile ) ; //copy the fields + + //obtain the Index4 object of the production index if one exists + Index4 index = new Index4( ) ; + index = dataFile.index( dataFile.alias ) ; + + Data4 dataCopy = new Data4(); + + if( index.isValid( ) != 0 ) + { + Tag4info tags = new Tag4info( index ) ; + dataCopy.create( ref codeBase, args.GetValue(1).ToString( ), ref fields, ref tags ) ; + tags.free( ) ; + } + else + dataCopy.create( ref codeBase, args.GetValue(1).ToString( ), ref fields ) ; + + codeBase.closeAll( ) ; + fields.free( ) ; + codeBase.initUndo( ) ; + } + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/COPYDATA.cs b/examples/source/CSharp/COPYDATA.cs new file mode 100644 index 0000000..8a7c2f9 --- /dev/null +++ b/examples/source/CSharp/COPYDATA.cs @@ -0,0 +1,32 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class COPYDATA + { + [STAThread] + static void Main(string[] args) + { + if(args.Length != 2) + { + Console.WriteLine( "USAGE: COPYDATA " ) ; + } + else + { + Code4 codeBase = new Code4(); + Data4 dataFile = new Data4( codeBase, args.GetValue(0).ToString( ) ) ; + Data4 dataCopy = new Data4(); + codeBase.exitTest( ) ; + + Field4info fields = new Field4info( dataFile ) ; + codeBase.safety = 0; + dataCopy.create( ref codeBase, args.GetValue(1).ToString( ), ref fields ) ; + fields.free( ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/CUSTLIST.cs b/examples/source/CSharp/CUSTLIST.cs new file mode 100644 index 0000000..e0caf5c --- /dev/null +++ b/examples/source/CSharp/CUSTLIST.cs @@ -0,0 +1,49 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class CUSTLIST + { + [STAThread] + static int Main(string[] args) + { + Code4 codeBase = new Code4() ; + Data4 dataFile = new Data4(codeBase, "data1.dbf" ) ; + Field4 fNameFld = new Field4( dataFile, "F_NAME" ) ; + Field4 lNameFld = new Field4( dataFile, "L_NAME" ) ; + Field4 addressFld = new Field4( dataFile, "ADDRESS" ) ; + Field4 ageFld = new Field4( dataFile, "AGE" ) ; + Field4 birthDateFld = new Field4( dataFile, "BIRTH_DATE" ) ; + Field4 marriedFld = new Field4( dataFile, "MARRIED" ) ; + Field4 amountFld = new Field4( dataFile, "AMOUNT" ) ; + Field4memo commentFld = new Field4memo( dataFile, "COMMENT" ); + + codeBase.exitTest( ) ; + + string birthDate ; + string purchased ; + string name ; + + for( int rc = dataFile.top( ); rc == Code4.r4success; rc = dataFile.skip( )) + { + purchased = amountFld.str() ; + birthDate = birthDateFld.str( ) ; + name = fNameFld.str( ) ; + name = name.Trim( ) ; + name = name + " " + lNameFld.str( ) ; + + Console.WriteLine("-------------------------------\nName : {0}\n" + + "Address : {1}\nAge : {2} Married : {3}\nBirth Date: {4}\n" + + "Comment: {5}\nPurchased this year:${6}", name.Trim(), addressFld.str( ), + ageFld.str( ), marriedFld.str( ), birthDateFld.str( ), + commentFld.str( ), purchased ) ; + } + + dataFile.close( ) ; + codeBase.initUndo( ) ; + + return 0 ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/DATAINFO.cs b/examples/source/CSharp/DATAINFO.cs new file mode 100644 index 0000000..fd4cb8e --- /dev/null +++ b/examples/source/CSharp/DATAINFO.cs @@ -0,0 +1,59 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class DATAINFO + { + [STAThread] + static int Main(string[] args) + { + if(args.Length != 1) + { + Console.WriteLine( " USAGE: DATAINFO \n" ) ; + } + else + { + Code4 codeBase = new Code4() ; + Data4 dataFile = new Data4( codeBase, args.GetValue(0).ToString() ) ; + codeBase.exitTest( ) ; + + int recCount = dataFile.recCount( ) ; + int numFields = dataFile.numFields( ) ; + uint recWidth = dataFile.recWidth( ) ; + string alias = dataFile.alias ; + + Console.WriteLine( "\t\t+---------------------------------+" ) ; + Console.WriteLine( "\t\t¦ Data File: {0, 12} ¦", args.GetValue(0) ) ; + Console.WriteLine( "\t\t¦ Alias : {0, 12} ¦", alias ) ; + Console.WriteLine( "\t\t¦ ¦" ) ; + Console.WriteLine( "\t\t¦ Number of Records: {0, 7} ¦", recCount ) ; + Console.WriteLine( "\t\t¦ Length of Record : {0, 7} ¦", recWidth ) ; + Console.WriteLine( "\t\t¦ Number of Fields : {0, 7} ¦", numFields ) ; + Console.WriteLine( "\t\t¦ ¦" ) ; + Console.WriteLine( "\t\t¦ Field Information : ¦\n" ) ; + Console.WriteLine( "\t\t¦---------------------------------¦\n"); + Console.WriteLine( "\t\t¦ Name ¦ type ¦ len ¦ dec ¦\n"); + Console.WriteLine( "\t\t¦------------+------+------+------¦\n"); + + for(short j = 1; j <= dataFile.numFields( ); j ++) + { + Field4 field = new Field4( dataFile, j ) ; + string name = field.name( ) ; + char type = (char ) field.type( ) ; + int len = (int) field.len( ) ; + int dec = field.decimals( ) ; + + Console.WriteLine( "\t\t¦ {0, 10} ¦ {1} ¦ {2,4} ¦ {3,4} ¦", + name, type, len, dec ) ; + + } + Console.WriteLine( "\t\t+---------------------------------+" ) ; + + dataFile.close( ) ; + codeBase.initUndo( ) ; + } + return 0; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/DELETION.cs b/examples/source/CSharp/DELETION.cs new file mode 100644 index 0000000..acc8783 --- /dev/null +++ b/examples/source/CSharp/DELETION.cs @@ -0,0 +1,75 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class DELETION + { + static void printDeleteStatus(int status,long recNo) + { + if(status != 0) + Console.WriteLine( "Record {0} - DELETED\n", recNo ) ; + else + Console.WriteLine( "Record {0} - NOT DELETED\n", recNo ) ; + } + + static void printRecords( Data4 dataFile) + { + int rc = 0, status; + int recNo; + + Console.WriteLine( "\n" ) ; + + dataFile.top( ) ; + while( rc != Code4.r4eof ) + { + recNo = dataFile.recNo( ) ; + status = dataFile.deleted( ) ; + printDeleteStatus( status, recNo ) ; + rc = dataFile.skip( ) ; + } + } + + [STAThread] + static void Main(string[] args) + { + Code4 codeBase = new Code4(); + Data4 dataFile = new Data4(); + Field4info fieldInfo = new Field4info( ref codeBase ) ; + fieldInfo.add( "DUMMY", 'C', 10, 0, 0 ) ; + fieldInfo.add( "MEMO", 'M', 10, 0, 0 ) ; + + int count; + + codeBase.safety = 0 ; + codeBase.errCreate = 0 ; + codeBase.lockEnforce = 1 ; + + dataFile.create(ref codeBase, "TUTOR5", ref fieldInfo ) ; + codeBase.exitTest( ) ; + + for(count = 0; count < 5; count ++) + dataFile.appendBlank( ) ; + + printRecords( dataFile ) ; + + dataFile.lockAll( ) ; + dataFile.go( 3 ) ; + dataFile.deleteRec( ) ; + dataFile.go( 1 ) ; + dataFile.deleteRec( ) ; + printRecords( dataFile ) ; + + dataFile.go( 3 ) ; + dataFile.recall( ) ; + printRecords( dataFile ) ; + + dataFile.pack( ) ; + dataFile.memoCompress( ) ; + printRecords( dataFile ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/MULTI.cs b/examples/source/CSharp/MULTI.cs new file mode 100644 index 0000000..e9f51ed --- /dev/null +++ b/examples/source/CSharp/MULTI.cs @@ -0,0 +1,135 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class MULTI + { + static Code4 cb = new Code4() ; + static Data4 dataNames = new Data4() ; + static Field4 fieldName ; + static Tag4 tagName = new Tag4() ; + + static void addRecord() + { + Console.WriteLine( "Enter New Record\n" ) ; + string buf ; + for(;;) + { + buf = Console.ReadLine() ; + if (buf != "") break ; + } + + dataNames.appendStart( ) ; + fieldName.assign( buf ) ; + dataNames.append( ) ; + dataNames.unlock( ) ; + } + + static void findRecord() + { + Console.WriteLine( "Enter Name to Find" ) ; + string buf ; + for(;;) + { + buf = Console.ReadLine() ; + if (buf != "") break ; + } + + dataNames.select( tagName ) ; + dataNames.seek( buf ) ; + } + + static void modifyRecord() + { + short oldLockAttempts = cb.lockAttempts ; + cb.lockAttempts = 1 ; // Only make one lock attempt + + int rc = dataNames.lockRecord(dataNames.recNo( ) ) ; + if(rc == Code4.r4locked) + Console.WriteLine( "Record locked. Unable to Edit" ) ; + else + { + Console.WriteLine( "Enter Replacement Record" ) ; + string buf ; + for(;;) + { + buf = Console.ReadLine() ; + if (buf != "") break ; + } + + fieldName.assign( buf ) ; + dataNames.flush( ) ; + dataNames.unlock( ) ; + } + cb.lockAttempts = oldLockAttempts ; + } + + static void listData() + { + cb.optStart( ) ; + dataNames.optimize( Code4.OPT4ALL ) ; + dataNames.select( tagName ) ; + + for( dataNames.top( ); dataNames.eof( ) == 0; dataNames.skip( ) ) + Console.WriteLine("{0} {1}\n", dataNames.recNo( ), fieldName.str( ) ); + + dataNames.optimize( Code4.OPT4OFF ) ; + cb.optSuspend( ) ; + } + + [STAThread] + static void Main(string[] args) + { + cb.accessMode = Code4.OPEN4DENY_NONE ; + cb.readOnly = 0 ; + cb.readLock = 0 ; + cb.lockAttempts = Code4.WAIT4EVER ; + cb.lockEnforce = 1 ; + + dataNames.open( ref cb, "names" ) ; + cb.exitTest( ) ; + + fieldName = new Field4( dataNames, "NAME" ) ; + tagName.init( dataNames, "NAMENAME" ) ; + + dataNames.top( ) ; + + for(;;) + { + cb.errorCode = 0 ; + + Console.WriteLine( "Record #: {0} Name: {1}", + dataNames.recNo( ), fieldName.str( ) ) ; + + Console.WriteLine( "Enter Command ('a','f','l','m' or 'x') " ) ; + + int command ; + do + { + command = Console.Read() ; + } while (command == 10) ; + switch( command ) + { + case 'a': + addRecord( ) ; + break ; + case 'f': + findRecord( ) ; + break ; + case 'l': + listData( ) ; + break ; + case 'm': + modifyRecord( ) ; + break ; + case 'x': + cb.closeAll( ) ; + cb.initUndo( ) ; + cb.exit( ) ; + break; + } + } + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/NEWLIST.cs b/examples/source/CSharp/NEWLIST.cs new file mode 100644 index 0000000..1ea802d --- /dev/null +++ b/examples/source/CSharp/NEWLIST.cs @@ -0,0 +1,126 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class NEWLIST + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Field4 fName ; + static Field4 lName ; + static Field4 address ; + static Field4 age ; + static Field4 birthDate ; + static Field4 married ; + static Field4 amount ; + static Field4memo comment ; + + static void OpenDataFile( ) + { + Field4info fieldInfo = new Field4info( ref codeBase ) ; + + fieldInfo.add( "F_NAME", Code4.r4str, 10, 0, 0 ) ; + fieldInfo.add( "L_NAME", Code4.r4str, 10, 0, 0 ) ; + fieldInfo.add( "ADDRESS", Code4.r4str, 15, 0, 0 ) ; + fieldInfo.add( "AGE", Code4.r4num, 2, 0, 0 ) ; + fieldInfo.add( "BIRTH_DATE", Code4.r4date, 8, 0, 0 ) ; + fieldInfo.add( "MARRIED", Code4.r4log, 1, 0, 0 ) ; + fieldInfo.add( "AMOUNT", Code4.r4num, 7, 2, 0 ) ; + fieldInfo.add( "COMMENT", Code4.r4memo, 10, 0, 0 ) ; + + dataFile.open( ref codeBase, "people.dbf" ) ; + + if( dataFile.isValid( ) == 0 ) + dataFile.create( ref codeBase,"people.dbf", ref fieldInfo ) ; + + fName = new Field4( dataFile, "F_NAME") ; + lName = new Field4( dataFile, "L_NAME") ; + address = new Field4( dataFile, "ADDRESS") ; + age = new Field4( dataFile, "AGE") ; + birthDate = new Field4( dataFile, "BIRTH_DATE") ; + married = new Field4( dataFile, "MARRIED") ; + amount = new Field4( dataFile, "AMOUNT") ; + comment = new Field4memo( dataFile, "COMMENT") ; + } + + static void PrintRecords( ) + { + string bDate ; + string purchased ; + string name ; + + for( int rc = dataFile.top( ); rc == Code4.r4success; rc = dataFile.skip( )) + { + purchased = amount.str() ; + bDate = birthDate.str( ) ; + name = fName.str( ) ; + name = name.Trim( ) ; + name = name + " " + lName.str( ) ; + + Console.WriteLine("-------------------------------\nName : {0}\n" + + "Address : {1}\nAge : {2} Married : {3}\nBirth Date: {4}\n" + + "Comment: {5}\nPurchased this year:${6}", name.Trim(), address.str( ), + age.str( ), married.str( ), birthDate.str( ), + comment.str( ), purchased ) ; + } + } + + static void AddNewRecord(string fNameStr, string lNameStr, string addressStr + ,string dateStr, int marriedValue, double amountValue, string commentStr ) + { + dataFile.lockAll( ) ; + dataFile.appendStart( ) ; + dataFile.blank( ) ; + + fName.assign( fNameStr ) ; + lName.assign( lNameStr ) ; + address.assign( addressStr ) ; + + DateTime bDate = DateTime.ParseExact(dateStr, "yyyyMMdd", + System.Globalization.CultureInfo.CurrentCulture) ; + DateTime today = DateTime.Today ; + + TimeSpan span = today.Subtract( bDate ) ; + // approximate age -- ignore leap year + int ageValue = (int) span.Days / 365 ; + + age.assignInt( ageValue ) ; + birthDate.assign( bDate.ToString( "yyyyMMdd" ) ) ; + + if( marriedValue != 0 ) + married.assign( "T" ) ; + else + married.assign( "F" ) ; + + amount.assignDouble( amountValue ) ; + if( commentStr.Length > 0 ) + comment.assign( commentStr ) ; + + dataFile.append( ) ; + dataFile.unlock( ) ; + } + + [STAThread] + static int Main(string[] args) + { + codeBase.errOpen = 0; + codeBase.safety = 0; + codeBase.lockEnforce = 1 ; + + OpenDataFile( ) ; + + PrintRecords( ) ; + + AddNewRecord("Sarah", "Webber", "132-43 St.", "19600223", 1, 147.99, "New Customer"); + + AddNewRecord("John", "Albridge", "1232-76 Ave.", "19581012", 0, 98.99, "" ) ; + + PrintRecords( ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + return 0 ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/NEWLIST2.cs b/examples/source/CSharp/NEWLIST2.cs new file mode 100644 index 0000000..892ddcd --- /dev/null +++ b/examples/source/CSharp/NEWLIST2.cs @@ -0,0 +1,144 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class NEWLIST2 + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Field4 fName ; + static Field4 lName ; + static Field4 address ; + static Field4 age ; + static Field4 birthDate ; + static Field4 married ; + static Field4 amount ; + static Field4memo comment ; + static Tag4 nameTag = new Tag4() ; + static Tag4 ageTag = new Tag4() ; + static Tag4 amountTag = new Tag4() ; + + static void CreateDataFile( ) + { + Field4info fieldInfo = new Field4info( ref codeBase ) ; + + fieldInfo.add( "F_NAME", Code4.r4str, 10, 0, 0 ) ; + fieldInfo.add( "L_NAME", Code4.r4str, 10, 0, 0 ) ; + fieldInfo.add( "ADDRESS", Code4.r4str, 15, 0, 0 ) ; + fieldInfo.add( "AGE", Code4.r4num, 2, 0, 0 ) ; + fieldInfo.add( "BIRTH_DATE", Code4.r4date, 8, 0, 0 ) ; + fieldInfo.add( "MARRIED", Code4.r4log, 1, 0, 0 ) ; + fieldInfo.add( "AMOUNT", Code4.r4num, 7, 2, 0 ) ; + fieldInfo.add( "COMMENT", Code4.r4memo, 10, 0, 0 ) ; + + Tag4info tagInfo = new Tag4info( codeBase ) ; + + tagInfo.add( "PPL_NAME", "F_NAME + L_NAME", ".NOT. DELETED()", 0, 0 ) ; + tagInfo.add( "PPL_ADDR", "ADDRESS", "", 0, 0 ) ; + tagInfo.add( "PPL_BRTH", "BIRTH_DATE", "AGE >= 18", 0, 0 ) ; + tagInfo.add( "PPL_AGE", "AGE", "", 0, 0 ) ; + tagInfo.add( "PPL_AMNT", "AMOUNT", "", 0, 0 ) ; + + dataFile.create( ref codeBase, "people.dbf", ref fieldInfo, ref tagInfo ) ; + + fName = new Field4( dataFile, "F_NAME") ; + lName = new Field4( dataFile, "L_NAME") ; + address = new Field4( dataFile, "ADDRESS") ; + age = new Field4( dataFile, "AGE") ; + birthDate = new Field4( dataFile, "BIRTH_DATE") ; + married = new Field4( dataFile, "MARRIED") ; + amount = new Field4( dataFile, "AMOUNT") ; + comment = new Field4memo( dataFile, "COMMENT") ; + + nameTag.init( dataFile, "PPL_NAME") ; + ageTag.init( dataFile, "PPL_AGE") ; + amountTag.init( dataFile, "PPL_AMNT") ; + } + + static void PrintRecords( ) + { + string bDate ; + string purchased ; + string name ; + + for( int rc = dataFile.top( ); rc == Code4.r4success; rc = dataFile.skip( )) + { + purchased = amount.str() ; + bDate = birthDate.str( ) ; + name = fName.str( ) ; + name = name.Trim( ) ; + name = name + " " + lName.str( ) ; + + Console.WriteLine("-------------------------------\nName : {0}\n" + + "Address : {1}\nAge : {2} Married : {3}\nBirth Date: {4}\n" + + "Comment: {5}\nPurchased this year:${6}", name.Trim(), address.str( ), + age.str( ), married.str( ), birthDate.str( ), + comment.str( ), purchased ) ; + } + } + + static void AddNewRecord(string fNameStr, string lNameStr, string addressStr + ,string dateStr, int marriedValue, double amountValue + ,string commentStr ) + { + dataFile.lockAll( ) ; + dataFile.appendStart( ) ; + dataFile.blank( ) ; + + fName.assign( fNameStr ) ; + lName.assign( lNameStr ) ; + address.assign( addressStr ) ; + + DateTime bDate = DateTime.ParseExact(dateStr, "yyyyMMdd", + System.Globalization.CultureInfo.CurrentCulture) ; + DateTime today = DateTime.Today ; + + TimeSpan span = today.Subtract( bDate ) ; + // approximate age -- ignore leap year + int ageValue = (int) span.Days / 365 ; + + age.assignInt( ageValue ) ; + birthDate.assign( bDate.ToString( "yyyyMMdd" ) ) ; + + if( marriedValue != 0 ) + married.assign( "T" ) ; + else + married.assign( "F" ) ; + + amount.assignDouble( amountValue ) ; + if( commentStr.Length > 0 ) + comment.assign( commentStr ) ; + + dataFile.append( ) ; + dataFile.unlock( ) ; + } + + [STAThread] + static void Main(string[] args) + { + codeBase.safety = 0 ; + codeBase.lockEnforce = 0 ; + + CreateDataFile( ) ; + + AddNewRecord( "Sarah", "Webber", "132-43 St.", "19600212", 1, 147.99 + , "New Customer"); + AddNewRecord("John", "Albridge", "1232-76 Ave.", "19581023", 0, 98.99, "" ) ; + + PrintRecords( ) ; + + dataFile.select( nameTag ) ; + PrintRecords( ) ; + + dataFile.select( ageTag ) ; + PrintRecords( ) ; + + dataFile.select( amountTag ) ; + PrintRecords( ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/NOGROUP.cs b/examples/source/CSharp/NOGROUP.cs new file mode 100644 index 0000000..8159926 --- /dev/null +++ b/examples/source/CSharp/NOGROUP.cs @@ -0,0 +1,48 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class NOGROUP + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Tag4 nameTag = new Tag4() ; + static Tag4 ageTag = new Tag4() ; + static Tag4 idTag = new Tag4() ; + + [STAThread] + static void Main(string[] args) + { + codeBase.connect("","","","",""); + + if ( codeBase.indexExtension().ToUpper().Equals( "NTX" ) ) + { + codeBase.autoOpen = 0; + codeBase.safety = 0; + codeBase.accessMode = Code4.OPEN4DENY_RW ; + + Tag4info tagInfo = new Tag4info( codeBase ) ; + tagInfo.add( "STU_NAME", "L_NAME+F_NAME", "", 0, 0 ); + tagInfo.add( "STU_AGE", "AGE", "", 0, 0 ) ; + tagInfo.add( "STU_ID", "ID", "", 0, 0 ) ; + + dataFile.open( ref codeBase, "STUDENT.DBF" ) ; + Index4 index = new Index4() ; + index.create( ref dataFile, "", ref tagInfo ) ; + + nameTag.init( dataFile, "STU_NAME" ) ; + ageTag.init( dataFile, "STU_AGE" ) ; + idTag.init(dataFile, "STU_ID" ); + + codeBase.closeAll( ) ; + } + else + { + Console.Error.WriteLine( "This example is only for Clipper." ) ; + } + + codeBase.initUndo( ) ; + } + } +} diff --git a/examples/source/CSharp/NOGROUP2.cs b/examples/source/CSharp/NOGROUP2.cs new file mode 100644 index 0000000..a72689d --- /dev/null +++ b/examples/source/CSharp/NOGROUP2.cs @@ -0,0 +1,46 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class NOGROUP + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Tag4 nameTag = new Tag4() ; + static Tag4 ageTag = new Tag4() ; + static Tag4 idTag = new Tag4() ; + + static void printRecords( ) + { + + } + + [STAThread] + static void Main(string[] args) + { + codeBase.connect("","","","","") ; + + if ( codeBase.indexExtension().ToUpper().Equals( "NTX" ) ) + { + codeBase.autoOpen = 0 ; + codeBase.safety = 0 ; + + dataFile.open( ref codeBase, "STUDENT.DBF" ) ; + + nameTag.open( dataFile, "STU_NAME" ) ; + ageTag.open( dataFile, "STU_AGE" ) ; + idTag.open( dataFile, "STU_ID" ) ; + + dataFile.select( nameTag ) ; + printRecords(); + + codeBase.closeAll( ) ; + } + else + Console.Error.WriteLine( "This example is only for Clipper." ) ; + + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/RELATE1.cs b/examples/source/CSharp/RELATE1.cs new file mode 100644 index 0000000..a9de0ec --- /dev/null +++ b/examples/source/CSharp/RELATE1.cs @@ -0,0 +1,86 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class RELATE1 + { + static Code4 codeBase = new Code4( 0 ) ; + static Data4 student = new Data4() ; + static Data4 enrolment = new Data4() ; + static Relate4 slave = new Relate4(); + static Relate4set master = new Relate4set(); + static Tag4 idTag = new Tag4() ; + static Tag4 nameTag = new Tag4(); + + static void openDataFiles( ) + { + codeBase.init( ) ; + + student.open( ref codeBase,"student" ) ; + enrolment.open( ref codeBase,"enroll"); + + nameTag.init( student,"STU_NAME"); + idTag.init( enrolment,"ENR_ID"); + + codeBase.exitTest( ) ; + } + + static void setRelation() + { + master.init( student ) ; + if( master.isValid( ) == 0) codeBase.exit(); + + Relate4 slave = new Relate4( master, enrolment, "ID", idTag) ; + + slave.type( Code4.relate4scan ) ; + master.top( ) ; + // 'slave' falls out of scope, but the relation remains + } + + static void printRecord() + { + Relate4iterator relation = new Relate4iterator( master) ; + Data4 data = new Data4() ; + + for( ; relation.isValid( ) != 0; relation.next( ) ) + { + data = relation.data( ) ; + + for(short j = 1; j <= data.numFields( ); j++ ) + { + Field4memo field = new Field4memo(data, j) ; + Console.WriteLine( field.str( ) ) ; + } + } + Console.WriteLine( "\n" ) ; + } + + static void listRecords() + { + int rc; + + for(rc = master.top( ); rc != Code4.r4eof; rc = master.skip( 1 ) ) + printRecord( ) ; + + Console.WriteLine( "\n" ) ; + + codeBase.unlock( ) ; + } + + [STAThread] + static void Main(string[] args) + { + openDataFiles( ) ; + + setRelation( ) ; + + listRecords( ) ; + + master.free( ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} diff --git a/examples/source/CSharp/RELATE2.cs b/examples/source/CSharp/RELATE2.cs new file mode 100644 index 0000000..bbbfccc --- /dev/null +++ b/examples/source/CSharp/RELATE2.cs @@ -0,0 +1,61 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class RELATE2 + { + static Code4 codeBase = new Code4() ; + static Data4 student = new Data4() ; + + static void openDataFiles( ) + { + student.open( ref codeBase, "student" ) ; + + codeBase.exitTest( ) ; + } + + static void printRecord( Data4 dataFile ) + { + for( short j=1; j <= dataFile.numFields( ); j++ ) + { + Field4memo field = new Field4memo( dataFile, j ) ; + Console.WriteLine( field.str( ) ) ; + } + + Console.WriteLine( "\n" ) ; + } + + static void query(Data4 dataFile + , string expr + , string order ) + { + Relate4set relation = new Relate4set( dataFile ) ; + if( relation.isValid( ) == 0 ) codeBase.exit( ) ; + + relation.querySet( expr ) ; + relation.sortSet( order ) ; + + for( int rc = relation.top( ); rc != Code4.r4eof; rc = relation.skip( 1 ) ) + printRecord( dataFile ) ; + + Console.WriteLine("\n") ; + + codeBase.unlock( ) ; + relation.free( ) ; + } + + [STAThread] + static void Main(string[] args) + { + openDataFiles( ) ; + + query( student, "AGE > 30", "" ) ; + + query( student, "UPPER(L_NAME) = 'MILLER'", "L_NAME + F_NAME" ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/RELATE3.cs b/examples/source/CSharp/RELATE3.cs new file mode 100644 index 0000000..69135a9 --- /dev/null +++ b/examples/source/CSharp/RELATE3.cs @@ -0,0 +1,101 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class RELATE3 + { + static Code4 codeBase = new Code4() ; + static Data4 student = new Data4() ; + static Data4 enrolment = new Data4() ; + static Data4 classes = new Data4() ; + static Field4 studentId ; + static Field4 firstName ; + static Field4 lastName ; + static Field4 age ; + static Field4 classCode ; + static Field4 classTitle ; + static Tag4 idTag = new Tag4() ; + static Tag4 codeTag = new Tag4(); + static Relate4set classRel = new Relate4set() ; + static Relate4 studentRel = new Relate4() ; + static Relate4 enrollRel = new Relate4() ; + + static void openDataFiles() + { + student.open( ref codeBase, "student" ) ; + enrolment.open( ref codeBase, "enroll" ) ; + classes.open( ref codeBase, "classes" ) ; + studentId = new Field4( student, "ID" ) ; + firstName = new Field4( student, "F_NAME" ) ; + lastName = new Field4( student, "L_NAME" ) ; + age = new Field4( student, "AGE" ) ; + classCode = new Field4( classes, "CODE" ) ; + classTitle = new Field4( classes, "TITLE" ) ; + + idTag.init( student, "STU_ID" ) ; + codeTag.init( enrolment, "ENR_CODE" ) ; + + codeBase.exitTest( ) ; + } + + static void printStudents( ) + { + Console.WriteLine(" {0} {1} {2} {3}", + firstName.str( ), lastName.str( ), + studentId.str( ), age.str( ) ) ; + } + + static void setRelation( ) + { + classRel.init( classes ) ; + + enrollRel.init( classRel, enrolment, "CODE", codeTag ) ; + + studentRel.init( enrollRel, student, "STU_ID_TAG", idTag ) ; + } + + static void printStudentList( string expr, int direction ) + { + classRel.querySet( expr ) ; + classRel.sortSet( "student->L_NAME + student->F_NAME" ) ; + + enrollRel.type( Code4.relate4scan ) ; + + int rc, endValue ; + if( direction > 0 ) + { + rc = classRel.top( ) ; + endValue = Code4.r4eof ; + } + else + { + rc = classRel.bottom( ) ; + endValue = Code4.r4bof ; + } + Console.WriteLine("{0} {1}", classCode.str( ), classTitle.str( ) ) ; + + for ( ; rc != endValue ; rc = classRel.skip( direction ) ) + printStudents( ) ; + + Console.WriteLine( "\n" ) ; + } + + [STAThread] + static void Main(string[] args) + { + openDataFiles( ) ; + + setRelation( ) ; + + printStudentList( "CODE = 'MATH114 '", 1 ) ; + + printStudentList( "CODE = 'CMPT411 '", -1 ) ; + + codeBase.unlock( ) ; + classRel.free( ) ; + + codeBase.initUndo( ) ; + } + } +} diff --git a/examples/source/CSharp/RELATE4.cs b/examples/source/CSharp/RELATE4.cs new file mode 100644 index 0000000..0cc3fb8 --- /dev/null +++ b/examples/source/CSharp/RELATE4.cs @@ -0,0 +1,92 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class RELATE3 + { + static Code4 codeBase = new Code4( 0 ) ; + static Data4 student = new Data4() ; + static Data4 enrolment = new Data4() ; + static Field4 id ; + static Field4 fName ; + static Field4 lName ; + static Field4 age ; + static Field4 cCode ; + static Relate4 slave = new Relate4() ; + static Relate4set master = new Relate4set() ; + static Tag4 idTag = new Tag4() ; + static Tag4 nameTag = new Tag4() ; + + static void openDataFiles() + { + codeBase.init( ) ; + + student.open( ref codeBase,"student" ) ; + enrolment.open( ref codeBase,"enroll"); + + id = new Field4( student,"ID"); + fName = new Field4( student,"F_NAME"); + lName = new Field4( student,"L_NAME"); + age = new Field4( student,"AGE"); + cCode = new Field4( enrolment,"C_CODE_TAG"); + + nameTag.init( student,"STU_NAME"); + idTag.init( enrolment,"ENR_ID"); + + codeBase.exitTest( ) ; + } + + static void setRelation() + { + master.init( student ) ; + slave.init( master, enrolment, "ID", idTag); + } + + static void seek( Data4 dataFile, Tag4 tag, Relate4set relation, string key) + { + Tag4 oldTag = new Tag4() ; + + oldTag.initSelected( dataFile ) ; + dataFile.select( tag ) ; + + dataFile.seek( key ) ; + relation.doAll( ) ; + + dataFile.select( oldTag ) ; + } + + static void printRecord() + { + Console.WriteLine("{0} {1} {2} {3} {4}", + fName.str( ), lName.str( ), id.str( ), + age.str( ), cCode.str( )); + } + + [STAThread] + static void Main(string[] args) + { + openDataFiles( ) ; + + setRelation( ) ; + + seek( student + , nameTag + , master, "Tyler Harvey ") ; + + printRecord( ) ; + + seek( student + , nameTag + , master, "Miller Albert "); + + printRecord( ) ; + + codeBase.unlock( ) ; + master.free( ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/REUSE.cs b/examples/source/CSharp/REUSE.cs new file mode 100644 index 0000000..d4e18dc --- /dev/null +++ b/examples/source/CSharp/REUSE.cs @@ -0,0 +1,52 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class REUSE + { + [STAThread] + static void Main(string[] args) + { + Code4 codeBase = new Code4(); + Data4 dataFile = new Data4(); + Field4info fieldInfo = new Field4info( ref codeBase ) ; + + fieldInfo.add( "FIELD1", 'C', 10, 0, 0 ) ; + + codeBase.safety = 0 ; + + dataFile.create(ref codeBase, "recycle", ref fieldInfo ) ; + codeBase.exitTest( ) ; + + Field4 field = new Field4(dataFile, 1); + + dataFile.appendStart(); + field.assign("One"); + dataFile.append(); + + dataFile.appendStart(); + field.assign("Two"); + dataFile.append(); + + dataFile.appendStart(); + field.assign("Three"); + dataFile.append(); + + MessageBox.Show("There are " + dataFile.recCount() + " records", "Information"); + + dataFile.go(2); + dataFile.deleteRec(); + dataFile.flush(); + + dataFile.appendStart(); + field.assign("Four"); + dataFile.append(); + + MessageBox.Show("There are " + dataFile.recCount() + " records", "Information"); + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/SEEKER.cs b/examples/source/CSharp/SEEKER.cs new file mode 100644 index 0000000..7327472 --- /dev/null +++ b/examples/source/CSharp/SEEKER.cs @@ -0,0 +1,141 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class SEEKER + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Field4 fName ; + static Field4 lName ; + static Field4 address ; + static Field4 age ; + static Field4 birthDate ; + static Field4 married ; + static Field4 amount ; + static Field4memo comment ; + + static Tag4 nameTag = new Tag4() ; + static Tag4 ageTag = new Tag4() ; + static Tag4 amountTag = new Tag4() ; + static Tag4 addressTag = new Tag4() ; + static Tag4 birthdateTag = new Tag4() ; + + static void OpenDataFile( ) + { + Field4info fieldInfo = new Field4info( ref codeBase ) ; + + fieldInfo.add( "F_NAME", Code4.r4str, 10, 0, 0 ) ; + fieldInfo.add( "L_NAME", Code4.r4str, 10, 0, 0 ) ; + fieldInfo.add( "ADDRESS", Code4.r4str, 15, 0, 0 ) ; + fieldInfo.add( "AGE", Code4.r4num, 2, 0, 0 ) ; + fieldInfo.add( "BIRTH_DATE", Code4.r4date, 8, 0, 0 ) ; + fieldInfo.add( "MARRIED", Code4.r4log, 1, 0, 0 ) ; + fieldInfo.add( "AMOUNT", Code4.r4num, 7, 2, 0 ) ; + fieldInfo.add( "COMMENT", Code4.r4memo, 10, 0, 0 ) ; + + dataFile.open( ref codeBase, "people.dbf" ) ; + + fName = new Field4( dataFile, "F_NAME") ; + lName = new Field4( dataFile, "L_NAME") ; + address = new Field4( dataFile, "ADDRESS") ; + age = new Field4( dataFile, "AGE") ; + birthDate = new Field4( dataFile, "BIRTH_DATE") ; + married = new Field4( dataFile, "MARRIED") ; + amount = new Field4( dataFile, "AMOUNT") ; + comment = new Field4memo( dataFile, "COMMENT") ; + + nameTag.init( dataFile, "PPL_NAME" ) ; + addressTag.init( dataFile, "PPL_ADDR" ) ; + ageTag.init( dataFile, "PPL_AGE" ) ; + birthdateTag.init( dataFile, "PPL_BRTH" ) ; + amountTag.init( dataFile, "PPL_AMNT" ) ; + } + + static void seekStatus(int rc, ref string status) + { + switch(rc) + { + case Code4.r4success: + status = "r4success" ; + break; + + case Code4.r4eof: + status = "r4eof" ; + break; + + case Code4.r4after: + status = "r4after" ; + break; + + default: + status = "other" ; + break; + } + } + + static void printRecord( int rc ) + { + string bDate ; + string purchased ; + string name ; + string status = ""; + + seekStatus( rc, ref status ) ; + + purchased = amount.str() ; + bDate = birthDate.str( ) ; + name = fName.str( ) ; + name = name.Trim( ) ; + name = name + " " + lName.str( ) ; + + Console.WriteLine( "Seek status : {0}", status ) ; + Console.WriteLine("-------------------------------\nName : {0}\n" + + "Address : {1}\nAge : {2} Married : {3}\nBirth Date: {4}\n" + + "Comment: {5}\nPurchased this year:${6}\n", name.Trim(), address.str( ), + age.str( ), married.str( ), birthDate.str( ), + comment.str( ), purchased ) ; + } + + [STAThread] + static void Main(string[] args) + { + int rc; + + OpenDataFile( ) ; + + dataFile.select( addressTag ) ; + rc = dataFile.seek( "123 - 76 Ave ") ; + printRecord( rc ) ; + + rc = dataFile.seek( "12") ; + printRecord( rc ) ; + + rc = dataFile.seek( "12 ") ; + printRecord( rc ) ; + + dataFile.select( birthdateTag) ; + rc = dataFile.seek( "19581111") ; // October 11, 1958 + printRecord( rc ) ; + + dataFile.select( amountTag) ; + rc = dataFile.seek( 98.99) ; + printRecord( rc ) ; + + rc = dataFile.seek( " 98.99") ; + printRecord( rc ) ; + + //The following code finds all the occurences + //John Albridge in the tag + dataFile.select( nameTag) ; + rc = dataFile.seekNext( "John Albridge ") ; + + for ( ; rc == Code4.r4success; rc = dataFile.seekNext("John Albridge ") ) + printRecord( rc ); + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/SHOWDAT2.cs b/examples/source/CSharp/SHOWDAT2.cs new file mode 100644 index 0000000..8cb0ae3 --- /dev/null +++ b/examples/source/CSharp/SHOWDAT2.cs @@ -0,0 +1,59 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class SHOWDAT2 + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Tag4 tag = new Tag4() ; + + static void printRecords( ) + { + for(int rc = dataFile.top( ); rc == Code4.r4success + ; rc = dataFile.skip( )) + { + for(short j = 1;j <= dataFile.numFields( ); j ++) + { + Field4memo field = new Field4memo( dataFile, j ) ; + Console.WriteLine( field.str( ) ) ; + } + Console.Write( "\n" ) ; + } + } + + [STAThread] + static void Main(string[] args) + { + if (args.Length != 1) + { + Console.WriteLine( "USAGE: SHOWDAT2 " ) ; + } + else + { + dataFile.open( ref codeBase, args.GetValue(0).ToString() ) ; + codeBase.exitTest( ) ; + + Console.WriteLine( "Data File {0} in Natural Order\n", args.GetValue(0) ) ; + printRecords( ) ; + + for( tag.initFirst( dataFile ); tag.isValid( ) != 0 + ; tag.initNext( )) + { + Console.WriteLine( "Press ENTER to continue:" ) ; + Console.ReadLine( ) ; + + Console.WriteLine( "Data File {0} sorted by Tag {1}\n", + args.GetValue(0).ToString(), tag.alias() ) ; + + dataFile.select( tag ) ; + printRecords( ) ; + } + + dataFile.close( ) ; + codeBase.initUndo( ) ; + } + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/SHOWDATA.cs b/examples/source/CSharp/SHOWDATA.cs new file mode 100644 index 0000000..2d10d88 --- /dev/null +++ b/examples/source/CSharp/SHOWDATA.cs @@ -0,0 +1,39 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class SHOWDATA + { + [STAThread] + static int Main(string[] args) + { + if (args.Length != 1) + { + Console.WriteLine( "USAGE: SHOWDATA " ) ; + } + else + { + Code4 codeBase = new Code4() ; + Data4 dataFile = new Data4( codeBase, args.GetValue(0).ToString() ) ; + codeBase.exitTest( ) ; + + int numFields = dataFile.numFields( ) ; + for( int rc = dataFile.top( ); rc == Code4.r4success ; rc = dataFile.skip( )) + { + for( short j = 1; j <= numFields; j++ ) + { + Field4memo field = new Field4memo( dataFile, j ) ; + Console.WriteLine( " {0}", field.str( ) ) ; + } + Console.Write( "\n" ) ; + } + + dataFile.close( ) ; + codeBase.initUndo( ) ; + } + + return 0 ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/SHOWLST2.cs b/examples/source/CSharp/SHOWLST2.cs new file mode 100644 index 0000000..8d94bd9 --- /dev/null +++ b/examples/source/CSharp/SHOWLST2.cs @@ -0,0 +1,105 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class SHOWLST2 + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Field4 fName ; + static Field4 lName ; + static Field4 address ; + static Field4 age ; + static Field4 birthDate ; + static Field4 married ; + static Field4 amount ; + static Field4memo comment ; + static Tag4 nameTag = new Tag4() ; + static Tag4 ageTag = new Tag4() ; + static Tag4 amountTag = new Tag4() ; + static Tag4 addressTag = new Tag4() ; + static Tag4 birthdateTag = new Tag4() ; + + static void OpenDataFile( ) + { + Tag4info tagInfo = new Tag4info( codeBase ) ; + + tagInfo.add( "PPL_NAME", "F_NAME + L_NAME", ".NOT. DELETED()", 0, 0 ) ; + tagInfo.add( "PPL_ADDR", "ADDRESS", "", 0, 0 ) ; + tagInfo.add( "PPL_BRTH", "BIRTH_DATE", "AGE >= 18", 0, 0 ) ; + tagInfo.add( "PPL_AGE", "AGE", "", 0, 0 ) ; + tagInfo.add( "PPL_AMNT", "AMOUNT", "", 0, 0 ) ; + + codeBase.accessMode = Code4.OPEN4DENY_RW ; + codeBase.autoOpen = 0; + codeBase.safety = 0; + + dataFile.open( ref codeBase, "people.dbf" ) ; + + Index4 index = new Index4() ; + index.create( ref dataFile, "SHOWLST2", ref tagInfo ) ; + + fName = new Field4( dataFile, "F_NAME") ; + lName = new Field4( dataFile, "L_NAME") ; + address = new Field4( dataFile, "ADDRESS") ; + age = new Field4( dataFile, "AGE") ; + birthDate = new Field4( dataFile, "BIRTH_DATE") ; + married = new Field4( dataFile, "MARRIED") ; + amount = new Field4( dataFile, "AMOUNT") ; + comment = new Field4memo( dataFile, "COMMENT") ; + + nameTag.init( dataFile, "PPL_NAME") ; + addressTag.init( dataFile, "PPL_ADDR" ) ; + ageTag.init( dataFile, "PPL_AGE") ; + birthdateTag.init( dataFile, "PPL_BRTH" ) ; + amountTag.init( dataFile, "PPL_AMNT") ; + } + + static void PrintRecords( ) + { + string bDate ; + string purchased ; + string name ; + + for( int rc = dataFile.top( ); rc == Code4.r4success; rc = dataFile.skip( )) + { + purchased = amount.str() ; + bDate = birthDate.str( ) ; + name = fName.str( ) ; + name = name.Trim( ) ; + name = name + " " + lName.str( ) ; + + Console.WriteLine("\t\t-------------------------------\n\t\tName : {0}\n" + + "\t\tAddress : {1}\n\t\tAge : {2} Married : {3}\n\t\tBirth Date: {4}\n" + + "\t\tComment: {5}\n\t\tPurchased this year:${6}", name.Trim(), address.str( ), + age.str( ), married.str( ), birthDate.str( ), + comment.str( ), purchased ) ; + } + } + + [STAThread] + static void Main(string[] args) + { + OpenDataFile( ) ; + + dataFile.select( nameTag ) ; + Console.WriteLine( "Order by Name" ) ; + PrintRecords( ) ; + Console.ReadLine( ) ; + + dataFile.select( ageTag ) ; + Console.WriteLine( "Order by Age" ) ; + PrintRecords( ) ; + Console.ReadLine( ) ; + + dataFile.select( amountTag ) ; + Console.WriteLine( "Order by Amount" ) ; + PrintRecords( ) ; + Console.ReadLine( ) ; + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/TRANSFER.cs b/examples/source/CSharp/TRANSFER.cs new file mode 100644 index 0000000..7825d02 --- /dev/null +++ b/examples/source/CSharp/TRANSFER.cs @@ -0,0 +1,111 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class TRANSFER + { + static Code4 codeBase = new Code4() ; + static Data4 dataFile = new Data4() ; + static Field4 acctNo ; + static Field4 balance ; + static Tag4 acctTag = new Tag4() ; + static Tag4 balTag = new Tag4(); + + #if !(S4CLIENT) + static void OpenLogFile( ) + { + int rc ; + + rc = codeBase.logOpen( "", "user1" ); + if ( rc == Code4.r4noOpen ) + { + codeBase.errorCode = 0 ; + codeBase.logCreate( "", "user1" ) ; + } + } + #endif + + static void OpenDataFile( ) + { + dataFile.open( ref codeBase, "bank.dbf" ) ; + acctNo = new Field4( dataFile, "ACCT_NO" ) ; + balance = new Field4( dataFile, "BALANCE" ) ; + + acctTag.init( dataFile, "ACCT_TAG" ) ; + balTag.init( dataFile, "BAL_TAG" ) ; + } + + static int Credit( int toAcct, double amt ) + { + dataFile.select( acctTag ) ; + int rc = dataFile.seek( toAcct ) ; + + if (rc != Code4.r4success ) return rc; + double newBal = balance.getDouble() + amt ; + balance.assignDouble( newBal ) ; + return Code4.r4success ; + } + + static int Debit( int fromAcct, double amt ) + { + return Credit( fromAcct, -amt ) ; + } + + static void Transfer( int fromAcct, int toAcct, double amt ) + { + dataFile.lockAll( ) ; + codeBase.tranStart() ; + + int rc1 = Debit( fromAcct, amt ) ; + int rc2 = Credit( toAcct, amt ); + + if (rc1 == Code4.r4success && rc2 == Code4.r4success) + codeBase.tranCommit() ; + else + codeBase.tranRollback() ; + dataFile.unlock( ) ; + } + + static void PrintRecords( ) + { + for( int rc = dataFile.top(); rc == Code4.r4success; rc = dataFile.skip()) + { + Console.WriteLine( "-----------------------------------\n" + + "Account Number: {0}\nBalance : {1}\n", acctNo.getInt(), balance.getDouble() ) ; + } + Console.WriteLine( "=========================================" ) ; + } + + [STAThread] + static void Main(string[] args) + { + codeBase.errOpen = 0 ; + codeBase.safety = 0 ; + codeBase.lockAttempts = 5 ; + codeBase.lockEnforce = 1 ; + + #if !(S4CLIENT) + OpenLogFile() ; + #endif + + OpenDataFile() ; + + PrintRecords() ; + + // The account number 56789 doesn't exist in the database, + // the transfer is aborted and database is not affected + + Transfer( 12345, 56789, 200.00 ) ; + PrintRecords() ; + + // Both accounts exist so the transfer is completed + // and the database is updated + + Transfer( 12345, 55555, 150.50 ) ; + PrintRecords() ; + + codeBase.initUndo( ) ; + } + } +} diff --git a/examples/source/CSharp/ex0.cs b/examples/source/CSharp/ex0.cs new file mode 100644 index 0000000..4b3f58b --- /dev/null +++ b/examples/source/CSharp/ex0.cs @@ -0,0 +1,29 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex0 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4() ; + Data4 dataFile = new Data4() ; + + settings.autoOpen = 0 ; + settings.memSizeBlock = 0x800 ; // 2048 + settings.memSizeBuffer = 0x2000 ; // 8192 + + settings.errDefaultUnique = Code4.r4unique ; + dataFile.open( ref settings, "INFO" ) ; + + // this is equivalent to calling Code4::exitTest( ) + if( settings.errorCode != 0 ) settings.exit( ) ; + + // ... + + settings.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex1.cs b/examples/source/CSharp/ex1.cs new file mode 100644 index 0000000..e152224 --- /dev/null +++ b/examples/source/CSharp/ex1.cs @@ -0,0 +1,36 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex1 + { + [STAThread] + static void Main(string[] args) + { + Code4 codeBase = new Code4() ; + codeBase.accessMode = Code4.OPEN4DENY_RW ; + codeBase.safety = 0 ; // Ensure the create overwrites any existing file + + Field4info fields = new Field4info( ref codeBase ) ; + + fields.add( "NAME", 'C', 20, 0, 0 ) ; + fields.add( "AGE", 'N', 3, 0, 0 ) ; + fields.add( "BIRTHDATE", 'D', 8, 0, 0 ) ; + + Data4 newDataFile = new Data4() ; + newDataFile.create( ref codeBase, "NEWDBF", ref fields ) ; + + newDataFile.close( ) ; + + // open in shared mode + codeBase.accessMode = Code4.OPEN4DENY_NONE ; + newDataFile.open( ref codeBase, "NEWDBF" ) ; + + // ... some other code ... + + codeBase.closeAll( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex10.cs b/examples/source/CSharp/ex10.cs new file mode 100644 index 0000000..a557931 --- /dev/null +++ b/examples/source/CSharp/ex10.cs @@ -0,0 +1,25 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex10 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + cb.readLock = 1 ; + cb.lockAttempts = 3 ; + + if ( data.top( ) == Code4.r4locked ) + { + Console.WriteLine( "Top record locked by another user" ) ; + Console.WriteLine( "Lock attempted " + cb.lockAttempts + " time(s)" ); + } + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex100.cs b/examples/source/CSharp/ex100.cs new file mode 100644 index 0000000..16f3d2c --- /dev/null +++ b/examples/source/CSharp/ex100.cs @@ -0,0 +1,30 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex100 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4( ) ; + Data4 info = new Data4( settings, "INFO" ) ; + Data4 data = new Data4( settings, "DATA" ) ; + settings.exitTest( ) ; + + Field4 infoName = new Field4( info, "NAME" ) ; + Field4 dataLname = new Field4( data, "LNAME" ) ; + + info.lockAddAll( ) ; + data.lockAddAll( ) ; + settings.lockGroup( ) ; + for( info.top( ) , data.top( ) ; info.eof( ) == 0 && data.eof( ) == 0 ; + info.skip( ) ,data.skip( ) ) + dataLname.assignField( ref infoName ) ; // copy 'LNAME' into 'NAME' + + settings.closeAll( ) ; + settings.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex101.cs b/examples/source/CSharp/ex101.cs new file mode 100644 index 0000000..ca5bb8a --- /dev/null +++ b/examples/source/CSharp/ex101.cs @@ -0,0 +1,31 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex101 + { + static void displayFieldStats( Field4 f ) + { + Data4 db = new Data4( f.data( ) ) ; + + Console.WriteLine( "-----------------------------------------------------" ) ; + Console.WriteLine( "Database: {0} Field: {1}\nLength: {2} Type: {3}\nDecimals: {4}" + , db.alias, f.name( ), f.len( ), f.type( ), f.decimals( ) ) ; + Console.WriteLine( "-----------------------------------------------------\n" ) ; + + return ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.readOnly = 1 ; + Data4 data = new Data4( cb, "INFO" ) ; + Field4 field = new Field4( data, "NAME" ) ; + displayFieldStats( field ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex102.cs b/examples/source/CSharp/ex102.cs new file mode 100644 index 0000000..4f8a286 --- /dev/null +++ b/examples/source/CSharp/ex102.cs @@ -0,0 +1,26 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex102 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.readOnly = 1 ; + Data4 data = new Data4( cb, "INFO" ) ; + + // Display all of the field names + for( short i = 1 ; i <= data.numFields( ) ; i++ ) + { + Field4 field = new Field4( data, i ) ; + Console.WriteLine( field.name( ) ) ; + } + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex104.cs b/examples/source/CSharp/ex104.cs new file mode 100644 index 0000000..a6f5fd1 --- /dev/null +++ b/examples/source/CSharp/ex104.cs @@ -0,0 +1,25 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex104 + { + static void displayField( Field4 field ) + { + Console.WriteLine( "{0} {1}\n", field.name( ), field.str( ) ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.readOnly = 1 ; + Data4 data = new Data4( cb, "INFO" ) ; + Field4 field = new Field4( data, "NAME" ) ; + data.top( ) ; + displayField( field ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex105.cs b/examples/source/CSharp/ex105.cs new file mode 100644 index 0000000..69ae282 --- /dev/null +++ b/examples/source/CSharp/ex105.cs @@ -0,0 +1,31 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex105 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 oneDbf = new Data4( ) ; + Field4info fields = new Field4info( ref cb ) ; + cb.safety = 0 ; + + fields.add( "NAME", 'C', 20, 0, 0 ) ; + fields.add( "AGE", 'N', 3, 0, 0 ) ; + fields.add( "BDATE", 'D', 8, 0, 0 ) ; + + oneDbf.create( ref cb, "EX105_1", ref fields ) ; + + if( cb.errorCode == 0 ) + Console.WriteLine( "Created successfully\n" ) ; + else + Console.WriteLine( "An error occurred\n" ) ; + + fields.free( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex106.cs b/examples/source/CSharp/ex106.cs new file mode 100644 index 0000000..5204f88 --- /dev/null +++ b/examples/source/CSharp/ex106.cs @@ -0,0 +1,27 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex106 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "INFO" ) ; + Data4 data2 = new Data4( ) ; + + cb.safety = 0 ; + Field4info fields = new Field4info( data ) ; + fields.add( "COMMENT", 'M', 8, 0, 0 ) ; + + data2.create( ref cb, "DATA2", ref fields ) ; + + if( cb.errorCode == 0 ) + Console.WriteLine( "Created successfully\n" ) ; + fields.free( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex107.cs b/examples/source/CSharp/ex107.cs new file mode 100644 index 0000000..0d60278 --- /dev/null +++ b/examples/source/CSharp/ex107.cs @@ -0,0 +1,31 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex107 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Field4info fields = new Field4info( ref cb ) ; // initialize with no fields + + fields.add( "NAME", 'C', 20, 0, 0 ) ; + fields.add( "AGE", 'N', 3, 0, 0 ) ; + fields.add( "REGISTER", 'L', 1, 0, 0 ) ; + fields.add( "birth", 'D', 8, 0, 0 ) ; + + // change your mind and delete them all + if( fields.del( "nome " ) < 0 ) + Console.WriteLine( "This will always happen" ) ; + fields.del( "name" ) ; + fields.del( 0 ) ; // delete the 'AGE' field + fields.del( 0 ) ; // delete the 'REGISTER' field + + fields.free( ) ; // delete all remaining + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex108.cs b/examples/source/CSharp/ex108.cs new file mode 100644 index 0000000..6876565 --- /dev/null +++ b/examples/source/CSharp/ex108.cs @@ -0,0 +1,30 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex108 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Field4info fields = new Field4info( ref cb ) ; // initialize with no fields + + fields.add( "NAME", 'C', 20, 0, 0 ) ; + fields.add( "AGE", 'N', 3, 0, 0 ) ; + fields.add( "REGISTER", 'L', 1, 0, 0 ) ; + fields.add( "birth", 'D', 8, 0, 0 ) ; + + Data4 data = new Data4( ) ; + cb.safety = 0 ; // overwrite existing DATAFILE.DBF + + data.create( ref cb, "DATAFILE", ref fields ) ; + if( data.isValid( ) == 1 && data.numFields( ) == 4 ) + Console.WriteLine( "CREATED SUCCESSFULLY" ) ; + + fields.free( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex109.cs b/examples/source/CSharp/ex109.cs new file mode 100644 index 0000000..81e6c87 --- /dev/null +++ b/examples/source/CSharp/ex109.cs @@ -0,0 +1,23 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex109 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "INFO" ) ; + Field4info fields = new Field4info( data ) ; + + if( data.numFields( ) == fields.numFields( ) ) + Console.WriteLine( "A copy has been made of the fields" ) ; + else + Console.WriteLine( "An error must have occurred." ) ; + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex11.cs b/examples/source/CSharp/ex11.cs new file mode 100644 index 0000000..94191b8 --- /dev/null +++ b/examples/source/CSharp/ex11.cs @@ -0,0 +1,47 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex11 + { + static int itemsToRestock( ref Code4 cb ) + { + short oldOpt = cb.optimize ; // save old optimization setting. + short oldExcl = cb.accessMode ; + cb.optimize = Code4.OPT4EXCLUSIVE ; + cb.accessMode = Code4.OPEN4DENY_RW ;//open files exclusively + + Data4 inventory = new Data4( cb, "INVENT.DBF" ) ; // Read optimized + Field4 minOnHand = new Field4( inventory, "MIN_ON_HND" ) ; + Field4 onHand = new Field4( inventory, "ON_HAND" ) ; + Field4 stockName = new Field4( inventory, "ITEM" ) ; + int count = 0 ; + + if ( cb.errorCode >= 0 ) + { + cb.optStart( ) ; + + for( inventory.top( ) ; inventory.eof( ) == 0 ; inventory.skip( ) ) + if( onHand.getInt() < minOnHand.getInt() ) + count++ ; + Console.WriteLine( count + " items must be restocked" ) ; + } + cb.optSuspend( ) ; + cb.optimize = oldOpt ; + cb.accessMode = oldExcl ; + inventory.close( ) ; + return count ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 codebase = new Code4() ; + + itemsToRestock( ref codebase ) ; + codebase.initUndo() ; + } + + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex110.cs b/examples/source/CSharp/ex110.cs new file mode 100644 index 0000000..c168380 --- /dev/null +++ b/examples/source/CSharp/ex110.cs @@ -0,0 +1,33 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex110 + { + static void dumpDataFileToScreen( Data4 d ) + { + // dump all fields -- including memo fields -- to screen + Console.WriteLine( "Contents of: {0}", d.alias ) ; + for( d.top( ) ; d.eof( ) == 0 ; d.skip( ) ) + { + for( short j = 1 ; j <= d.numFields( ) ; j++ ) + { + Field4memo field = new Field4memo( d, j ) ; + Console.WriteLine( field.str( ) ) ; + } + Console.WriteLine( ); + } + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.readOnly = 1 ; + Data4 data = new Data4( cb, "INFO" ) ; + dumpDataFileToScreen( data ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex111.cs b/examples/source/CSharp/ex111.cs new file mode 100644 index 0000000..762e545 --- /dev/null +++ b/examples/source/CSharp/ex111.cs @@ -0,0 +1,25 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex111 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "DATA3" ) ; + Field4memo comments = new Field4memo( data, "COMMENTS" ) ; + + cb.exitTest( ) ; + int count = 0 ; + for( data.top( ) ; data.eof( ) == 0 ; data.skip( ) ) + if( comments.len( ) > 0 ) + count ++ ; + + Console.WriteLine( "There were {0} memo entries out of {1} records.", count, data.recCount( ) ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex112.cs b/examples/source/CSharp/ex112.cs new file mode 100644 index 0000000..4fd0ff9 --- /dev/null +++ b/examples/source/CSharp/ex112.cs @@ -0,0 +1,27 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex112 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "DATA3" ) ; + Field4memo comments = new Field4memo( data, "COMMENTS" ) ; + Field4memo name = new Field4memo( data, "NAME" ) ; + + data.top( ) ; + // display the null terminated contents of the memo field + Console.WriteLine( "Memo field contents: {0}", comments.str( ) ) ; + + // display the non-null terminated contents of the NAME field. + // this displays NAME plus any additional fields in the record buffer + Console.WriteLine( "NAME field contents: {0}", name.str( ) ) ; + + cb.initUndo( ) ; // close all files and free memory + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex113.cs b/examples/source/CSharp/ex113.cs new file mode 100644 index 0000000..6fd2b43 --- /dev/null +++ b/examples/source/CSharp/ex113.cs @@ -0,0 +1,34 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex113 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "DATA3" ) ; + + data.top( ) ; + Field4memo comments = new Field4memo( data, "COMMENTS" ) ; + data.lockAll( ) ; + comments.setLen( 0x4000 ) ; // 16K + comments.assign( "First characters of a 16k memo field" ) ; + + // Flush changes to disk and close the data and memo files + data.close( ) ; + + data.open( ref cb, "DATA3" ) ; + comments = new Field4memo( data, "COMMENTS" ) ; + data.top( ) ; + + Console.WriteLine( "Memo field Value:\n{0}\nLength of memo field: {1}", + comments.str( ), comments.len( ) ) ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex114.cs b/examples/source/CSharp/ex114.cs new file mode 100644 index 0000000..255c7d4 --- /dev/null +++ b/examples/source/CSharp/ex114.cs @@ -0,0 +1,32 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex114 + { + static void displayTheRecord( Data4 d ) + { + int numFields = d.numFields( ) ; + short curField = 1 ; + + for( ; curField <= numFields; curField++ ) + { + Field4memo genericField = new Field4memo( d, curField ) ; + + Console.WriteLine( "{0}\t", genericField.str( ) ) ; + } + Console.WriteLine( ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "DATA2" ) ; + data.top( ) ; + displayTheRecord( data ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex13.cs b/examples/source/CSharp/ex13.cs new file mode 100644 index 0000000..7d5f975 --- /dev/null +++ b/examples/source/CSharp/ex13.cs @@ -0,0 +1,43 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex13 + { + static int retry( ) + { + string rc ; + Console.WriteLine( "Record locked by another user." ) ; + Console.WriteLine( "Retry? (Y or N)" ) ; + rc = Console.ReadLine() ; + if ( rc == "N" ) + return 0 ; + + return 1 ; + } + + static int lockARecord( Data4 d, int rec ) + { + int rc ; + while( ((rc = d.go( rec )) == Code4.r4locked) && (retry( ) == 1) ) ; + + if ( rc == Code4.r4locked ) + return 0 ; + + return 1 ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + lockARecord( data, 3 ) ; + + // other code + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex135.cs b/examples/source/CSharp/ex135.cs new file mode 100644 index 0000000..2763685 --- /dev/null +++ b/examples/source/CSharp/ex135.cs @@ -0,0 +1,28 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex135 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + + // automatically open the INFO production index file + Data4 data = new Data4( cb, "INFO" ) ; + + // Copy the Index4 object for the production index file + Index4 info = data.index( "INFO" ) ; + + cb.errOpen = 0 ; + Index4 names = new Index4( data, "NOT" ) ; // attempt a second index file + if( names.isValid( ) == 0 ) + Console.WriteLine( "Index file could not be opened\n"); + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex136.cs b/examples/source/CSharp/ex136.cs new file mode 100644 index 0000000..dd14e6c --- /dev/null +++ b/examples/source/CSharp/ex136.cs @@ -0,0 +1,40 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex136 + { + static int addLotsOfRecords( Data4 d ) + { + // get the secondary index file + Index4 index = d.index( "INFO2" ) ; + if( index.isValid( ) > 0 ) + index.close( ) ; + + d.top( ) ; + for( int i = 200 ; i != 1 ; i -- ) + { + // make 200 copies of record 1 + d.appendStart() ; + d.append( ) ; + } + + // open the index file and update it + index.open( d, d.alias ) ; + return index.reindex( ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.autoOpen = 0 ; + Data4 data = new Data4( cb, "INFO" ) ; + Index4 index = new Index4( ) ; + index.open( data, "INFO2" ) ; + addLotsOfRecords( data ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex137.cs b/examples/source/CSharp/ex137.cs new file mode 100644 index 0000000..a477077 --- /dev/null +++ b/examples/source/CSharp/ex137.cs @@ -0,0 +1,32 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex137 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( ) ; + Index4 index = new Index4( ); + + Field4info fieldInfo = new Field4info(ref cb ) ; + fieldInfo.add("FIELD_NAME", 'C', 10, 0, 0 ) ; + fieldInfo.add( "VALUE", 'N', 7, 2, 0) ; + + Tag4info tagInfo = new Tag4info( cb ) ; + tagInfo.add( "T_NAME", "FIELD_NAME", "FIELD_NAME > 'A'", 0, 0 ) ; + tagInfo.add( "NAME_TWO", "VALUE", "", Code4.e4unique, Code4.r4descending ) ; + + cb.safety = 0 ; + data.create( ref cb, "DB_NAME", ref fieldInfo ) ; + if ( data.isValid( ) != 0 ) + index.create( ref data, "name", ref tagInfo ) ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex138.cs b/examples/source/CSharp/ex138.cs new file mode 100644 index 0000000..2c1929a --- /dev/null +++ b/examples/source/CSharp/ex138.cs @@ -0,0 +1,27 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex138 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.autoOpen = 0 ; // don't automatically open index file + Data4 data = new Data4( cb, "INFO" ) ; + + Index4 index = new Index4( ) ; + index.open( data, "INFO2" ) ; // open a secondary index file + + cb.lockAttempts = Code4.WAIT4EVER ; // wait until the lock succeeds + data.lockAll( ) ; + if( index.reindex( ) == 0 ) + Console.WriteLine( "Reindexed successfully" ) ; + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex14.cs b/examples/source/CSharp/ex14.cs new file mode 100644 index 0000000..177a138 --- /dev/null +++ b/examples/source/CSharp/ex14.cs @@ -0,0 +1,30 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex14 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + cb.readOnly = 1 ; + Tag4 tag = new Tag4() ; + + // This example assumes that drive W is a read-only drive. + Data4 prices = new Data4( cb, "w:\\datafile.DBF" ) ; + cb.exitTest( ) ; + + tag.initFirst( prices ) ; + prices.select( tag ) ; + if( prices.seek( "SMITH" ) == 0 ) + Console.WriteLine( "SMITH is found" ) ; + else + Console.WriteLine( "SMITH is not found" ) ; + + prices.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex140.cs b/examples/source/CSharp/ex140.cs new file mode 100644 index 0000000..ddffd84 --- /dev/null +++ b/examples/source/CSharp/ex140.cs @@ -0,0 +1,48 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex140 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 enroll = new Data4( cb, "ENROLL" ) ; + Data4 master = new Data4( cb, "CLASSES" ) ; + Data4 student = new Data4( cb, "STUDENT" ) ; + + Tag4 enrollTag = new Tag4( enroll, "ENR_CODE" ) ; + Tag4 studentTag = new Tag4( student, "STU_ID" ) ; + + Relate4set MasterRelation = new Relate4set( master ) ; + Relate4 relation1 = new Relate4( MasterRelation, enroll, "CODE", enrollTag ) ; + Relate4 relation2 = new Relate4( relation1, student, "STU_ID_TAG", studentTag ) ; + + relation1.type( Code4.relate4scan ) ; + MasterRelation.sortSet( "STUDENT->L_NAME,8,0)+ENROLL->CODE" ) ; + + Field4 classCode = new Field4( master, "CODE" ) ; + Field4 classTitle = new Field4( master, "TITLE" ) ; + Field4 enrollStudentId = new Field4( enroll, "STU_ID_TAG") ; + Field4 studentName = new Field4( student, "L_NAME" ) ; + + cb.exitTest( ) ; + + for(int rc = MasterRelation.top( ); rc != Code4.r4eof + ; rc = MasterRelation.skip( 1 ) ) + { + Console.WriteLine( "{0} ", studentName.str( ) ) ; // only one Str4::str per stmt. + Console.WriteLine( "{0} ", enrollStudentId.str( ) ) ; + Console.WriteLine( "{0} ", classCode.str( ) ) ; + Console.WriteLine( "{0}\n", classTitle.str( ) ) ; + } + + Console.WriteLine( "Number of records in {0} {1}", master.alias, master.recCount( ) ) ; + + MasterRelation.free( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex141.cs b/examples/source/CSharp/ex141.cs new file mode 100644 index 0000000..dbb552c --- /dev/null +++ b/examples/source/CSharp/ex141.cs @@ -0,0 +1,43 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex141 + { + static int seekMaster( Relate4 r, Tag4 masterTag, string seekKey ) + { + Data4 master = r.master( ).data( ) ; + master.select( masterTag ) ; + int rc = master.seek( seekKey ) ; // seek for the requested value + + if( rc == Code4.r4success ) + r.doOne( ) ; // position the slave data file to the appropriate + // record + return rc ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 enroll = new Data4( cb, "ENROLL" ) ; + Data4 master = new Data4( cb, "CLASSES" ) ; + Data4 student = new Data4( cb, "STUDENT" ) ; + + Tag4 enrollTag = new Tag4( enroll, "ENR_CODE" ) ; + Tag4 studentTag = new Tag4( student, "STU_ID" ) ; + Tag4 classTag = new Tag4( master, "CODE_TAG" ) ; + + Relate4set MasterRelation = new Relate4set( master ) ; + Relate4 relation1 = new Relate4( MasterRelation, enroll, "CODE", enrollTag ) ; + Relate4 relation2 = new Relate4( relation1, student, "STU_ID_TAG", studentTag ) ; + + relation1.type( Code4.relate4scan ) ; + + seekMaster( relation1, classTag, "CMPT401" ) ; + MasterRelation.free( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex142.cs b/examples/source/CSharp/ex142.cs new file mode 100644 index 0000000..44d062a --- /dev/null +++ b/examples/source/CSharp/ex142.cs @@ -0,0 +1,40 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex142 + { + static void listFilesInRelation( Relate4set rel ) + { + Relate4iterator relation = new Relate4iterator( rel ) ; + + for( ; relation.isValid( ) != 0 ; relation.next( ) ) + Console.WriteLine( "{0}\n", relation.data( ).alias ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 enroll = new Data4( cb, "ENROLL" ) ; + Data4 master = new Data4( cb, "CLASSES" ) ; + Data4 student = new Data4( cb, "STUDENT" ) ; + + Tag4 enrollTag = new Tag4( enroll, "ENR_CODE" ) ; + Tag4 studentTag = new Tag4( student, "STU_ID" ) ; + Tag4 classTag = new Tag4( master, "CODE_TAG" ) ; + + Relate4set MasterRelation = new Relate4set( master ) ; + Relate4 relation1 = new Relate4( MasterRelation, enroll, "CODE", enrollTag ) ; + Relate4 relation2 = new Relate4( relation1, student, "STU_ID_TAG", studentTag ) ; + + relation1.type( Code4.relate4scan ) ; + + listFilesInRelation( MasterRelation ) ; + + MasterRelation.free( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex143.cs b/examples/source/CSharp/ex143.cs new file mode 100644 index 0000000..9e0d073 --- /dev/null +++ b/examples/source/CSharp/ex143.cs @@ -0,0 +1,49 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex143 + { + static void displayRelationTree( Relate4 relate ) + { + int pos = 0 ; + Relate4iterator tree = new Relate4iterator( relate ) ; + + for(; tree.isValid( ) != 0; ) + { + for( int i = pos; i > 0; i-- ) + Console.Write( " " ); + Console.Write( "{0}\n", tree.data( ).fileName( ) ) ; + + pos += tree.nextPosition( ) ; + } + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 master = new Data4( cb, "M1" ) ; + Data4 sl1 = new Data4( cb, "SL1" ) ; + Data4 sl2 = new Data4( cb, "SL2" ) ; + Data4 sl3 = new Data4( cb, "SL3" ) ; + Data4 sl4 = new Data4( cb, "SL4" ) ; + + Relate4set MasterRelation = new Relate4set( master ) ; + + // create the tree + Relate4 relate1 = new Relate4( MasterRelation, sl1, "TOSL1", new Tag4( sl1, "FRM" ) ) ; + Relate4 relate2 = new Relate4( MasterRelation, sl2, "TOSL2", new Tag4( sl2, "FRM") ) ; + Relate4 relate3 = new Relate4( relate2, sl3, "TOSL3", new Tag4( sl3, "FRMSL2" ) ) ; + Relate4 relate4 = new Relate4( MasterRelation, sl4, "TOSL4", new Tag4( sl4, "FRM" ) ) ; + cb.exitTest( ) ; + + MasterRelation.top( ) ; + displayRelationTree( MasterRelation ) ; + + MasterRelation.free( 1 ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex144.cs b/examples/source/CSharp/ex144.cs new file mode 100644 index 0000000..24e8250 --- /dev/null +++ b/examples/source/CSharp/ex144.cs @@ -0,0 +1,49 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex144 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + + Data4 employee = new Data4( cb, "EMPLOYEE" ) ; + Data4 office = new Data4( cb, "OFFICE" ) ; + Data4 building = new Data4( cb, "BUILDING" ) ; + + // Set up the tags. + Tag4 officeNo = new Tag4( office, "OFF_NUM" ) ; + Tag4 buildNo = new Tag4( building, "BUILD_NO" ) ; + + // Create the relations + Relate4set master = new Relate4set( employee ) ; + + Relate4 toOffice = new Relate4( master, office, "EMPLOYEE->OFFICE_NO", officeNo ) ; + Relate4 toBuilding = new Relate4( toOffice, building, "OFFICE->BUILD_NO", buildNo ) ; + + // Go to employee, at record 2 + employee.go( 2 ) ; + + // Lock the data files and their index files. + master.lockAdd( ) ; + cb.lockGroup( ) ; + + // This call causes the corresponding records in data files "OFFICE" and + // "BUILDING" to be looked up. + master.doAll( ) ; + + // Go to office, at record 3 + office.go( 3 ) ; + + // This call causes the building record to be looked up from the office + toBuilding.doOne( ) ; + + // .. and so on + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex145.cs b/examples/source/CSharp/ex145.cs new file mode 100644 index 0000000..cd6e026 --- /dev/null +++ b/examples/source/CSharp/ex145.cs @@ -0,0 +1,27 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex145 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 info = new Data4( cb, "INFO" ) ; + + Relate4set TopMaster = new Relate4set( info ) ; + // ... other code ... + + // This relation tree is no longer needed. Create a new one + TopMaster.free( ) ; + TopMaster.init( info ) ; + + // ... other code ... + TopMaster.free( 1 ) ; // Automatically close all files in the relation + cb.closeAll( ) ; // close any remaining files + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex15.cs b/examples/source/CSharp/ex15.cs new file mode 100644 index 0000000..158ab1d --- /dev/null +++ b/examples/source/CSharp/ex15.cs @@ -0,0 +1,34 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex15 + { + static int createFiles( ref Code4 cb ) + { + Field4info fields = new Field4info( ref cb ) ; + + fields.add( "NAME", 'C', 20, 0, 0 ) ; + fields.add( "AGE", 'N', 3, 0, 0 ) ; + fields.add( "BIRTHDATE", 'D', 0, 0, 0 ) ; + + Tag4info tags = new Tag4info( cb ) ; + tags.add( "INF1_NME", "NAME", "", 0, 0 ) ; + + cb.safety = 0 ; // Turn off safety -- overwrite files + Data4 data = new Data4() ; + data.create( ref cb, "INFO1.DBF", ref fields, ref tags ) ; + + return cb.errorCode ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 code = new Code4() ; + createFiles( ref code ) ; + code.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex17.cs b/examples/source/CSharp/ex17.cs new file mode 100644 index 0000000..77bfc7f --- /dev/null +++ b/examples/source/CSharp/ex17.cs @@ -0,0 +1,29 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex17 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 db = new Data4( cb, "DATA" ) ; + db.top( ) ; + + Expr4 ex = new Expr4( db, "TRIM(LNAME)+', '+TRIM(FNAME)" ) ; + cb.calcCreate( ex, "NAMES" ) ; + Console.WriteLine( ex.str( ) ) ; + + Expr4 ex2 = new Expr4() ; + ex2.parse( db, "'HELLO '+NAMES()" ) ; // no space in dBASE function calls. + + Console.WriteLine( ex2.str( ) ) ; + + ex2.free( ) ; + cb.calcReset( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex18.cs b/examples/source/CSharp/ex18.cs new file mode 100644 index 0000000..d503f26 --- /dev/null +++ b/examples/source/CSharp/ex18.cs @@ -0,0 +1,28 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex18 + { + static void openAFile( ref Code4 cb ) + { + // 'd' falls out of scope. Data file is still open + Data4 d = new Data4( cb, "INFO" ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + cb.autoOpen = 0 ; + openAFile( ref cb ) ; + + Data4 d = new Data4( cb, "DATAFILE" ) ; // open a second file + Console.WriteLine( "Number of records in DATAFILE: " + d.recCount( ) ) ; + + cb.closeAll( ) ; // INFO and DATAFILE are both closed + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex184.cs b/examples/source/CSharp/ex184.cs new file mode 100644 index 0000000..4352a8c --- /dev/null +++ b/examples/source/CSharp/ex184.cs @@ -0,0 +1,29 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex184 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.readOnly = 1 ; + Data4 data = new Data4( cb, "INFO" ) ; + cb.exitTest( ) ; + + // get the reference to the "INF_NAME" tag + Tag4 tag = new Tag4( data, "INF_NAME" ) ; + + data.select( tag ) ; // select the "INF_NAME" ordering + for( data.top( ) ; data.eof( ) == 0 ; data.skip( ) ) + { + Field4 field = new Field4( data, "NAME" ) ; + Console.WriteLine( "{0}\n", field.str( ) ) ; // List out the NAMES + } + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex186.cs b/examples/source/CSharp/ex186.cs new file mode 100644 index 0000000..6e7979a --- /dev/null +++ b/examples/source/CSharp/ex186.cs @@ -0,0 +1,26 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex186 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4( ) ; + Data4 info = new Data4( settings, "INFO" ) ; + + // List the names of the tags in any production index file corresponding + // to "INFO" + + Console.WriteLine( "Production index file tags for data file: {0}\n", info.alias ) ; + + Tag4 tag = new Tag4( ) ; + for( tag.initFirst( info ); tag.isValid( ) != 0; tag.initNext( )) + Console.WriteLine( "Tag name: {0}\n", tag.alias( ) ) ; + + settings.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex187.cs b/examples/source/CSharp/ex187.cs new file mode 100644 index 0000000..ef6991e --- /dev/null +++ b/examples/source/CSharp/ex187.cs @@ -0,0 +1,43 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex187 + { + static int searchAll( Data4 d, string myValue ) + { + Tag4 origTag = new Tag4( ) ; + Tag4 tag = new Tag4( ) ; + origTag.initSelected( d ) ; // Save the current tag + int origRecNo = d.recNo( ) ; + + for( tag.initLast( d ) ; tag.isValid( ) != 0; tag.initPrev( ) ) + { + d.select( tag ) ; + if( d.seek( myValue ) == 0 ) + { + d.select( origTag ) ; + return d.recNo( ) ; + } + } + d.select( origTag ) ; + d.go( origRecNo ) ; + return -1 ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "INFO" ) ; + data.top( ) ; + int rc = searchAll( data, "Abbot" ) ; + for( short j = 1; j < data.numFields( ); j++ ) + Console.Write( new Field4memo( data, j).str( ) ) ; + + Console.WriteLine( "\n{0} is the record number", rc ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex188.cs b/examples/source/CSharp/ex188.cs new file mode 100644 index 0000000..9943cf3 --- /dev/null +++ b/examples/source/CSharp/ex188.cs @@ -0,0 +1,30 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex188 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + + // open the datafile but not the index file + cb.autoOpen = 0 ; + Data4 data = new Data4( cb, "INFO" ) ; + + Tag4info tags = new Tag4info( cb ) ; + tags.add( "retired", "age", "age>55", 0, Code4.r4descending) ; + tags.add( "inf_name", "name", "", Code4.r4uniqueContinue, 0 ) ; + + Index4 index = new Index4( ) ; + cb.safety = 0 ; // overwrite an existing file + index.create( ref data, "INFO2", ref tags ) ; + if( cb.errorCode != 0 ) + Console.WriteLine( "An error occurred" ) ; + + cb.initUndo( ) ; // Tag4info destructor called + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex189.cs b/examples/source/CSharp/ex189.cs new file mode 100644 index 0000000..4d1890e --- /dev/null +++ b/examples/source/CSharp/ex189.cs @@ -0,0 +1,26 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex189 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "DATA1" ) ; + short j ; + + /* list the fields that are character fields */ + for (j = 1 ; j < data.numFields( ) ; j++ ) + { + Field4 field = new Field4( data, j ) ; + if ( field.type( ) == Code4.r4str ) + Console.WriteLine( field.name( ) ) ; + } + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex19.cs b/examples/source/CSharp/ex19.cs new file mode 100644 index 0000000..80e34d8 --- /dev/null +++ b/examples/source/CSharp/ex19.cs @@ -0,0 +1,32 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex19 + { + static void openAFile( ref Code4 cb ) + { + // 'd' falls out of scope. Data file is still open + Data4 d = new Data4( cb, "INFO" ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + openAFile( ref cb ) ; + + Data4 d = cb.data( "INFO" ) ; // obtain a new Data4 object + + if( d.isValid( ) != 0 ) + { + Console.WriteLine( "INFO has " + d.recCount( ) + " records." ) ; + + d.top( ) ; + cb.data( "INFO" ).close( ) ; // an alternate way to close the file + } + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex2.cs b/examples/source/CSharp/ex2.cs new file mode 100644 index 0000000..39a30d4 --- /dev/null +++ b/examples/source/CSharp/ex2.cs @@ -0,0 +1,31 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex2 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4(); + + // Do not automatically open production index file + cb.autoOpen = 0 ; + Data4 info = new Data4( cb, "INFO.DBF" ) ; + Index4 infoIndex = info.index("INFO") ; + + if( infoIndex.isValid() == 0 ) + Console.WriteLine( "Production index file is not opened" ) ; + + // DATA.DBF has a production index. Open it + cb.autoOpen = 1 ; + Data4 data = new Data4( cb, "DATA.DBF" ) ; + + // Some other code + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex20.cs b/examples/source/CSharp/ex20.cs new file mode 100644 index 0000000..13860b7 --- /dev/null +++ b/examples/source/CSharp/ex20.cs @@ -0,0 +1,27 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex20 + { + static int display( ref Code4 cb, string p ) + { + if( p.Length == 0 ) + return cb.error( Code4.e4parm, 0, "Null display string", "", "" ) ; + + Console.WriteLine( p ) ; + return 0 ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 code = new Code4() ; + string someString = "Hello There" ; + display( ref code, someString ); + display( ref code, "" ) ; + code.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex21.cs b/examples/source/CSharp/ex21.cs new file mode 100644 index 0000000..70250de --- /dev/null +++ b/examples/source/CSharp/ex21.cs @@ -0,0 +1,22 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex21 + { + static void exitToSystem( ref Code4 cb ) + { + Console.WriteLine( "Shutting down application ... " ) ; + cb.closeAll( ) ; + cb.exit( ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + exitToSystem( ref cb ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex22.cs b/examples/source/CSharp/ex22.cs new file mode 100644 index 0000000..b60ae0e --- /dev/null +++ b/examples/source/CSharp/ex22.cs @@ -0,0 +1,19 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex22 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "FILE" ) ; + cb.exitTest( ) ; // the application will exit if FILE cannot be opened + + // ... other code ... + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex23.cs b/examples/source/CSharp/ex23.cs new file mode 100644 index 0000000..3efa704 --- /dev/null +++ b/examples/source/CSharp/ex23.cs @@ -0,0 +1,32 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex23 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data1 = new Data4( cb, "DATA1" ) ; + Data4 data2 = new Data4( cb, "DATA2" ) ; + + data1.top( ) ; + data2.top( ) ; + + data1.lockAddFile( ) ; + data2.lockAddAppend( ) ; + + int numRecords = data2.recCount( ) ; + data2.lockAdd( numRecords ) ; + data2.lockAdd( numRecords-1 ) ; + data2.lockAdd( numRecords-2 ) ; + + if( cb.lockGroup( ) == Code4.r4success ) + Console.WriteLine( "All locks were successfully performed" ) ; + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex24.cs b/examples/source/CSharp/ex24.cs new file mode 100644 index 0000000..660d02b --- /dev/null +++ b/examples/source/CSharp/ex24.cs @@ -0,0 +1,28 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex24 + { + [STAThread] + static void Main(string[] args) + { + Code4 code = new Code4() ; + code.accessMode = Code4.OPEN4DENY_RW ; + + Data4 dataFile = new Data4( code, "INFO" ) ; + code.exitTest( ) ; + + // initialize optimization with default settings. + code.optStart( ) ; + int delCount = 0 ; + for ( int rc = dataFile.top( ); rc == Code4.r4success ; rc = dataFile.skip( ) ) + if( dataFile.deleted( ) != 0 ) + delCount++ ; + + Console.WriteLine( delCount + " records are marked for deletion." ) ; + code.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex25.cs b/examples/source/CSharp/ex25.cs new file mode 100644 index 0000000..8e94dd7 --- /dev/null +++ b/examples/source/CSharp/ex25.cs @@ -0,0 +1,30 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex25 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + data.lockAll( ) ; + data.optimizeWrite( 1 ) ; + cb.optStart( ) ; + // .. some other code + + cb.optSuspend( ) ; // flush & free optimization memory. + data.unlock( ) ; // let other users make modifications. + + // ... some other code + + cb.optStart( ) ; + + // ... other code + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex26.cs b/examples/source/CSharp/ex26.cs new file mode 100644 index 0000000..4ede5b0 --- /dev/null +++ b/examples/source/CSharp/ex26.cs @@ -0,0 +1,24 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex26 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 info = new Data4( cb, "INFO" ) ; + Data4 data = new Data4( cb, "DATAFILE" ) ; + + info.lockRecord( 1 ) ; + data.lockAll( ) ; + + if ( cb.unlock() == Code4.r4success ) + Console.WriteLine( "Successfully unlocked" ) ; + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex27.cs b/examples/source/CSharp/ex27.cs new file mode 100644 index 0000000..5451d9a --- /dev/null +++ b/examples/source/CSharp/ex27.cs @@ -0,0 +1,30 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex27 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4() ; + + Data4 info = new Data4( settings, "DATA2.DBF" ) ; + + settings.optStart() ; + + Field4 field = new Field4( info, "NAME" ) ; + info.lockAll( ) ; //the record must be locked before a field can be changed + for( int iRec = 1 ; iRec <= info.recCount() ; iRec++ ) + { + info.go( iRec ) ; + field.assign( "New Data" ) ; + } + + info.close( ) ; + settings.initUndo( ) ; + settings.exit( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex28.cs b/examples/source/CSharp/ex28.cs new file mode 100644 index 0000000..c93f0a4 --- /dev/null +++ b/examples/source/CSharp/ex28.cs @@ -0,0 +1,28 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex28 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + if( cb.errorCode != 0 ) + { + Console.WriteLine( "An error occurred in the Data4 constructor" ) ; + cb.exit( ) ; + } + + data.top() ; + Console.Write( "Number of records in " + data.fileName( ) + ": " ) ; + Console.WriteLine( data.recCount( ) ) ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex29.cs b/examples/source/CSharp/ex29.cs new file mode 100644 index 0000000..64d51ae --- /dev/null +++ b/examples/source/CSharp/ex29.cs @@ -0,0 +1,22 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex29 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO.DBF" ) ; + + string st = data.alias ; + string sp = "INFO" ; + if( st == sp ) + Console.WriteLine( "This is always true" ) ; + + cb.initUndo() ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex30.cs b/examples/source/CSharp/ex30.cs new file mode 100644 index 0000000..46d9137 --- /dev/null +++ b/examples/source/CSharp/ex30.cs @@ -0,0 +1,40 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex30 + { + static Code4 cb = new Code4() ; // Code4 may be constructed globally. + static Data4 data = new Data4( cb, "INFO" ) ; + + [STAThread] + static void Main(string[] args) + { + data.lockAll( ) ; + cb.optStart( ) ; + data.appendBlank( ) ; + + // Append a copy of record two. (Assume record two exists.) + data.go( 2 ) ; + data.appendStart( ) ; // use_memo_entries defaults to zero + data.append( ) ; + + // Append a copy of record 2 including existing memo entries. + data.go( 2 ) ; + data.appendStart( 1 ) ; // a true parameter means use memo entries + data.append( ) ; + + // Set the record buffer to blank, change a field's value, and append + // the resulting record. + data.appendStart( ) ; + data.blank( ) ; + Field4 field = new Field4( data, "NAME" ) ; + field.assign( "New field value" ) ; + data.append( ) ; + + // close all open files and release any allocated memory + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex31.cs b/examples/source/CSharp/ex31.cs new file mode 100644 index 0000000..3c307a2 --- /dev/null +++ b/examples/source/CSharp/ex31.cs @@ -0,0 +1,23 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex31 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + // Add 5 blank records + for( int i = 5 ; i != 0 ; i-- ) + data.appendBlank( ) ; + + // Close the data file. + data.close( ) ; + cb.initUndo( ) ; // Free up any memory used. + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex32.cs b/examples/source/CSharp/ex32.cs new file mode 100644 index 0000000..1e156c7 --- /dev/null +++ b/examples/source/CSharp/ex32.cs @@ -0,0 +1,20 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex32 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "DATA1" ) ; + data.lockAll( ) ; + for( data.top( ) ; data.eof() == 0 ; data.skip() ) + data.blank( ) ; // blank out all records in the data file + + cb.initUndo( ) ; // close all files and release any memory + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex33.cs b/examples/source/CSharp/ex33.cs new file mode 100644 index 0000000..f4948f9 --- /dev/null +++ b/examples/source/CSharp/ex33.cs @@ -0,0 +1,22 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex33 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ); + Field4 field = new Field4( data, 1 ) ; + + // output the first field of every record in reverse sequential order. + for( data.bottom() ; data.bof( ) == 0 ; data.skip( -1 ) ) + Console.WriteLine( field.str() ) ; + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex34.cs b/examples/source/CSharp/ex34.cs new file mode 100644 index 0000000..c98d982 --- /dev/null +++ b/examples/source/CSharp/ex34.cs @@ -0,0 +1,21 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex34 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + data.bottom( ) ; + Console.WriteLine( "Last Name added: " + new Field4( data, "NAME" ).str() ) ; + + data.close() ; + cb.initUndo() ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex35.cs b/examples/source/CSharp/ex35.cs new file mode 100644 index 0000000..6e1cbc2 --- /dev/null +++ b/examples/source/CSharp/ex35.cs @@ -0,0 +1,26 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex35 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + data.top() ; + Console.WriteLine( "Changed status: " + data.changed ) ; // Displays 0 + data.lockAll( ) ; + new Field4( data, 1 ).assign( "TEMP DATA" ) ; + Console.WriteLine( "Changed status: " + data.changed ) ; // Displays 1 + data.changed = 0 ; + + data.close( ) ; + // The top record is not flushed. + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex36.cs b/examples/source/CSharp/ex36.cs new file mode 100644 index 0000000..bba8347 --- /dev/null +++ b/examples/source/CSharp/ex36.cs @@ -0,0 +1,41 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex36 + { + /* Check the validity of an index file. */ + [STAThread] + static void Main(string[] args) + { + if ( args.Length > 1 ) + { + Code4 cb = new Code4() ; + cb.autoOpen = 0 ; // open index file manually. + cb.errOff = 1 ; + + Data4 checkData = new Data4( cb, args[0] ) ; + + // Demonstration of Index4::open instead of Index4::Index4 + Index4 testIndex = new Index4() ; + testIndex.open( checkData, args[1] ) ; + + cb.exitTest( ) ; + cb.optStart( ) ; + + cb.errorCode = 0; + if ( checkData.checkIndex() == 0 ) + Console.WriteLine( "\nIndex is OK !!" ) ; + else + Console.WriteLine( "\nProblem with Index" ) ; + cb.initUndo( ) ; + } + else + { + Console.WriteLine() ; + Console.WriteLine( "PROGRAM DataFile IndexFile" ) ; + } + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex37.cs b/examples/source/CSharp/ex37.cs new file mode 100644 index 0000000..1985f09 --- /dev/null +++ b/examples/source/CSharp/ex37.cs @@ -0,0 +1,39 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex37 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4() ; + Data4 secondFile = new Data4() ; + Field4info fieldsFirst = new Field4info( ref cb ) ; + fieldsFirst.add( "NAME_FIELD", 'C', 20, 0, 0 ) ; + fieldsFirst.add( "AGE_FIELD", 'N', 3, 0, 0 ) ; + fieldsFirst.add( "BIRTH_DATE", 'D', 8, 0, 0 ) ; + + data.create( ref cb, "FIRSTDBF", ref fieldsFirst ) ; + cb.exitTest( ) ; + + // initialize fields object with the fields of FIRSTDBF.DBF + Field4info fields = new Field4info( data ) ; + // add a new field + fields.add( "NEW_FLD", 'C', 20, 0, 0 ) ; + + cb.safety = 0 ; // overwrite the file if it exists + secondFile.create( ref cb, "NEWDBF", ref fields ) ; + + if( cb.errorCode != 0 ) + Console.WriteLine( "An error occurred, NEWDBF not created" ) ; + else + Console.WriteLine( "Created successfully!" ) ; + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex38.cs b/examples/source/CSharp/ex38.cs new file mode 100644 index 0000000..9500136 --- /dev/null +++ b/examples/source/CSharp/ex38.cs @@ -0,0 +1,27 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex38 + { + [STAThread] + static void Main(string[] args) + { + Code4 codeBase = new Code4() ; + Data4 file = new Data4( codeBase, "INFO" ) ; + + codeBase.optStart( ) ; + + int count = 0 ; + + for( file.top( ) ; file.eof( ) == 0 ; file.skip( 1 ) ) + if( file.deleted( ) != 0 ) + count++ ; + + Console.WriteLine( "\"INFO\" has " + count + " deleted records" ) ; + + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex39.cs b/examples/source/CSharp/ex39.cs new file mode 100644 index 0000000..d13ac51 --- /dev/null +++ b/examples/source/CSharp/ex39.cs @@ -0,0 +1,29 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex39 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4() ; + + cb.accessMode = Code4.OPEN4DENY_RW ; // open file exclusively to speed pack + + data.open( ref cb, "INFO" ) ; + cb.exitTest( ) ; + cb.optStart( ) ; + + for( data.top( ) ; data.eof( ) == 0 ; data.skip( 2 ) ) + data.deleteRec( ) ; // Mark the record for deletion + + data.pack( ) ; // Physically remove the deleted records from the disk + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex4.cs b/examples/source/CSharp/ex4.cs new file mode 100644 index 0000000..2d300eb --- /dev/null +++ b/examples/source/CSharp/ex4.cs @@ -0,0 +1,35 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex4 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + + // Do not add duplicate records to unique tags or the data file and + // return r4unique when attempted. + cb.errDefaultUnique = Code4.r4unique ; + + Data4 data = new Data4( cb, "INFO" ) ; + + data.top( ) ; + data.appendStart( ) ; + int rc = data.append( ) ; // append a duplicate copy of the top record + + if ( rc == Code4.r4unique ) + Console.WriteLine( "Attempt to add a duplicate record failed." ) ; + else + { + Console.WriteLine( "Attempt to add a duplicate record succeeded" ) ; + Console.WriteLine( "Record in both data and index file" ) ; + } + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex40.cs b/examples/source/CSharp/ex40.cs new file mode 100644 index 0000000..058caf2 --- /dev/null +++ b/examples/source/CSharp/ex40.cs @@ -0,0 +1,28 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex40 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4() ; + Data4 infoFile = new Data4( settings, "INFO" ) ; + + // Go to the end of file and set the End of file flag + infoFile.goEof( ) ; + + // Check to see if the end of file flag is set + if ( infoFile.eof( ) != 0 ) + { + Console.WriteLine( "This is always true" ) ; + infoFile.bottom( ) ; // reset the eof flag + } + + infoFile.close( ) ; + settings.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex41.cs b/examples/source/CSharp/ex41.cs new file mode 100644 index 0000000..5e5f034 --- /dev/null +++ b/examples/source/CSharp/ex41.cs @@ -0,0 +1,24 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex41 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4() ; + Data4 infoFile = new Data4( settings, "INFO" ); + + for( short num = (short) infoFile.numFields( ) ; num != 0 ; num-- ) + { + Field4 field = new Field4( infoFile, num ) ; + if( num == infoFile.fieldNumber( field.name( ) ) ) + Console.WriteLine( "This is always true." ) ; + } + infoFile.close( ) ; + settings.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex42.cs b/examples/source/CSharp/ex42.cs new file mode 100644 index 0000000..111b5b6 --- /dev/null +++ b/examples/source/CSharp/ex42.cs @@ -0,0 +1,28 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex42 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + cb.accessMode = Code4.OPEN4DENY_RW ; + Data4 data = new Data4( cb, "INFO" ); + Field4 age = new Field4( data, "AGE" ) ; + + data.go( 2 ) ; + age.assignInt( 49 ) ; + + // Explicitly flush the change to disk in case power goes out + data.flush( ) ; + + // some other code + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex43.cs b/examples/source/CSharp/ex43.cs new file mode 100644 index 0000000..1b18688 --- /dev/null +++ b/examples/source/CSharp/ex43.cs @@ -0,0 +1,36 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex43 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + cb.lockAttempts = 0 ; /* Do not wait when locking. */ + cb.readLock = 1 ; + + int rc = data.go( 3 ) ; + if ( rc == Code4.r4locked ) + { + Console.WriteLine( "\nRecord 3 was locked by another user." ) ; + + cb.readLock = 0 ; // Turn automatic locking off. + + rc = data.go( 3 ) ; + if ( rc == Code4.r4locked ) + { + Console.Write( "This will never happen because " ) ; + Console.WriteLine( "'Code4::readLock' is false." ) ; + } + } + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex44.cs b/examples/source/CSharp/ex44.cs new file mode 100644 index 0000000..41f2abf --- /dev/null +++ b/examples/source/CSharp/ex44.cs @@ -0,0 +1,33 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex44 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4() ; + Data4 data = new Data4( settings, "INFO" ) ; + + // Since Code4::autoOpen is by default TRUE, the INFO index file + // should have been opened. + + Index4 index = new Index4() ; + + index = data.index( "INFO" ) ; + + if( index.isValid( ) != 0 ) + Console.WriteLine( "INDEX: INFO has been opened" ) ; + + index = data.index( "JUNK" ) ; + + if ( index.isValid( ) == 0 ) + Console.WriteLine( "INDEX: JUNK has not been opened" ) ; + + data.close( ) ; + settings.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex45.cs b/examples/source/CSharp/ex45.cs new file mode 100644 index 0000000..d20738c --- /dev/null +++ b/examples/source/CSharp/ex45.cs @@ -0,0 +1,24 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex45 + { + static void displayAlias( Data4 d ) + { + if ( d.isValid( ) != 0 ) + Console.WriteLine( d.alias + " is valid." ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + displayAlias( data ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex46.cs b/examples/source/CSharp/ex46.cs new file mode 100644 index 0000000..9e693d5 --- /dev/null +++ b/examples/source/CSharp/ex46.cs @@ -0,0 +1,34 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex46 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4() ; + + data.open( ref cb, "INFO" ) ; + + cb.lockAttempts = 4 ; // Try four times + + int rc = data.lockRecord( 5 ) ; + if( rc == Code4.r4success ) + Console.WriteLine( "Record 5 is now locked." ) ; + else if( rc == Code4.r4locked ) + Console.WriteLine( "Record 5 is locked by another user" ) ; + + cb.lockAttempts = Code4.WAIT4EVER ; // Try forever + rc = data.lockRecord( 5 ) ; + + if ( rc == Code4.r4success ) + Console.WriteLine( "This will always happen." ) ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex47.cs b/examples/source/CSharp/ex47.cs new file mode 100644 index 0000000..ac8b8b7 --- /dev/null +++ b/examples/source/CSharp/ex47.cs @@ -0,0 +1,24 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex47 + { + [STAThread] + static void Main(string[] args) + { + Code4 code = new Code4() ; + Data4 df = new Data4( code, "INFO" ) ; + + int rc = df.lockAll( ) ; + + if( rc == Code4.r4success ) + Console.WriteLine( "Lock is successful." ) ; + else + Console.WriteLine( "Lock was unsuccessful" ) ; + + code.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex48.cs b/examples/source/CSharp/ex48.cs new file mode 100644 index 0000000..27d1592 --- /dev/null +++ b/examples/source/CSharp/ex48.cs @@ -0,0 +1,29 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex48 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + /* Lock all of the records in the data file as well as + the append bytes all at once. Existing locks are + removed. */ + + int rc = data.lockFile( ) ; + if ( rc == Code4.r4success ) + { + Console.Write( "Other users can read this data file, " ) ; + Console.Write( "but can make no modifications until\n" ) ; + Console.WriteLine( "this lock is removed." ) ; + } + + cb.initUndo( ) ; // implicitly unlock the file. + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex49.cs b/examples/source/CSharp/ex49.cs new file mode 100644 index 0000000..2955be6 --- /dev/null +++ b/examples/source/CSharp/ex49.cs @@ -0,0 +1,27 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex49 + { + static void compressAll( Data4 d ) + { + if ( d.pack( ) == 0 ) + Console.WriteLine( "Records marked for deletion are removed." ) ; + + if ( d.memoCompress( ) == 0 ) + Console.WriteLine( "Memo entries are compressed." ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + compressAll( data ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex5.cs b/examples/source/CSharp/ex5.cs new file mode 100644 index 0000000..d0c5c5a --- /dev/null +++ b/examples/source/CSharp/ex5.cs @@ -0,0 +1,31 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex5 + { + [STAThread] + static void Main(string[] args) + { + Code4 code = new Code4() ; + Data4 data = new Data4( code, "INFO" ) ; + + string badExpr = "NAME = 5" ; + + Expr4 expression = new Expr4( data, badExpr ) ; + + Console.WriteLine( "\nAn error message just displayed" ) ; + + code.errorCode = code.errExpr = 0 ; + + expression.parse( data, badExpr ) ; + Console.WriteLine( "No error message displayed." ) ; + + if ( expression.isValid() != 0 ) + expression.free( ) ; + + code.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex50.cs b/examples/source/CSharp/ex50.cs new file mode 100644 index 0000000..477b3b4 --- /dev/null +++ b/examples/source/CSharp/ex50.cs @@ -0,0 +1,26 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex50 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + cb.optStart( ) ; + + for ( int rc = data.top( ) ; rc != Code4.r4eof ; rc = data.skip( 1 ) ) + { + short fieldNum ; + for( fieldNum = 1 ; fieldNum <= data.numFields( ) ; fieldNum++ ) + Console.Write( new Field4(data, fieldNum).str( ) + " " ) ; + Console.WriteLine() ; + } + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex51.cs b/examples/source/CSharp/ex51.cs new file mode 100644 index 0000000..6561582 --- /dev/null +++ b/examples/source/CSharp/ex51.cs @@ -0,0 +1,26 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex141 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4() ; // Do not open the file with the constructor + + cb.accessMode = Code4.OPEN4DENY_RW ; + int rc = data.open( ref cb, "INFO" ) ; + + if( rc == Code4.r4success ) + { + Console.Write( "Data file INFO.DBF has " + data.recCount( ) ) ; + Console.WriteLine( " records. " ) ; + } + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex52.cs b/examples/source/CSharp/ex52.cs new file mode 100644 index 0000000..09c5dab --- /dev/null +++ b/examples/source/CSharp/ex52.cs @@ -0,0 +1,37 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex52 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + cb.accessMode = Code4.OPEN4DENY_RW ; + + // Open the file exclusively, default optimization is the same as if + // Data4::optimize( Code4.OPT4EXCLUSIVE ) were called. + Data4 info = new Data4( cb, "INFO" ) ; + + // open a shared file. + cb.accessMode = Code4.OPEN4DENY_NONE ; + Data4 extra = new Data4( cb, "DATA" ) ; + + extra.optimize( Code4.OPT4ALL ) ; // read optimize the "DATA" file + + int rc = cb.optStart( ) ; // Begin the memory optimizations. + if ( rc == Code4.r4success ) + Console.WriteLine( "Memory optimiztion is implemented" ) ; + else + Console.WriteLine( "Either the S4OFF_OPTIMIZE switch is defined or " + + "there is insufficient memory for optimization" ) ; + + // .... Some other code .... + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex53.cs b/examples/source/CSharp/ex53.cs new file mode 100644 index 0000000..dd5c3ab --- /dev/null +++ b/examples/source/CSharp/ex53.cs @@ -0,0 +1,33 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex53 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + data.optimizeWrite( Code4.OPT4ALL ) ; + // when doing write optimization on shared files, it is necessary to + // lock the file, preferably with Data4::lockAll( ) + data.lockAll( ) ; + + cb.optStart( ) ; // begin optimization + + int age = 20 ; + Field4 ageField = new Field4( data, "AGE" ) ; + + for( data.top( ) ; age < 65 ; data.append( ) ) + { + data.appendStart( 0 ) ; + ageField.assignInt( age++ ) ; + } + + cb.initUndo( ) ; // flushes, closes, and unlocks + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex54.cs b/examples/source/CSharp/ex54.cs new file mode 100644 index 0000000..a5dd68b --- /dev/null +++ b/examples/source/CSharp/ex54.cs @@ -0,0 +1,32 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex54 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4() ; + + cb.accessMode = Code4.OPEN4DENY_RW ; // open file exclusively + + data.open( ref cb, "INFO" ) ; + cb.exitTest( ) ; + data.lockAll( ) ; + cb.optStart( ) ; + + // Mark every other record for deletion + for( data.top( ) ; data.eof( ) == 0 ; data.skip( 2 ) ) + data.deleteRec( ) ; + + // Remove the deleted records from the physical disk + data.pack( ) ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex55.cs b/examples/source/CSharp/ex55.cs new file mode 100644 index 0000000..1a97923 --- /dev/null +++ b/examples/source/CSharp/ex55.cs @@ -0,0 +1,27 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex55 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + Tag4 firstTag = new Tag4() ; + firstTag.initFirst( data ) ; + + cb.exitTest( ) ; + + data.select( firstTag ) ; // select the first tag of the first open index. + data.position = .25 ; // move one quarter through the index file. + Console.WriteLine( "Record number: " + data.recNo() ) ; + + Console.WriteLine( "The current position is: " + data.position ) ; + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex56.cs b/examples/source/CSharp/ex56.cs new file mode 100644 index 0000000..eb4c1bc --- /dev/null +++ b/examples/source/CSharp/ex56.cs @@ -0,0 +1,39 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex56 + { + static int recallAll( Data4 d ) + { + + Tag4 saveSelected = new Tag4() ; + saveSelected.initSelected( d ) ; + + d.select( ) ; // use record ordering + + d.lockAll( ) ; + + int count = 0 ; + + for( d.top( ) ; d.eof( ) != 0 ; d.skip( 1 ) ) + { + d.recall( ) ; + count++ ; + } + + d.select( saveSelected ) ; // reset the selected tag. + return count ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + recallAll( data ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex57.cs b/examples/source/CSharp/ex57.cs new file mode 100644 index 0000000..3cb9a5e --- /dev/null +++ b/examples/source/CSharp/ex57.cs @@ -0,0 +1,30 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex57 + { + static int recsInFile( ref Code4 cb, string fileName ) + { + Data4 data = new Data4( cb, fileName ) ; + if ( cb.errorCode != 0 ) + return -1 ; // an error occurred + + int count = data.recCount( ) ; // save the record count + + data.close( ) ; // close the data file + return count ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + string name = "INFO" ; + int rc = recsInFile( ref cb, name ) ; + Console.WriteLine( rc + " records in the file" ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex58.cs b/examples/source/CSharp/ex58.cs new file mode 100644 index 0000000..a89238f --- /dev/null +++ b/examples/source/CSharp/ex58.cs @@ -0,0 +1,27 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex58 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + Tag4 firstTag = new Tag4() ; + firstTag.initFirst( data ) ; + + data.select( firstTag ) ; //select the first tag of the first opened index + + int count = 0 ; + for( data.top( ); data.eof( ) == 0 ; data.skip( 1 ) ) + { + Console.Write( "position in the tag: " + ++count ) ; + Console.WriteLine( " Record Position: " + data.recNo( ) ) ; + } + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex6.cs b/examples/source/CSharp/ex6.cs new file mode 100644 index 0000000..8bc5e62 --- /dev/null +++ b/examples/source/CSharp/ex6.cs @@ -0,0 +1,26 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex6 + { + [STAThread] + static void Main(string[] args) + { + Code4 code = new Code4() ; + Data4 data = new Data4( code, "INFO" ) ; + string badField = "notAField" ; + + Field4 field = new Field4( data, badField ) ; + Console.WriteLine( "\nAn error message just displayed" ) ; + + code.errorCode = code.errFieldName = 0 ; + + field.init( data, badField ) ; + Console.WriteLine( "No error message displayed." ) ; + + code.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex60.cs b/examples/source/CSharp/ex60.cs new file mode 100644 index 0000000..9fbc05c --- /dev/null +++ b/examples/source/CSharp/ex60.cs @@ -0,0 +1,33 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex60 + { + [STAThread] + static void Main(string[] args) + { + Code4 codeBase = new Code4() ; + Data4 dataFile = new Data4( codeBase, "INFO" ) ; + + dataFile.optimize( Code4.OPT4ALL ) ; + codeBase.optStart( ) ; + + dataFile.top( ) ; + Console.WriteLine( "Press Enter when you want to refresh your data." ) ; + Console.Read() ; + + dataFile.refresh( ) ; + dataFile.top( ) ; // re-read the record from disk. + + Console.Write( "The latest information is: " ) ; + for ( short i = 1 ; i <= dataFile.numFields() ; i++ ) + Console.Write( new Field4( dataFile, i ).str() + " " ) ; + Console.WriteLine() ; + + dataFile.close( ) ; + codeBase.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex61.cs b/examples/source/CSharp/ex61.cs new file mode 100644 index 0000000..c705d03 --- /dev/null +++ b/examples/source/CSharp/ex61.cs @@ -0,0 +1,31 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex61 + { + static void update( Data4 d ) + { + if ( d.changed != 0 ) + Console.WriteLine( "Changes not discarded." ) ; + else + d.refreshRecord( ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + data.top( ) ; + data.lockRecord(1) ; + Field4 field = new Field4( data, "NAME" ) ; + field.assign( "Marvin" ) ; + update( data ) ; + data.skip( ) ; + update( data ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex62.cs b/examples/source/CSharp/ex62.cs new file mode 100644 index 0000000..b1f0d92 --- /dev/null +++ b/examples/source/CSharp/ex62.cs @@ -0,0 +1,26 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex62 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + cb.accessMode = Code4.OPEN4DENY_RW ; + Data4 data = new Data4( cb, "INFO" ) ; + + Console.WriteLine( "Reindexing {0}\nPlease Wait", data.alias ) ; + int rc = data.reindex( ) ; + + if ( rc != 0 ) + Console.WriteLine( "\nReindex NOT successful.\n" ) ; + else + Console.WriteLine( "\nSuccessfully reindexed.\n" ) ; + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex63.cs b/examples/source/CSharp/ex63.cs new file mode 100644 index 0000000..2a3991e --- /dev/null +++ b/examples/source/CSharp/ex63.cs @@ -0,0 +1,48 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex63 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 people = new Data4( cb, "people.dbf" ) ; + + /* Assume 'PEOPLE.DBF' has a production index file with tags + PPL_NAME, PPL_AGE, PPL_BRTH */ + people.select( new Tag4( people, "PPL_NAME" ) ) ; + + if( people.seek( "fred" ) == Code4.r4success ) + Console.WriteLine( "fred is in record # {0}\n", people.recNo( ) ) ; + + if( people.seek( "HANK STEVENS" ) == Code4.r4success ) + Console.WriteLine( "HANK STEVENS is in record # {1}\n", people.recNo( ) ) ; + + people.select( new Tag4( people, "PPL_AGE" ) ) ; + Field4 age = new Field4( people, "AGE" ) ; + + int rc = people.seek( 0.0 ) ; + + if( rc == Code4.r4success || rc == Code4.r4after ) + Console.WriteLine( "The youngest age is: {0}\n", (double) age.getDouble( ) ) ; + + // Seek using the char * version + rc = people.seek( "0" ) ; + if( rc == Code4.r4success || rc == Code4.r4after ) + Console.WriteLine( "The youngest age is: {0}\n", (double) age.getDouble( ) ) ; + + // Assume PPL_BRTH is a Date key expression + people.select( new Tag4( people, "PPL_BRTH" )) ; + string birth = "19600415" ; + + if( people.seek( birth ) == Code4.r4success ) // String in CCYYMMDD format + Console.WriteLine( "Found: {0}\n", birth ) ; + + people.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex64.cs b/examples/source/CSharp/ex64.cs new file mode 100644 index 0000000..d01900d --- /dev/null +++ b/examples/source/CSharp/ex64.cs @@ -0,0 +1,37 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex64 + { + static int SeekSeries( Data4 d, string s ) + { + int rc ; + rc = d.seekNext( s ) ; + + if( rc == Code4.r4noTag || rc == Code4.r4entry || rc == Code4.r4locked || rc < 0 ) + return rc ; + + if( rc == Code4.r4after || rc == Code4.r4eof ) + rc = d.seek( s ) ; + + return rc ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "PEOPLE" ) ; + Tag4 nametag = new Tag4( data, "PPL_NAME" ) ; + + data.select( nametag ) ; + int rc = data.seek( "mickey" ) ; + for ( ; rc == Code4.r4success ; rc = SeekSeries( data, "mickey" ) ) + Console.WriteLine( "found search string\n" ) ; + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex65.cs b/examples/source/CSharp/ex65.cs new file mode 100644 index 0000000..7a0786b --- /dev/null +++ b/examples/source/CSharp/ex65.cs @@ -0,0 +1,37 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex65 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "INFO" ) ; // automatically open data & index file. + Tag4 nameTag = new Tag4( data, "INF_NAME" ) ; + Tag4 firstTag = new Tag4( ); + firstTag.initFirst( data ) ; + + data.top(); + data.recall(); + + data.select( nameTag ) ; // Select the 'INF_NAME' + data.seek( "JONES" ) ; // Seek using 'INF_NAME' + + data.select( firstTag ) ; // Select the 'AGE' tag which is the + // first tag of the first open index + data.seek( 32 ) ; // Seek using selected tag 'AGE' + + data.select( ) ; // Select record ordering + data.seek( "ginger" ) ; // The seek uses the first tag of the first index + // when no tag is selected, so the seek fails even + // if "ginger" is in the data file + + data.top( ) ; //Physical top of the data file + + cb.initUndo( ) ; // close all files and free up Code4 memory + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex66.cs b/examples/source/CSharp/ex66.cs new file mode 100644 index 0000000..5bbbf37 --- /dev/null +++ b/examples/source/CSharp/ex66.cs @@ -0,0 +1,34 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex66 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "NAMES" ) ; + + // Skip to the last record in the file whose NAME field contains "John" + + cb.optStart( ) ; + + Field4 name = new Field4( data, "F_NAME" ) ; + + for( data.bottom( ) ;data.bof( ) == 0 ; data.skip( -1 ) ) + { + if( name.str().Trim() == "John" ) // anything but -1 indicates a find + break ; + } + if( data.bof( ) != 0 ) + Console.WriteLine( "John not located\n" ) ; + else + Console.WriteLine( "The last John is in record: {0}\n", data.recNo( ) ) ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex67.cs b/examples/source/CSharp/ex67.cs new file mode 100644 index 0000000..e82ec80 --- /dev/null +++ b/examples/source/CSharp/ex67.cs @@ -0,0 +1,34 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex67 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "DBF" ) ; + Tag4 tag = new Tag4( data, "DBF_NAME" ) ; // A tag with '.NOT.DELETED()' filter + + data.lockAll( ) ; + data.select( tag ) ; + data.top( ) ; // Position to the first record that is not deleted. + Console.WriteLine( "first record that is not deleted is {0}\n", data.recNo() ) ; + + data.deleteRec( ) ; // The current record no longer is located in the tag + + data.tagSync( ) ; // The change to the record is flushed, and the datafile is + // positioned on a valid record. + + data.top( ) ; + Console.WriteLine( "the new first record that is not deleted is {0}\n ", data.recNo() ) ; + data.skip( ) ; + + //... some other code ... + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex68.cs b/examples/source/CSharp/ex68.cs new file mode 100644 index 0000000..0c88527 --- /dev/null +++ b/examples/source/CSharp/ex68.cs @@ -0,0 +1,28 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex68 + { + [STAThread] + static void Main(string[] args) + { + Code4 settings = new Code4() ; + Data4 info = new Data4( settings, "INFO" ) ; // automatically open data & index file + Tag4 firstTag = new Tag4() ; + firstTag.initFirst( info ) ; + + info.select( firstTag ) ; // Select first tag of the first open index + + int count = 0 ; + for( info.top( ) ; info.eof( ) == 0 ; info.skip( ) ) + count++ ; + + Console.WriteLine( "{0} records in tag {1}\n", count, firstTag.alias( ) ) ; + + info.close( ) ; + settings.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex69.cs b/examples/source/CSharp/ex69.cs new file mode 100644 index 0000000..5a05024 --- /dev/null +++ b/examples/source/CSharp/ex69.cs @@ -0,0 +1,33 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex69 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "INFO" ) ; + Tag4 nameTag = new Tag4( data, "INF_NAME" ) ; + Field4 name = new Field4( data, "NAME" ) ; + + cb.exitTest( ) ; // check for errors + data.lockAll( ) ; + data.select( nameTag ) ; + + for( int rc = data.seek( "JONES" ) ; rc == 0 ; rc = data.skip( ) ) + { + if( name.str( ).Trim( ) == "JONES" ) + Console.WriteLine( "Jones in record {0}\n", data.recNo( ) ) ; + else + break ; + } + data.unlock( ) ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex7.cs b/examples/source/CSharp/ex7.cs new file mode 100644 index 0000000..be9ebfd --- /dev/null +++ b/examples/source/CSharp/ex7.cs @@ -0,0 +1,25 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex7 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + Data4 data = new Data4( cb, "INFO" ) ; + + data.go( data.recCount( ) + 1 ) ; + + Console.WriteLine( "An error message was displayed" ) ; + cb.errorCode = cb.errGo = 0 ; + + data.go( data.recCount( ) + 1 ) ; + Console.WriteLine( "No error message was displayed" ) ; + + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex70.cs b/examples/source/CSharp/ex70.cs new file mode 100644 index 0000000..b2d1b25 --- /dev/null +++ b/examples/source/CSharp/ex70.cs @@ -0,0 +1,28 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex70 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + // open exclusively to avoid multiuser corruption + cb.accessMode = Code4.OPEN4DENY_RW ; + + Data4 data = new Data4( cb, "INFO" ) ; + data.go( 1 ) ; + + // Make all of the records in the data file the same as the first record + + for( int numRecs = data.recCount( ) ; numRecs-1 != 0 ; numRecs -- ) + if( data.write( numRecs ) != 0 ) + break ; + + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex71.cs b/examples/source/CSharp/ex71.cs new file mode 100644 index 0000000..a8e5217 --- /dev/null +++ b/examples/source/CSharp/ex71.cs @@ -0,0 +1,31 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex71 + { + static int zapLast( Data4 info, int toDelete ) + { + Console.WriteLine( "{0} has {1} records.\n", info.alias, info.recCount( ) ) ; + + // Remove the last 'toDelete' records in the data file. + // endRec parameter defaults to 1 Billion + + info.zap( info.recCount( ) - toDelete + 1, 1000000) ; + + Console.WriteLine( "\n{0} now has {1} records.\n", info.alias, info.recCount( ) ) ; + + return info.recCount( ) ; + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "INFO" ) ; + zapLast( data, 10 ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex8.cs b/examples/source/CSharp/ex8.cs new file mode 100644 index 0000000..e71adb4 --- /dev/null +++ b/examples/source/CSharp/ex8.cs @@ -0,0 +1,30 @@ +using System ; +using CodeBase ; + +namespace c4ap +{ + class ex8 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4() ; + cb.errOpen = 0 ; + // no error message is displayed if NO_FILE does not exist + Data4 data = new Data4( cb, "NO_FILE" ) ; + + if( data.isValid() == 0 ) + { + // Data file does not exist + cb.safety = 0 ; + Field4info fields = new Field4info( ref cb ) ; + fields.add( "NAME_FLD", 'C', 20, 0, 0 ) ; + fields.add( "AGE_FLD", 'N', 3, 0, 0 ) ; + data.create( ref cb, "NO_FILE", ref fields ) ; + if( data.isValid( ) == 0 ) + Console.WriteLine( "Could not create NO_FILE" ) ; + } + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex92.cs b/examples/source/CSharp/ex92.cs new file mode 100644 index 0000000..b9752bf --- /dev/null +++ b/examples/source/CSharp/ex92.cs @@ -0,0 +1,26 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex92 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "DATA" ) ; + + data.go( 1 ) ; + + // "FNAME" and "LNAME" are Character field names of data file "DATA.DBF" + Expr4 expr = new Expr4( data, "FNAME+\' \'+LNAME") ; + + Console.WriteLine( "FNAME and LNAME for Record One: {0}\n", expr.str( ) ) ; + + expr.free( ) ; + data.close( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex93.cs b/examples/source/CSharp/ex93.cs new file mode 100644 index 0000000..01639cd --- /dev/null +++ b/examples/source/CSharp/ex93.cs @@ -0,0 +1,25 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex93 + { + [STAThread] + static void Main(string[] args) + { + Code4 code = new Code4( ) ; + Data4 db = new Data4( code, "DATA" ) ; + Expr4 exp = new Expr4( db, "LNAME=\'Smith\'" ) ; // a logical dBASE expression + int count = 0 ; + + for( db.top( ) ; db.eof( ) == 0 ; db.skip( ) ) + if( exp.isTrue( ) > 0 ) + count++ ; + + Console.WriteLine( "{0} record(s) had a last name of Smith\n", count ) ; + + code.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex94.cs b/examples/source/CSharp/ex94.cs new file mode 100644 index 0000000..ed4a4db --- /dev/null +++ b/examples/source/CSharp/ex94.cs @@ -0,0 +1,27 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex94 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 db = new Data4( cb, "INFO" ) ; + Expr4 expr = new Expr4( db, "AGE" ) ; + + double VOTE_AGE = 18.0 ; + long count = 0 ; + for( int rc = db.top( ) ; rc != Code4.r4eof ; rc = db.skip( ) ) + if( (double) expr >= VOTE_AGE ) + count ++ ; + + Console.WriteLine( "Possible voters: {0}\n", count ) ; + + expr.free( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex96.cs b/examples/source/CSharp/ex96.cs new file mode 100644 index 0000000..b78c710 --- /dev/null +++ b/examples/source/CSharp/ex96.cs @@ -0,0 +1,27 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex96 + { + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4( cb, "DATA" ) ; + Data4 info = new Data4( cb, "INFO" ) ; + Expr4 expr = new Expr4( ) ; + + expr.parse( data, "FNAME+' '+DTOS( INFO->BIRTH_DATE)" ) ; + + data.top( ) ; + info.top( ) ; + + Console.WriteLine( "First name from DATA and birth date from INFO: {0}\n", expr.str() ); + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex97.cs b/examples/source/CSharp/ex97.cs new file mode 100644 index 0000000..1df6700 --- /dev/null +++ b/examples/source/CSharp/ex97.cs @@ -0,0 +1,69 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex97 + { + static void showExpr( Expr4 ex ) + { + Console.WriteLine( "\nValue: " ); + + switch( ex.type( ) ) + { + case Code4.r4date: + Console.WriteLine( "{0}\nr4date\n", ex.str( ) ) ; + break ; + case Code4.r4dateDoub: + Console.WriteLine( "{0}\nr4dateDoub\n", (double) ex ) ; + break ; + case Code4.r4log: + Console.WriteLine( "{0}\nr4log\n", (double) ex ) ; + break ; + case Code4.r4num: + Console.WriteLine( "{0}\nr4num\n", (double) ex ) ; + break ; + case Code4.r4numDoub: + Console.WriteLine( "{0}\nr4numDoub\n", (double) ex ) ; + break ; + case Code4.r4str: + Console.WriteLine( "{0}\nr4str\n", ex.str( ) ) ; + break ; + case Code4.r4memo: + Console.WriteLine( "{0}\nr4memo\n", ex.str( ) ) ; + break ; + } + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 db = new Data4( cb, "info" ) ; + db.top( ) ; + + Expr4 ex = new Expr4( db, "NAME" ) ; + showExpr( ex ) ; + ex.free( ) ; + + ex.parse( db, "AGE" ) ; + showExpr( ex ) ; + ex.free( ) ; + + ex.parse( db, "AGE+1" ) ; + showExpr( ex ) ; + ex.free( ) ; + + ex.parse( db, "BIRTH_DATE" ) ; + showExpr( ex ) ; + ex.free( ) ; + + ex.parse( db, "BIRTH_DATE+1" ) ; + showExpr( ex ) ; + ex.free( ) ; + + cb.closeAll( ) ; + cb.initUndo( ) ; + } + } +} \ No newline at end of file diff --git a/examples/source/CSharp/ex99.cs b/examples/source/CSharp/ex99.cs new file mode 100644 index 0000000..479c461 --- /dev/null +++ b/examples/source/CSharp/ex99.cs @@ -0,0 +1,34 @@ +using System; +using CodeBase; + +namespace c4ap +{ + class ex99 + { + static void dumpDataFileToScreen( Data4 d ) + { + Console.WriteLine( "Contents of: {0}\n", d.alias ) ; + for( d.top( ) ; d.eof( ) == 0 ; d.skip( ) ) + { + for( short j = 1 ; j <=d.numFields( ) ; j++ ) + { + Field4 field = new Field4( d, j ) ; + Console.WriteLine( field.str( ) ) ; + } + Console.Write("\n") ; + } + } + + [STAThread] + static void Main(string[] args) + { + Code4 cb = new Code4( ) ; + Data4 data = new Data4(cb, "DATA"); + + dumpDataFileToScreen( data ); + + data.close(); + cb.initUndo(); + } + } +} \ No newline at end of file diff --git a/examples/source/VB.NET/EX0.vb b/examples/source/VB.NET/EX0.vb new file mode 100644 index 0000000..463ebee --- /dev/null +++ b/examples/source/VB.NET/EX0.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX0.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex0 example code + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + rc = code4autoOpen(cb, 0) 'Don't open production index + rc = code4errDefaultUnique(cb, r4unique) 'How to handle duplicate keys + frm.ListBox1.Items.Add("made setting changes") + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "data1") 'Open a data file + + ' this is equivalent to calling error4exitTest( ) + + If code4errorCode(cb, 0) < 0 Then + Call code4exit(cb) + End If + + + ' more code ... + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX1.vb b/examples/source/VB.NET/EX1.vb new file mode 100644 index 0000000..cfd01e4 --- /dev/null +++ b/examples/source/VB.NET/EX1.vb @@ -0,0 +1,57 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX1.VB + + Public lf As String 'Line Feed + Public fpath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex1 example code + Dim cb, newDataFile As Integer + Dim fieldInfo() As FIELD4INFO + Dim rc As Short + + cb = code4init() + ReDim fieldInfo(3) + fieldInfo(0).fName = "NAME" + fieldInfo(0).ftype = r4str + fieldInfo(0).flength = 20 + fieldInfo(0).fdecimals = 0 + + fieldInfo(1).fName = "AGE" + fieldInfo(1).ftype = r4num + fieldInfo(1).flength = 3 + fieldInfo(1).fdecimals = 0 + + fieldInfo(2).fName = "BIRTH_DATE" + fieldInfo(2).ftype = r4date + fieldInfo(2).flength = 8 + fieldInfo(2).fdecimals = 0 + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fpath = VB6.GetPath & "\" + + rc = code4accessMode(cb, OPEN4DENY_RW) 'Prevents other applications from + 'having read and write access to any + 'files opened subsequently + rc = code4safety(cb, 0) 'Ensure the create overwrites any + 'existing file + newDataFile = d4createData(cb, fpath & "NEWDBF", fieldInfo) + + rc = d4close(newDataFile) + + rc = code4accessMode(cb, OPEN4DENY_NONE) 'Open file in shared mode + newDataFile = d4open(cb, fpath & "NEWDBF") + + '...some other code... + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX10.vb b/examples/source/VB.NET/EX10.vb new file mode 100644 index 0000000..fb42c3a --- /dev/null +++ b/examples/source/VB.NET/EX10.vb @@ -0,0 +1,52 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX10.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex10 example code + Dim cb, inventory As Integer + Dim onHand, minOnHand, stockName As Integer + Dim rc, count As Short + Dim oldOpt, oldExcl As Short + + cb = code4init() + oldOpt = code4optimize(cb, OPT4EXCLUSIVE) + oldExcl = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + inventory = d4open(cb, fPath & "INVENT.DBF") 'Read optimized + minOnHand = d4field(inventory, "MIN_ON_HND") + onHand = d4field(inventory, "ON_HAND") + stockName = d4field(inventory, "ITEM") + + count = 0 + If code4errorCode(cb, r4check) >= 0 Then + rc = code4optStart(cb) + rc = d4top(inventory) + Do While d4eof(inventory) = 0 + If f4long(onHand) < f4long(minOnHand) Then + count = count + 1 + End If + rc = d4skip(inventory, 1) + Loop + rc = code4optSuspend(cb) + End If + + rc = code4optimize(cb, oldOpt) + rc = code4accessMode(cb, oldExcl) + rc = d4close(inventory) + MsgBox(Str(count) & " items need to be restocked", MsgBoxStyle.OKOnly) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX100.vb b/examples/source/VB.NET/EX100.vb new file mode 100644 index 0000000..26b7ce0 --- /dev/null +++ b/examples/source/VB.NET/EX100.vb @@ -0,0 +1,38 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX100.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc As Short + Dim j As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + + If db <> 0 Then + ' list the fields that are character fields + For j = 1 To d4numFields(db) + field = d4fieldJ(db, j) + If Chr(f4type(field)) = r4str Then + frm.ListBox1.Items.Add(f4name(field)) + End If + Next j + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX101.vb b/examples/source/VB.NET/EX101.vb new file mode 100644 index 0000000..c4cf340 --- /dev/null +++ b/examples/source/VB.NET/EX101.vb @@ -0,0 +1,49 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX101.VB + + Sub ExCode(ByRef frm As Form1) + Dim f4memoBinary As Object + Dim f4binary As Object + Dim f4memoAssignBinary As Object + Dim f4assignBinary As Object + Dim cb As Integer + cb = code4init() + Call code4safety(cb, 0) + + Dim fields(2) As FIELD4INFO + fields(0).fName = "FIELD" + fields(0).ftype = r4str + fields(0).flength = 10 + fields(1).fName = "MFIELD" + fields(1).ftype = r4memo + + Dim field, data, mfield As Integer + data = d4createData(cb, "bin", fields) + field = d4field(data, "field") + mfield = d4field(data, "mfield") + + 'UPGRADE_WARNING: Lower bound of array bin was changed from 5 to 0. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1033"' + Dim bin(8) As Byte ' prepare a Byte array to append + bin(5) = &H8S + bin(6) = &H9S + bin(7) = &HAS + bin(8) = &HBS + + Call d4appendStart(data, 0) + Call f4assignBinary(field, bin) + Call f4memoAssignBinary(mfield, bin) + Call d4append(data) + + Dim getdata() As Byte + 'UPGRADE_WARNING: Couldn't resolve default property of object f4binary(). Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"' + getdata = f4binary(field) + ' getdata contains 4 bytes from the 'bin' array plus 6 spaces + 'UPGRADE_WARNING: Couldn't resolve default property of object f4memoBinary(). Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"' + getdata = f4memoBinary(mfield) + ' getdata contains 4 bytes from the 'bin' array + + Call code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX102.vb b/examples/source/VB.NET/EX102.vb new file mode 100644 index 0000000..a37f82a --- /dev/null +++ b/examples/source/VB.NET/EX102.vb @@ -0,0 +1,56 @@ +Option Strict Off +Option Explicit On +Module Example + 'ex102 + + Private reindexDone As Boolean + Private gFrm As Form1 + Private gMutex As New System.Threading.Mutex() + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc, action As Short + Dim fPath As String + + gFrm = frm + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, "c:\examples\customer") + If db <> 0 Then + reindexDone = False + rc = d4reindexWithProgress(db, AddressOf ReindexProgress, 1200) + If rc = r4success Then + Do While True + gMutex.WaitOne() + If reindexDone = True Then + gMutex.ReleaseMutex() + Exit Do + End If + gMutex.ReleaseMutex() + System.Threading.Thread.Sleep(100) + System.Windows.Forms.Application.DoEvents() + Loop + MsgBox("Reindex is complete.", MsgBoxStyle.Information, "Reindex") + End If + End If + + Call code4close(cb) + Call code4initUndo(cb) + End Sub + + Function ReindexProgress(ByVal percent As Double) As Short + ' Handle progress here by updating a progress bar, + ' for example. + + gFrm.ListBox1.Items.Add(VB6.Format(percent * 100, ".##")) + If percent >= 1.0# Then + gMutex.WaitOne() + reindexDone = True + gMutex.ReleaseMutex() + End If + ReindexProgress = 0 + End Function +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX11.vb b/examples/source/VB.NET/EX11.vb new file mode 100644 index 0000000..0f82263 --- /dev/null +++ b/examples/source/VB.NET/EX11.vb @@ -0,0 +1,51 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX11.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex11 example code + Dim db, cb, dateField As Integer + Dim rc As Short + Dim today_Renamed As String + Dim oldOpt, oldLockAtt, oldOptWrite As Short + + cb = code4init() + oldLockAtt = code4lockAttempts(cb, WAIT4EVER) + oldOpt = code4optimize(cb, OPT4ALL) + oldOptWrite = code4optimizeWrite(cb, OPT4ALL) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATEFILE") + If code4errorCode(cb, r4check) Then code4exit((cb)) + + rc = d4lockAll(db) 'lock the file for optimizations to take place + + dateField = d4field(db, "DATE") + Call date4today(today_Renamed) + + rc = code4optStart(cb) + rc = d4top(db) + Do While d4eof(db) = 0 + Call f4assign(dateField, today_Renamed) + rc = d4skip(db, 1) + Loop + rc = code4optSuspend(cb) + + rc = d4close(db) + rc = code4lockAttempts(cb, oldLockAtt) + rc = code4optimize(cb, oldOpt) + rc = code4optimizeWrite(cb, oldOptWrite) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX12.vb b/examples/source/VB.NET/EX12.vb new file mode 100644 index 0000000..d4ab556 --- /dev/null +++ b/examples/source/VB.NET/EX12.vb @@ -0,0 +1,64 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX12.VB + + Public cb, db As Integer + Public rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATEFILE") + Call modifyRecordValues() + rc = code4initUndo(cb) + End Sub + + Sub modifyRecordValues() + Dim buf As String + Dim field As Integer + + rc = code4readLock(cb, 1) + rc = code4lockAttempts(cb, 3) + + field = d4field(db, "DATE") + + rc = d4top(db) + Do While rc = r4locked + If retry() = 1 Then rc = d4top(db) + Loop + + If rc = r4locked Then Exit Sub + + Do While d4eof(db) = 0 + buf = InputBox("Enter the new record value", "EX12", "19950101") + Call f4assign(field, buf) + + rc = d4skip(db, 1) + Do While rc = r4locked + If retry() = 1 Then rc = d4skip(db, 1) + Loop + If rc = r4locked Then Exit Sub + Loop + End Sub + + Function retry() As Integer + rc = MsgBox("Record locked by another user. Retry?", MsgBoxStyle.YesNo) + If rc = IDYES Then + retry = 1 + Else + retry = 0 + End If + End Function +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX13.vb b/examples/source/VB.NET/EX13.vb new file mode 100644 index 0000000..274f8d7 --- /dev/null +++ b/examples/source/VB.NET/EX13.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX13.VB + + Public lf As String 'Line Feed + Public fpath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, tag As Integer + Dim rc As Short + + cb = code4init() + rc = code4readOnly(cb, 1) + + 'open a file on a drive without write access + db = d4open(cb, "W:\DATA1.DBF") + + If code4errorCode(cb, 0) = r4success Then + tag = d4tag(db, "NAME_TAG") + Call d4tagSelect(db, tag) + + If d4seek(db, "Sarah Webber") = 0 Then + MsgBox("Sarah is found") + Else + MsgBox("Sarah is not found") + End If + + rc = d4close(db) + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX14.vb b/examples/source/VB.NET/EX14.vb new file mode 100644 index 0000000..37b8803 --- /dev/null +++ b/examples/source/VB.NET/EX14.vb @@ -0,0 +1,63 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX14.VB + + Public cb, db As Integer + Public rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Function createFiles() As Short + Dim fields() As FIELD4INFO + Dim tags() As TAG4INFO + + ReDim fields(3) + fields(0).fName = "NAME" + fields(0).ftype = r4str + fields(0).flength = 20 + fields(0).fdecimals = 0 + + fields(1).fName = "AGE" + fields(1).ftype = r4num + fields(1).flength = 3 + fields(1).fdecimals = 0 + + fields(2).fName = "BIRTH_DATE" + fields(2).ftype = r4date + fields(2).flength = 8 + fields(2).fdecimals = 0 + + ReDim tags(3) + tags(0).name = "INF_AGE" + tags(0).expression = "AGE" + + tags(1).name = "INF_BRTH" + tags(1).expression = "BIRTH_DATE" + + tags(2).name = "INF_NAME" + tags(2).expression = "NAME" + + rc = code4safety(cb, 0) 'Turn off safety -- overwrite files + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4create(cb, fPath & "INFO.DBF", fields, tags) + + createFiles = code4errorCode(cb, r4check) + End Function + + Sub ExCode(ByRef frm As Form1) + cb = code4init() + + rc = createFiles() + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX15.vb b/examples/source/VB.NET/EX15.vb new file mode 100644 index 0000000..4444580 --- /dev/null +++ b/examples/source/VB.NET/EX15.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX15.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex15 example code + Dim cb, db As Integer + Dim ex, ex2 As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + rc = d4top(db) + + ex = expr4parse(db, "TRIM(L_NAME)+', '+TRIM(F_NAME)") + rc = code4calcCreate(cb, ex, "NAMES") + frm.ListBox1.Items.Add(expr4str(ex)) + + ex2 = expr4parse(db, "'HELLO '+NAMES()") 'no space in dBASE function calls + frm.ListBox1.Items.Add(expr4str(ex2)) + + Call expr4free(ex2) + Call code4calcReset(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX16.vb b/examples/source/VB.NET/EX16.vb new file mode 100644 index 0000000..aef8c7e --- /dev/null +++ b/examples/source/VB.NET/EX16.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX16.VB + + Public cb As Integer + Public rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db As Integer + cb = code4init() + rc = code4autoOpen(cb, 0) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + Call openAFile() + + db = d4open(cb, fPath & "DATA1") 'open a second file + frm.ListBox1.Items.Add("Number of records in DATA1: " & Str(d4recCount(db))) + + rc = code4close(cb) 'INFO and DATA1 are both closed + rc = code4initUndo(cb) + End Sub + + Sub openAFile() + Dim db As Integer + 'db falls out of scope. the data file is still open + db = d4open(cb, fPath & "INFO") + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX17.vb b/examples/source/VB.NET/EX17.vb new file mode 100644 index 0000000..8e85335 --- /dev/null +++ b/examples/source/VB.NET/EX17.vb @@ -0,0 +1,43 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX17.VB + + Public cb As Integer + Public rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + Call openAFile() + + db = code4data(cb, "INFO") 'obtain a new DATA4 structure + If db <> 0 Then + frm.ListBox1.Items.Add("INFO has " & Str(d4recCount(db)) & " records") + rc = d4top(db) + 'an alternative way to close the file + rc = d4close(code4data(cb, "INFO")) + End If + + rc = code4initUndo(cb) + End Sub + + Sub openAFile() + Dim db As Integer + 'db falls out of scope. Data file is still open + db = d4open(cb, fPath & "INFO") + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX18.vb b/examples/source/VB.NET/EX18.vb new file mode 100644 index 0000000..bcb4f8d --- /dev/null +++ b/examples/source/VB.NET/EX18.vb @@ -0,0 +1,28 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX18.VB + + Public cb As Integer + Public rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + cb = code4init() + Call exitToSystem() + End Sub + + Sub exitToSystem() + MsgBox("Shutting down application ... ") + + rc = code4close(cb) + Call code4exit(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX19.vb b/examples/source/VB.NET/EX19.vb new file mode 100644 index 0000000..7c9aa20 --- /dev/null +++ b/examples/source/VB.NET/EX19.vb @@ -0,0 +1,46 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX19.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim data1, cb, data2 As Integer + Dim rc As Short + Dim numRec As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + data1 = d4open(cb, fPath & "DATA1") + data2 = d4open(cb, fPath & "DATA2") + + rc = d4top(data1) + rc = d4top(data2) + + rc = d4lockAddFile(data1) + rc = d4lockAddAppend(data2) + + numRec = d4recCount(data2) + + If numRec > 2 Then + rc = d4lockAdd(data2, numRec) + rc = d4lockAdd(data2, numRec - 1) + End If + + If code4lock(cb) = r4success Then + MsgBox("All locks were successfully performed") + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX2.vb b/examples/source/VB.NET/EX2.vb new file mode 100644 index 0000000..59edf32 --- /dev/null +++ b/examples/source/VB.NET/EX2.vb @@ -0,0 +1,44 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX2.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex2 example code + + Dim db, cb, info, ind As Integer + Dim rc As Short + + cb = code4init() + + ' Do not automatically open production index file + rc = code4autoOpen(cb, 0) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + info = d4open(cb, fPath & "INFO") + ind = i4open(info, fPath & "INFO") + + If ind = 0 Then + MsgBox("Production index file is not opened", MsgBoxStyle.OKOnly) + End If + + ' DATA1.DBF has a production index. Open it + rc = code4autoOpen(cb, 1) + db = d4open(cb, fPath & "DATA1") + + ' Some other code + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX20.vb b/examples/source/VB.NET/EX20.vb new file mode 100644 index 0000000..fb45925 --- /dev/null +++ b/examples/source/VB.NET/EX20.vb @@ -0,0 +1,44 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX20.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc, delCount As Short + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + error4exitTest((cb)) + + 'initialize optimization with default settings + + rc = code4optStart(cb) + + delCount = 0 + rc = d4top(db) + Do While rc = r4success + If d4deleted(db) Then + delCount = delCount + 1 + End If + rc = d4skip(db, 1) + Loop + + frm.ListBox1.Items.Add(Str(delCount) & " records are marked for deletion") + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX21.vb b/examples/source/VB.NET/EX21.vb new file mode 100644 index 0000000..248556a --- /dev/null +++ b/examples/source/VB.NET/EX21.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX21.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + rc = d4lockAll(db) + rc = d4optimizeWrite(db, OPT4ALL) + + rc = code4optStart(cb) + '... some other code + rc = code4optSuspend(cb) 'flush & free optimization memory. + + rc = d4unlock(db) 'let other users make modifications. + '... some other code + rc = d4lockAll(db) + rc = code4optStart(cb) + '... some other code + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX22.vb b/examples/source/VB.NET/EX22.vb new file mode 100644 index 0000000..daef61f --- /dev/null +++ b/examples/source/VB.NET/EX22.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX22.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex22 example code + Dim info, cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + info = d4open(cb, fPath & "INFO") + db = d4open(cb, fPath & "DATA1") + + rc = d4lock(info, 1) + If rc = r4success Then frm.ListBox1.Items.Add("lock successful") + rc = d4lockAll(db) + If rc = r4success Then frm.ListBox1.Items.Add("lock successful") + rc = code4unlock(cb) 'unlocks all open files + If rc = r4success Then frm.ListBox1.Items.Add("unlock successful") + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX23.vb b/examples/source/VB.NET/EX23.vb new file mode 100644 index 0000000..7a15160 --- /dev/null +++ b/examples/source/VB.NET/EX23.vb @@ -0,0 +1,38 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX23.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim info, cb, field As Integer + Dim rc As Short + Dim iRec, recNum As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + info = d4open(cb, fPath & "DATA2") + + rc = code4optStart(cb) + field = d4field(info, "NAME") + + recNum = d4recCount(info) + For iRec = 1 To recNum + rc = d4go(info, iRec) + Call f4assign(field, "New Data") + Next + + rc = d4close(info) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX24.vb b/examples/source/VB.NET/EX24.vb new file mode 100644 index 0000000..f2b9b3a --- /dev/null +++ b/examples/source/VB.NET/EX24.vb @@ -0,0 +1,29 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX24.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + frm.ListBox1.Items.Add("The alias of the db file INFO.DBF is " & d4alias(db)) + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX25.vb b/examples/source/VB.NET/EX25.vb new file mode 100644 index 0000000..b11f07a --- /dev/null +++ b/examples/source/VB.NET/EX25.vb @@ -0,0 +1,50 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX25.BAS + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = code4optStart(cb) + + rc = d4appendBlank(db) + rc = d4appendBlank(db) + + 'Append a copy of record two, assuming record two exists + rc = d4go(db, 2) + rc = d4appendStart(db, 0) 'a false parameter means don't copy memo entries + rc = d4append(db) 'append a copy of record 2 using a blank memo + + rc = d4go(db, 2) + rc = d4appendStart(db, 1) 'a true parameter means copy memo entries + rc = d4append(db) 'append a copy of record 2 with its memo + + 'Set the record buffer to blank, change a field's value, and append + 'the resulting record. + rc = d4appendStart(db, 0) + Call d4blank(db) + + field = d4field(db, "NAME") + Call f4assign(field, "New Field Value") + rc = d4append(db) + + 'close all open files and release any allocated memory + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX26.vb b/examples/source/VB.NET/EX26.vb new file mode 100644 index 0000000..b16a943 --- /dev/null +++ b/examples/source/VB.NET/EX26.vb @@ -0,0 +1,34 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX26.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc, i As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + 'Add 20 blank records + For i = 1 To 20 + rc = d4appendBlank(db) + Next + + 'Close the data file + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX27.vb b/examples/source/VB.NET/EX27.vb new file mode 100644 index 0000000..e7f6ea9 --- /dev/null +++ b/examples/source/VB.NET/EX27.vb @@ -0,0 +1,33 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX27.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + 'Blanks out all records in the data file + rc = d4top(db) + Do While d4eof(db) = 0 + Call d4blank(db) + rc = d4skip(db, 1) + Loop + + rc = code4initUndo(cb) 'close all files and release any memory + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX28.vb b/examples/source/VB.NET/EX28.vb new file mode 100644 index 0000000..ca14f49 --- /dev/null +++ b/examples/source/VB.NET/EX28.vb @@ -0,0 +1,36 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX28.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + field = d4fieldJ(db, 1) + + 'output the first field of every record in reverse sequential order. + rc = d4bottom(db) + Do While d4bof(db) = 0 + frm.ListBox1.Items.Add(f4str(field)) + rc = d4skip(db, -1) + Loop + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX29.vb b/examples/source/VB.NET/EX29.vb new file mode 100644 index 0000000..daf3735 --- /dev/null +++ b/examples/source/VB.NET/EX29.vb @@ -0,0 +1,30 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX29.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + rc = d4bottom(db) + frm.ListBox1.Items.Add("Last Name added: " & f4str(d4field(db, "NAME"))) + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX3.vb b/examples/source/VB.NET/EX3.vb new file mode 100644 index 0000000..7ca33ad --- /dev/null +++ b/examples/source/VB.NET/EX3.vb @@ -0,0 +1,44 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX3.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex3 example code + Dim cb, temp As Integer + Dim rc As Short + Dim fieldInfo() As FIELD4INFO + + ReDim fieldInfo(1) + + fieldInfo(0).fName = "NAME" + fieldInfo(0).ftype = r4str + fieldInfo(0).flength = 10 + fieldInfo(0).fdecimals = 0 + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + rc = code4errCreate(cb, 0) + temp = d4createData(cb, fPath & "NEWFILE", fieldInfo) + If code4errorCode(cb, r4check) = r4noCreate Then + 'File exists. Try in the temp directory. + temp = d4createData(cb, "C:\TEMP\NEWFILE", fieldInfo) 'TEMP must exist + End If + + If code4errorCode(cb, 0) < 0 Then Call code4exit(cb) + + 'Some other code + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX30.vb b/examples/source/VB.NET/EX30.vb new file mode 100644 index 0000000..f7fd394 --- /dev/null +++ b/examples/source/VB.NET/EX30.vb @@ -0,0 +1,44 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX30.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + field = d4field(db, "L_NAME") + rc = d4top(db) + + If d4changed(db, -1) = 0 Then 'Displays false + MsgBox("Changed Status: FALSE") + Else + MsgBox("Changed Status: TRUE") + End If + + Call f4assign(field, "TEMP DATA") + If d4changed(db, -1) = 0 Then 'Displays true + MsgBox("Changed Status: FALSE") + Else + MsgBox("Changed Status: TRUE") + End If + + rc = d4changed(db, 0) + rc = d4close(db) 'top record not flushed + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX31.vb b/examples/source/VB.NET/EX31.vb new file mode 100644 index 0000000..eb12656 --- /dev/null +++ b/examples/source/VB.NET/EX31.vb @@ -0,0 +1,46 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX31.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim checkData, cb, testIndex As Integer + Dim rc As Short + Dim fileName, indexName As String + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + rc = code4autoOpen(cb, 0) 'open index file manually + fileName = InputBox("Enter data file name ", "EX31", "INFO") + indexName = InputBox("Enter index file name ", "EX31", "INFO") + If fileName = "" Then + Exit Sub + Else + checkData = d4open(cb, fPath & fileName) + testIndex = i4open(checkData, fPath & indexName) + + error4exitTest((cb)) + rc = code4optStart(cb) + + If d4check(checkData) = r4success Then + MsgBox("Index is OK !") + Else + MsgBox("Problem with Index") + End If + End If + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX32.vb b/examples/source/VB.NET/EX32.vb new file mode 100644 index 0000000..19af704 --- /dev/null +++ b/examples/source/VB.NET/EX32.vb @@ -0,0 +1,59 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX32.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, secondFile As Integer + Dim fieldArray() As FIELD4INFO + Dim tagArray() As TAG4INFO + Dim rc As Short + + cb = code4init() + rc = code4safety(cb, 0) 'overwrite the file if it exists + + ReDim fieldArray(3) + fieldArray(0).fName = "NAME_FIELD" + fieldArray(0).ftype = r4str + fieldArray(0).flength = 20 + fieldArray(0).fdecimals = 0 + + fieldArray(1).fName = "AGE_FIELD" + fieldArray(1).ftype = r4num + fieldArray(1).flength = 2 + fieldArray(1).fdecimals = 0 + + fieldArray(2).fName = "BIRTH_DATE" + fieldArray(2).ftype = r4date + fieldArray(2).flength = 8 + fieldArray(2).fdecimals = 0 + + ReDim tagArray(1) + tagArray(0).name = "NAME_TAG" + tagArray(0).expression = "NAME_FIELD" + + 'Specify full path if stand-alone + If u4switch() And &H80s Then fPath = VB6.GetPath & "\" + + db = d4create(cb, fPath & "NEWDBF", fieldArray, tagArray) + + error4exitTest((cb)) + + If code4errorCode(cb, r4check) < 0 Then + MsgBox("An error occurred, NEWDBF was not created") + Else + MsgBox("Created successfully") + End If + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX33.vb b/examples/source/VB.NET/EX33.vb new file mode 100644 index 0000000..621fc8c --- /dev/null +++ b/examples/source/VB.NET/EX33.vb @@ -0,0 +1,54 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX33.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, secondFile As Integer + Dim fieldArray() As FIELD4INFO + Dim rc As Short + + cb = code4init() + rc = code4safety(cb, 0) 'overwrite the file if it exists + + ReDim fieldArray(3) + fieldArray(0).fName = "NAME_FIELD" + fieldArray(0).ftype = r4str + fieldArray(0).flength = 20 + fieldArray(0).fdecimals = 0 + + fieldArray(1).fName = "AGE_FIELD" + fieldArray(1).ftype = r4num + fieldArray(1).flength = 2 + fieldArray(1).fdecimals = 0 + + fieldArray(2).fName = "BIRTH_DATE" + fieldArray(2).ftype = r4date + fieldArray(2).flength = 8 + fieldArray(2).fdecimals = 0 + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4createData(cb, fPath & "NEWDBF", fieldArray) + + error4exitTest((cb)) + + If code4errorCode(cb, r4check) < 0 Then + MsgBox("An error occurred, NEWDBF was not created") + Else + MsgBox("Created successfully") + End If + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX34.vb b/examples/source/VB.NET/EX34.vb new file mode 100644 index 0000000..8eef456 --- /dev/null +++ b/examples/source/VB.NET/EX34.vb @@ -0,0 +1,38 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX34.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + rc = code4accessMode(cb, OPEN4DENY_RW) 'open file exclusively to speed pack + db = d4open(cb, fPath & "INFO") + error4exitTest((cb)) + + rc = code4optStart(cb) + rc = d4top(db) + Do While rc = r4success + Call d4delete(db) 'mark record for deletion + rc = d4skip(db, 2) + Loop + 'physically remove the deleted records from the disk + rc = d4pack(db) + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX35.vb b/examples/source/VB.NET/EX35.vb new file mode 100644 index 0000000..1c9a788 --- /dev/null +++ b/examples/source/VB.NET/EX35.vb @@ -0,0 +1,38 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX35.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + Dim count As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = code4optStart(cb) + count = 0 + + rc = d4top(db) + Do While rc = r4success + If d4deleted(db) = 1 Then + count = count + 1 + End If + rc = d4skip(db, 1) + Loop + frm.ListBox1.Items.Add("INFO has " & Str(count) & " deleted records") + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX36.vb b/examples/source/VB.NET/EX36.vb new file mode 100644 index 0000000..2389f3a --- /dev/null +++ b/examples/source/VB.NET/EX36.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX36.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + 'Go to the end of the file and set the End of File flag + rc = d4goEof(db) + 'Check if the End of File flag is set + If d4eof(db) = 1 Then + MsgBox("This is always true") + rc = d4bottom(db) 'reset the eof flag + End If + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX37.vb b/examples/source/VB.NET/EX37.vb new file mode 100644 index 0000000..7716416 --- /dev/null +++ b/examples/source/VB.NET/EX37.vb @@ -0,0 +1,32 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX37.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc, num As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + For num = d4numFields(db) To 1 Step -1 + field = d4fieldJ(db, num) + If num = d4fieldNumber(db, f4name(field)) Then + MsgBox("This is always true") + End If + Next + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX38.vb b/examples/source/VB.NET/EX38.vb new file mode 100644 index 0000000..0491b23 --- /dev/null +++ b/examples/source/VB.NET/EX38.vb @@ -0,0 +1,33 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX38.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, age As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = d4go(db, 2) + age = d4field(db, "AGE") + Call f4assignLong(age, 49) + 'Explicitly flush the change to disk in case the power goes out + rc = d4flush(db) + '... some other code.... + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX39.vb b/examples/source/VB.NET/EX39.vb new file mode 100644 index 0000000..5b7dfd5 --- /dev/null +++ b/examples/source/VB.NET/EX39.vb @@ -0,0 +1,40 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX39.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + rc = code4lockAttempts(cb, 1) 'do not wait when locking + rc = code4readLock(cb, 1) + + rc = d4go(db, 2) + If rc = r4locked Then + MsgBox("Record 3 was locked by another user") + rc = code4readLock(cb, 0) 'turn off automatic locking + rc = d4go(db, 2) + If rc = r4locked Then + MsgBox("This will never happen because CODE4.readLock is false") + End If + End If + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX4.vb b/examples/source/VB.NET/EX4.vb new file mode 100644 index 0000000..53aff43 --- /dev/null +++ b/examples/source/VB.NET/EX4.vb @@ -0,0 +1,45 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX4.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex4 example code + + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + ' Do not add duplicate records to unique tags or the data file and + ' return r4unique when attempted. + rc = code4errDefaultUnique(cb, r4unique) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = d4top(db) + rc = d4appendStart(db, 0) + + rc = d4append(db) ' append a duplicate copy of the top record + + If rc = r4unique Then + MsgBox("Attempt to add a duplicate record failed.", MsgBoxStyle.OKOnly) + Else + MsgBox("Attempt to add a duplicate record succeeded", MsgBoxStyle.OKOnly) + MsgBox("Record in both data and index file", MsgBoxStyle.OKOnly) + End If + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX40.vb b/examples/source/VB.NET/EX40.vb new file mode 100644 index 0000000..f516ef1 --- /dev/null +++ b/examples/source/VB.NET/EX40.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX40.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, index As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + 'Since CODE4.autoOpen is true (non-zero) by default + 'the index file should have been opened + index = d4index(db, "INFO") + If index <> 0 Then + MsgBox("Index file INFO has been opened") + End If + + index = d4index(db, fPath & "JUNK") + If index = 0 Then + MsgBox("Index file JUNK has not been opened") + End If + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX41.vb b/examples/source/VB.NET/EX41.vb new file mode 100644 index 0000000..455c27c --- /dev/null +++ b/examples/source/VB.NET/EX41.vb @@ -0,0 +1,41 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX41.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + rc = code4lockAttempts(cb, 4) 'try lock 4 times + rc = d4lock(db, 2) 'lock record 5 + If rc = r4success Then + MsgBox("Record 2 is now locked") + ElseIf rc = r4locked Then + MsgBox("Record 2 is locked by another user") + End If + + rc = code4lockAttempts(cb, WAIT4EVER) 'try lock forever + rc = d4lock(db, 2) + If rc = r4locked Then + MsgBox("This should never happen") + End If + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX42.vb b/examples/source/VB.NET/EX42.vb new file mode 100644 index 0000000..a406783 --- /dev/null +++ b/examples/source/VB.NET/EX42.vb @@ -0,0 +1,32 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX42.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + rc = d4lockAll(db) + If rc = r4success Then + MsgBox("Lock is successful") + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX43.vb b/examples/source/VB.NET/EX43.vb new file mode 100644 index 0000000..fdc2dfd --- /dev/null +++ b/examples/source/VB.NET/EX43.vb @@ -0,0 +1,34 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX43.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + 'Lock all the records in the data file as well as the append bytes + 'all at once. Existing locks are removed according to + 'code4unlockAuto + + rc = d4lockFile(db) + If rc = r4success Then + MsgBox("Other users can read this data file, but can not make modifications until the lock is removed") + End If + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX44.vb b/examples/source/VB.NET/EX44.vb new file mode 100644 index 0000000..ab4c3ff --- /dev/null +++ b/examples/source/VB.NET/EX44.vb @@ -0,0 +1,34 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX44.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + + If d4pack(db) = r4success Then + MsgBox("Records marked for deletion are removed") + End If + If d4memoCompress(db) = r4success Then + MsgBox("Memo entries are compressed") + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX45.vb b/examples/source/VB.NET/EX45.vb new file mode 100644 index 0000000..8e85a94 --- /dev/null +++ b/examples/source/VB.NET/EX45.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX45.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc, fieldNum As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + rc = code4optStart(cb) + rc = d4top(db) + Do While rc <> r4eof + For fieldNum = 1 To d4numFields(db) + frm.ListBox1.Items.Add(f4name(d4fieldJ(db, fieldNum))) + Next + rc = d4skip(db, 1) + Loop + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX46.vb b/examples/source/VB.NET/EX46.vb new file mode 100644 index 0000000..25f34e0 --- /dev/null +++ b/examples/source/VB.NET/EX46.vb @@ -0,0 +1,32 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX46.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + If db <> 0 Then + frm.ListBox1.Items.Add("Data File INFO.DBF has " & Str(d4recCount(db)) & " records") + End If + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX47.vb b/examples/source/VB.NET/EX47.vb new file mode 100644 index 0000000..7233909 --- /dev/null +++ b/examples/source/VB.NET/EX47.vb @@ -0,0 +1,41 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX47.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, extra As Integer + Dim rc As Short + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + 'Open the file exclusively, default optimization is the same as if + 'd4optimize( db, OPT4EXCLUSIVE ) were called. + + 'open a shared file. + rc = code4accessMode(cb, OPEN4DENY_NONE) + extra = d4open(cb, fPath & "DATA1") + + rc = d4optimize(extra, OPT4ALL) 'read optimize the extra "DATA" file + + rc = code4optStart(cb) 'Begin the memory optimizations. + + ' .... Some other code .... + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX48.vb b/examples/source/VB.NET/EX48.vb new file mode 100644 index 0000000..f9abee6 --- /dev/null +++ b/examples/source/VB.NET/EX48.vb @@ -0,0 +1,43 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX48.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, ageField As Integer + Dim rc As Short + Dim age As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + rc = d4optimizeWrite(db, OPT4ALL) + 'when doing write optimization on shared files, it is necessary to + 'lock the file, preferably with d4lockAll( ) + rc = d4lockAll(db) + + rc = code4optStart(cb) 'Begin optimization + ageField = d4field(db, "AGE") + 'append a copy of the first record, assigning the age field's + 'value from 20 to 65 + rc = d4top(db) + For age = 20 To 65 + rc = d4appendStart(db, 0) + Call f4assignLong(ageField, age) + rc = d4append(db) + Next + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX49.vb b/examples/source/VB.NET/EX49.vb new file mode 100644 index 0000000..5563174 --- /dev/null +++ b/examples/source/VB.NET/EX49.vb @@ -0,0 +1,38 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX49.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Integer + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) 'open file exclusively + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + error4exitTest((cb)) + rc = code4optStart(cb) + + rc = d4top(db) + Do While rc = r4success + Call d4delete(db) 'Mark every other record for deletion + rc = d4skip(db, 2) + Loop + 'Remove the deleted records from the disk physically + rc = d4pack(db) + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX5.vb b/examples/source/VB.NET/EX5.vb new file mode 100644 index 0000000..a0b9eaa --- /dev/null +++ b/examples/source/VB.NET/EX5.vb @@ -0,0 +1,37 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX5.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, expr As Integer + Dim badExpr As String + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + badExpr = "NAME = 5" + expr = expr4parse(db, badExpr) + MsgBox("An error message just displayed", MsgBoxStyle.OKOnly) + + rc = code4errorCode(cb, 0) + rc = code4errExpr(cb, 0) + expr = expr4parse(db, badExpr) + MsgBox("No error message displayed.", MsgBoxStyle.OKOnly) + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX50.vb b/examples/source/VB.NET/EX50.vb new file mode 100644 index 0000000..4527890 --- /dev/null +++ b/examples/source/VB.NET/EX50.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX50.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, defaultTag As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + defaultTag = d4tagDefault(db) + error4exitTest((cb)) + + Call d4tagSelect(db, defaultTag) 'select the default tag + rc = d4top(db) + rc = d4positionSet(db, 0.25) 'move one quarter through the index file. + frm.ListBox1.Items.Add("Record number: " & Str(d4recNo(db))) + frm.ListBox1.Items.Add("The current position is " & Str(d4position(db))) + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX51.vb b/examples/source/VB.NET/EX51.vb new file mode 100644 index 0000000..ef48ed3 --- /dev/null +++ b/examples/source/VB.NET/EX51.vb @@ -0,0 +1,50 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX51.VB + + Dim cb, db As Integer + Dim rc As Integer + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim count As Integer + Dim lockTries As Short + + lockTries = WAIT4EVER + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + count = recallAll(lockTries) + frm.ListBox1.Items.Add("The number of recalled records is " & Str(count)) + rc = code4initUndo(cb) + End Sub + + Function recallAll(ByRef lockTries As Short) As Integer + Dim saveSelected As Integer + Dim count As Integer + + saveSelected = d4tagSelected(db) + Call d4tagSelect(db, 0) 'use record number ordering + count = 0 + rc = d4top(db) + Do While rc = r4success + Call d4recall(db) + If d4changed(db, -1) <> 0 Then count = count + 1 + rc = d4skip(db, 1) + Loop + + Call d4tagSelect(db, saveSelected) 'reset the selected tag + recallAll = count + End Function +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX52.vb b/examples/source/VB.NET/EX52.vb new file mode 100644 index 0000000..16fb3dc --- /dev/null +++ b/examples/source/VB.NET/EX52.vb @@ -0,0 +1,42 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX52.VB + + Dim cb, db As Integer + Dim rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim count As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + count = recsInFile() + frm.ListBox1.Items.Add("the number of records in the file is " & Str(count)) + rc = code4initUndo(cb) + End Sub + + Function recsInFile() As Integer + Dim count As Integer + + If code4errorCode(cb, r4check) < 0 Then 'an error occurred + recsInFile = -1 + Exit Function + End If + count = d4recCount(db) 'save the record count + recsInFile = count + End Function +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX53.vb b/examples/source/VB.NET/EX53.vb new file mode 100644 index 0000000..852ba42 --- /dev/null +++ b/examples/source/VB.NET/EX53.vb @@ -0,0 +1,37 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX53.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, defaultTag As Integer + Dim rc As Short + Dim count As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + defaultTag = d4tagDefault(db) + Call d4tagSelect(db, defaultTag) 'select the default tag + count = 1 + rc = d4top(db) + Do While rc = r4success + frm.ListBox1.Items.Add("Tag position: " & Str(count) & " Record position: " & Str(d4recNo(db))) + count = count + 1 + rc = d4skip(db, 1) + Loop + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX54.vb b/examples/source/VB.NET/EX54.vb new file mode 100644 index 0000000..4b785bc --- /dev/null +++ b/examples/source/VB.NET/EX54.vb @@ -0,0 +1,54 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX54.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim fromFile, cb, toFile As Integer + Dim fromField, toField As Integer + Dim toStr As String + Dim rc, i As Short + Dim iRecs As Integer + + 'Copy records from one database to another. + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + 'Data file TO_DBF and FROM_DBF have the same file structure + fromFile = d4open(cb, fPath & "FROM_DBF") + toFile = d4open(cb, fPath & "TO_DBF") + rc = code4optStart(cb) + + If d4recWidth(fromFile) <> d4recWidth(toFile) Then + rc = error4describe(cb, e4result, 0, "Structures not identical", "", "") + code4exit((cb)) + End If + + error4exitTest((cb)) + For iRecs = 1 To d4recCount(fromFile) + rc = d4go(fromFile, iRecs) 'read the data file record + rc = d4appendStart(toFile, 0) 'copy the data file buffer + For i = 1 To d4numFields(fromFile) + fromField = d4fieldJ(fromFile, i) + 'UPGRADE_WARNING: Couldn't resolve default property of object f4nCpy(). Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"' + rc = f4nCpy(fromField, toStr, f4len(fromField)) + toField = d4fieldJ(toFile, i) + Call f4assign(toField, toStr) + Next + rc = d4append(toFile) + Next + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX55.vb b/examples/source/VB.NET/EX55.vb new file mode 100644 index 0000000..4a841bc --- /dev/null +++ b/examples/source/VB.NET/EX55.vb @@ -0,0 +1,34 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX55.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = d4optimize(db, OPT4ALL) + rc = code4optStart(cb) + rc = d4top(db) + MsgBox("Click OK when you want to refresh your data", MsgBoxStyle.OKOnly) + rc = d4refresh(db) + rc = d4top(db) 're-read the record from disk + MsgBox("The latest infomation is now in the buffer") + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX56.vb b/examples/source/VB.NET/EX56.vb new file mode 100644 index 0000000..f21c8c8 --- /dev/null +++ b/examples/source/VB.NET/EX56.vb @@ -0,0 +1,34 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX56.VB + + Dim cb, db As Integer + Dim rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + cb = code4init() + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + db = d4open(cb, fPath & "DATA1") + rc = d4top(db) + Call updateData() + rc = code4initUndo(cb) + End Sub + + Sub updateData() + If d4changed(db, -1) > 0 Then + frm.ListBox1.Items.Add("Changes not discarded") + Else + rc = d4refreshRecord(db) + End If + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX57.vb b/examples/source/VB.NET/EX57.vb new file mode 100644 index 0000000..8a10cb6 --- /dev/null +++ b/examples/source/VB.NET/EX57.vb @@ -0,0 +1,34 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX57.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + frm.ListBox1.Items.Add("Reindexing " & d4alias(db) & " Please Wait") + If d4reindex(db) <> 0 Then + MsgBox("Reindex NOT successful") + Else + MsgBox("Reindex Successful") + End If + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX58.vb b/examples/source/VB.NET/EX58.vb new file mode 100644 index 0000000..6156f31 --- /dev/null +++ b/examples/source/VB.NET/EX58.vb @@ -0,0 +1,72 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX58.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, age As Integer + Dim rc As Short + Dim birth, result As String + Dim birthLong As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "PEOPLE.DBF") + 'Assume PEOPLE.DBF has a production index file with + 'tags PPL_NAME, PPL_AGE, PPL_BRTH + Call d4tagSelect(db, d4tag(db, "PPL_NAME")) + + If d4seek(db, "fred") = r4success Then + frm.ListBox1.Items.Add("fred is in record # " & Str(d4recNo(db))) + End If + + If d4seek(db, "HANK STEVENS") = r4success Then + frm.ListBox1.Items.Add("HANK STEVENS is in record #" & Str(d4recNo(db))) + End If + + Call d4tagSelect(db, d4tag(db, "PPL_AGE")) + age = d4field(db, "AGE") + + rc = d4seekDouble(db, 0.0#) + + If rc = r4success Or rc = r4after Then + frm.ListBox1.Items.Add("The youngest age is " & Str(f4int(age))) + End If + + 'Seek using the character version + rc = d4seek(db, "0") + + If rc = r4success Or rc = r4after Then + frm.ListBox1.Items.Add("The youngest age is " & Str(f4int(age))) + End If + + 'Assume PPL_BRTH is a Date key expression + Call d4tagSelect(db, d4tag(db, "PPL_BRTH")) + + birth = "19600415" + + If d4seek(db, birth) = r4success Then + Call date4format(birth, result, "MMM DD, CCYY") + frm.ListBox1.Items.Add("Found " & result) + End If + + birthLong = date4long(birth) + + If d4seekDouble(db, birthLong) = r4success Then + frm.ListBox1.Items.Add("Found " & result) + End If + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX59.vb b/examples/source/VB.NET/EX59.vb new file mode 100644 index 0000000..0b52e91 --- /dev/null +++ b/examples/source/VB.NET/EX59.vb @@ -0,0 +1,47 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX59.VB + + Dim cb, db As Integer + Dim rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim nameTag As Integer + Dim i As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "PEOPLE") + nameTag = d4tag(db, "PPL_NAME") + Call d4tagSelect(db, nameTag) + rc = d4top(db) + rc = SeekSeries("mickey") + frm.ListBox1.Items.Add("return code" & Str(rc)) + rc = code4initUndo(cb) + End Sub + + Function SeekSeries(ByRef s As String) As Short + rc = d4seekNext(db, s) + + If rc = r4notag Or rc = r4entry Or rc = r4locked Then + SeekSeries = rc + Exit Function + End If + + If rc = r4after Or rc = r4eof Then rc = d4seek(db, s) + + SeekSeries = rc + End Function +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX6.vb b/examples/source/VB.NET/EX6.vb new file mode 100644 index 0000000..e3dc14d --- /dev/null +++ b/examples/source/VB.NET/EX6.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX6.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex6 example code + Dim db, cb, field As Integer + Dim rc As Short + Dim badField As String + + cb = code4init() + + 'Use full path in stand-alone version + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + badField = "notAField" + field = d4field(db, badField) + + MsgBox("An error message just displayed", MsgBoxStyle.OKOnly) + + rc = code4errorCode(cb, 0) + rc = code4errFieldName(cb, 0) + + field = d4field(db, badField) + MsgBox("No error message displayed.", MsgBoxStyle.OKOnly) + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX60.vb b/examples/source/VB.NET/EX60.vb new file mode 100644 index 0000000..9c99552 --- /dev/null +++ b/examples/source/VB.NET/EX60.vb @@ -0,0 +1,44 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX60.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, nameField As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "NAMES") + 'Skip to the last record in the file whose NAME field contains "John" + + rc = code4optStart(cb) + nameField = d4field(db, "NAME") + + rc = d4bottom(db) + Do While d4bof(db) = 0 'Do while bof is false + If InStr(1, f4str(nameField), "White ") <> 0 Then Exit Do + rc = d4skip(db, -1) + Loop + + If d4bof(db) <> 0 Then + frm.ListBox1.Items.Add("White not located") + Else + frm.ListBox1.Items.Add("The last White is located in record # " & Str(d4recNo(db))) + End If + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX61.vb b/examples/source/VB.NET/EX61.vb new file mode 100644 index 0000000..6ee156d --- /dev/null +++ b/examples/source/VB.NET/EX61.vb @@ -0,0 +1,40 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX61.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim ageTag, cb, db, defaultTag As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "data1") + ageTag = d4tag(db, "AGE_TAG") + defaultTag = d4tagDefault(db) + + Call d4tagSelect(db, ageTag) 'Select the AGE_TAG tag + rc = d4seekDouble(db, 32) 'seek using the AGE_TAG tag + If rc = r4success Then frm.ListBox1.Items.Add("Found age 32") + + Call d4tagSelect(db, defaultTag) 'Select the default tag which is the ADDR_TAG tag + rc = d4seek(db, "1232") 'seek using the ADDR_TAG tag + If rc = r4success Then frm.ListBox1.Items.Add("Found address starting with 1232") + + Call d4tagSelect(db, 0) 'Select record number ordering + rc = d4top(db) 'physical top of the data file + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX62.vb b/examples/source/VB.NET/EX62.vb new file mode 100644 index 0000000..12c4515 --- /dev/null +++ b/examples/source/VB.NET/EX62.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX62.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, tag As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DBF") + tag = d4tag(db, "DBF_NAME") 'a tag with a '.NOT.DELETED()' filter + + rc = d4top(db) 'position to the first record that is not deleted + Call d4delete(db) 'current record is no longer located in the tag + + rc = d4tagSync(db, tag) + rc = d4skip(db, 1) + + 'some other code + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX63.vb b/examples/source/VB.NET/EX63.vb new file mode 100644 index 0000000..d858692 --- /dev/null +++ b/examples/source/VB.NET/EX63.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX63.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, defaultTag As Integer + Dim rc As Short + Dim count As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + defaultTag = d4tagDefault(db) + + Call d4tagSelect(db, defaultTag) + count = 0 + rc = d4top(db) 'top record in default tag + Do While d4eof(db) = 0 + count = count + 1 + rc = d4skip(db, 1) + Loop + frm.ListBox1.Items.Add(Str(count) & " records in the tag" & t4Alias(defaultTag)) + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX64.vb b/examples/source/VB.NET/EX64.vb new file mode 100644 index 0000000..03b494c --- /dev/null +++ b/examples/source/VB.NET/EX64.vb @@ -0,0 +1,46 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX64.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim nameTag, cb, db, nameField As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + nameTag = d4tag(db, "INF_NAME") + nameField = d4field(db, "NAME") + + Call error4exitTest(cb) + rc = d4lockAll(db) + Call d4tagSelect(db, nameTag) + + rc = d4seek(db, "John") + Do While rc = r4success + If StrComp(f4str(nameField), "John ") = 0 Then + 'UPGRADE_ISSUE: Form method Form1.Print was not upgraded. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2064"' + frm.ListBox1.Items.Add("John in record " & Str(d4recNo(db))) + Else + Exit Do + End If + rc = d4skip(db, 1) + Loop + + rc = d4unlock(db) + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX65.vb b/examples/source/VB.NET/EX65.vb new file mode 100644 index 0000000..fdb4fa0 --- /dev/null +++ b/examples/source/VB.NET/EX65.vb @@ -0,0 +1,37 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX65.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc, i As Short + Dim numRecs As Integer + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO1") + + rc = d4go(db, 1) + 'Make all the records in the data file the same as the first record + numRecs = d4recCount(db) + For i = numRecs To 2 Step -1 + If d4write(db, numRecs) <> 0 Then Exit For + Next + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX66.vb b/examples/source/VB.NET/EX66.vb new file mode 100644 index 0000000..d26a6ea --- /dev/null +++ b/examples/source/VB.NET/EX66.vb @@ -0,0 +1,38 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX66.VB + + Dim cb, db As Integer + Dim rc As Integer + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim toDelete As Integer + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + toDelete = 2 + rc = zapLast(toDelete, frm) + rc = code4initUndo(cb) + End Sub + + Function zapLast(ByRef toDelete As Integer, ByRef fm As Form1) As Integer + fm.ListBox1.Items.Add(d4alias(db) & " has " & Str(d4recCount(db)) & " records") + rc = d4zap(db, d4recCount(db) - toDelete + 1, 1000000) + fm.ListBox1.Items.Add(d4alias(db) & " now has " & Str(d4recCount(db)) & " records") + zapLast = d4recCount(db) + End Function +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX67.vb b/examples/source/VB.NET/EX67.vb new file mode 100644 index 0000000..9887b56 --- /dev/null +++ b/examples/source/VB.NET/EX67.vb @@ -0,0 +1,59 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX67.VB + 'NOTE: 'today' is a reserved word under VB .NET + + Dim cb, db As Integer + Dim rc As Integer + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim birthField, cb, db, birthTag As Integer + Dim result, today_Renamed, tomorrow, yesterday As String + Dim myBirthDate As String + Dim rc As Short + + Call date4today(today_Renamed) + Call date4format(today_Renamed, result, "MMMMMMMM DD, CCYY") + frm.ListBox1.Items.Add("Today is " & date4cdow(today_Renamed) & " " & result) + + Call date4assign(tomorrow, date4long(today_Renamed) + 1) + Call date4format(tomorrow, result, "MMMMMMMM DD, CCYY") + frm.ListBox1.Items.Add("Tomorrow is " & date4cdow(tomorrow) & " " & result) + + Call date4assign(yesterday, date4long(tomorrow) - 2) + Call date4format(yesterday, result, "MMMMMMMM DD, CCYY") + frm.ListBox1.Items.Add("Yesterday was " & date4cdow(yesterday) & " " & result) + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + birthField = d4field(db, "BIRTH_DATE") + birthTag = d4tag(db, "INF_BRTH") + Call d4tagSelect(db, birthTag) + myBirthDate = "19690225" + If d4seek(db, myBirthDate) = r4success Then + frm.ListBox1.Items.Add("I'm in record " & Str(d4recNo(db))) + End If + + 'change all birthdate fields to my birth date + rc = d4top(db) + Do While d4eof(db) = 0 + Call f4assign(birthField, myBirthDate) + rc = d4skip(db, 1) + Loop + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX68.vb b/examples/source/VB.NET/EX68.vb new file mode 100644 index 0000000..2bd6d80 --- /dev/null +++ b/examples/source/VB.NET/EX68.vb @@ -0,0 +1,25 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX68.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim result, dateStr, dayBefore, resultBefore As String + Dim rc As Short + + dateStr = "19900101" + + Call date4assign(dayBefore, date4long(dateStr) - 1) + Call date4format(dateStr, result, "MMM DD, 'YY") + Call date4format(dayBefore, resultBefore, "MMM DD, 'YY") + frm.ListBox1.Items.Add(result & " is after " & resultBefore) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX69.vb b/examples/source/VB.NET/EX69.vb new file mode 100644 index 0000000..bb71652 --- /dev/null +++ b/examples/source/VB.NET/EX69.vb @@ -0,0 +1,21 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX69.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim birthDate As String + + birthDate = InputBox("Enter your birth date in CCYYMMDD format", "EX69", "19730305") + frm.ListBox1.Items.Add("You were born on a " & date4cdow(birthDate)) + 'displays "You were born on a Monday" if a Monday was entered + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX7.vb b/examples/source/VB.NET/EX7.vb new file mode 100644 index 0000000..803cbec --- /dev/null +++ b/examples/source/VB.NET/EX7.vb @@ -0,0 +1,36 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX7.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex7 example code + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = d4go(db, d4recCount(db) + 1) + MsgBox("An error message was displayed", MsgBoxStyle.OKOnly) + + rc = code4errorCode(cb, 0) + rc = code4errGo(cb, 0) + + rc = d4go(db, d4recCount(db) + 1) + MsgBox("No error message was displayed", MsgBoxStyle.OKOnly) + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX70.vb b/examples/source/VB.NET/EX70.vb new file mode 100644 index 0000000..8761c4c --- /dev/null +++ b/examples/source/VB.NET/EX70.vb @@ -0,0 +1,22 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX70.VB + 'NOTE: 'today' is a reserved word under VB .NET + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim today_Renamed As String + + Call date4today(today_Renamed) + frm.ListBox1.Items.Add("The current month is " & date4cmonth(today_Renamed)) + 'displays "The current month is January" if the system clock says that it is + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX71.vb b/examples/source/VB.NET/EX71.vb new file mode 100644 index 0000000..3740ad3 --- /dev/null +++ b/examples/source/VB.NET/EX71.vb @@ -0,0 +1,22 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX71.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim tillEnd As Short + Dim dateStr As String + + Call date4today(dateStr) + tillEnd = 7 - date4dow(dateStr) + frm.ListBox1.Items.Add(Str(tillEnd) & " days left till the end of the week") + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX72.vb b/examples/source/VB.NET/EX72.vb new file mode 100644 index 0000000..a8725e1 --- /dev/null +++ b/examples/source/VB.NET/EX72.vb @@ -0,0 +1,27 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX72.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim dt, result As String + + dt = "19901002" + Call date4format(dt, result, "YY.MM.DD") 'result will contain "90.10.02" + frm.ListBox1.Items.Add(result) + Call date4format(dt, result, "CCYY.MM.DD") 'result will contain "1990.10.02" + frm.ListBox1.Items.Add(result) + Call date4format(dt, result, "MM/DD/YY") 'result will contain "10/02/90" + frm.ListBox1.Items.Add(result) + Call date4format(dt, result, "MMM DD/CCYY") 'result will contain "Oct 02/1990" + frm.ListBox1.Items.Add(result) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX73.vb b/examples/source/VB.NET/EX73.vb new file mode 100644 index 0000000..4da128b --- /dev/null +++ b/examples/source/VB.NET/EX73.vb @@ -0,0 +1,23 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX73.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim dayStr As String + + 'date4init puts a given date in CCYYMMDD format + Call date4init(dayStr, "Oct 07/90", "MMM DD/YY") + frm.ListBox1.Items.Add("Oct 07/90 becomes " & dayStr) + Call date4init(dayStr, "08/07/1989", "MM/DD/CCYY") + frm.ListBox1.Items.Add("08/07/1989 becomes " & dayStr) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX74.vb b/examples/source/VB.NET/EX74.vb new file mode 100644 index 0000000..d767bcd --- /dev/null +++ b/examples/source/VB.NET/EX74.vb @@ -0,0 +1,27 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX74.VB + 'NOTE: 'today' is a reserved word under VB .NET + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim yesterday As Integer + Dim tomorrow, today_Renamed, result As String + + Call date4today(today_Renamed) + yesterday = date4long(today_Renamed) - 1 + Call date4assign(tomorrow, yesterday + 2) + Call date4format(today_Renamed, result, "MMM DD, CCYY") + frm.ListBox1.Items.Add("Today is " & result) + frm.ListBox1.Items.Add("The Julian date for yesterday is " & Str(yesterday)) + frm.ListBox1.Items.Add("The Julian date for tomorrow is " & Str(date4long(tomorrow))) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX75.vb b/examples/source/VB.NET/EX75.vb new file mode 100644 index 0000000..dc01e9e --- /dev/null +++ b/examples/source/VB.NET/EX75.vb @@ -0,0 +1,41 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX75.VB + 'NOTE: 'today' is a reserved word under VB .NET + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim daysInMonth() As Short + Dim endOfMonth As Short + Dim today_Renamed As String + + ReDim daysInMonth(12) + daysInMonth(0) = 31 + daysInMonth(1) = 28 + daysInMonth(2) = 31 + daysInMonth(3) = 30 + daysInMonth(4) = 31 + daysInMonth(5) = 30 + daysInMonth(6) = 31 + daysInMonth(7) = 31 + daysInMonth(8) = 30 + daysInMonth(9) = 31 + daysInMonth(10) = 30 + daysInMonth(11) = 31 + + Call date4today(today_Renamed) + endOfMonth = daysInMonth(date4month(today_Renamed)) + If date4month(today_Renamed) = 2 And date4isLeap(today_Renamed) = 1 Then + endOfMonth = endOfMonth + 1 + End If + frm.ListBox1.Items.Add("There are " & Str(endOfMonth - date4day(today_Renamed)) & " days till the end of the month") + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX76.vb b/examples/source/VB.NET/EX76.vb new file mode 100644 index 0000000..79ac1cc --- /dev/null +++ b/examples/source/VB.NET/EX76.vb @@ -0,0 +1,27 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX76.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim d As String + Dim daysToWeekEnd As Short + + Call date4today(d) + frm.ListBox1.Items.Add("Today is " & date4cdow(d)) + daysToWeekEnd = 7 - date4dow(d) + If daysToWeekEnd = 0 Or daysToWeekEnd = 6 Then + frm.ListBox1.Items.Add("Better enjoy it!") + Else + frm.ListBox1.Items.Add("Only " & Str(daysToWeekEnd) & " days to go till the weekend") + End If + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX77.vb b/examples/source/VB.NET/EX77.vb new file mode 100644 index 0000000..e7f7f34 --- /dev/null +++ b/examples/source/VB.NET/EX77.vb @@ -0,0 +1,42 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX77.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, bDate As Integer + Dim date1, date2 As String + Dim year1, year2 As Short + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + bDate = d4field(db, "BIRTH_DATE") + rc = d4top(db) + date1 = Mid(f4str(bDate), 1) 'make a copy of the field's contents + rc = d4skip(db, 1) + date2 = Mid(f4str(bDate), 1) + year1 = date4year(date1) + year2 = date4year(date2) + If year1 <> year2 Then + frm.ListBox1.Items.Add("The people in the 1st and 2nd records were born in different years " & Str(year1) & ", " & Str(year2)) + Else + frm.ListBox1.Items.Add("The people in the 1st and 2nd records were born in the same year" & Str(year1)) + End If + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX78.vb b/examples/source/VB.NET/EX78.vb new file mode 100644 index 0000000..b230cf4 --- /dev/null +++ b/examples/source/VB.NET/EX78.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX78.VB + + Dim cb As Integer + Dim rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Function display(ByRef p As String, ByRef fm As Form1) As Short + If p = "" Then + display = error4describe(cb, e4parm, 0, "Null display string", "", "") + Exit Function + End If + fm.ListBox1.Items.Add(p) + display = r4success + End Function + + Sub ExCode(ByRef frm As Form1) + Dim p As String + + p = "some string" + cb = code4init() + rc = display(p, frm) + rc = display("", frm) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX79.vb b/examples/source/VB.NET/EX79.vb new file mode 100644 index 0000000..329a2d0 --- /dev/null +++ b/examples/source/VB.NET/EX79.vb @@ -0,0 +1,28 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX79.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "FILE") + Call error4exitTest(cb) + '... other code.... + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX8.vb b/examples/source/VB.NET/EX8.vb new file mode 100644 index 0000000..f9707ce --- /dev/null +++ b/examples/source/VB.NET/EX8.vb @@ -0,0 +1,52 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX8.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex8 example code + + Dim cb, db As Integer + Dim fieldInfo() As FIELD4INFO + Dim rc As Short + + cb = code4init() + ReDim fieldInfo(2) + fieldInfo(0).fName = "NAME_FLD" + fieldInfo(0).ftype = r4str + fieldInfo(0).flength = 20 + fieldInfo(0).fdecimals = 0 + + fieldInfo(1).fName = "AGE_FLD" + fieldInfo(1).ftype = r4num + fieldInfo(1).flength = 3 + fieldInfo(1).fdecimals = 0 + + rc = code4errOpen(cb, 0) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + 'no error message is displayed if NO_FILE does not exist + db = d4open(cb, "NO_FILE") + + If code4errorCode(cb, r4check) = r4noOpen Then + 'the data file does not exist + rc = code4safety(cb, 0) + db = d4createData(cb, fPath & "NO_FILE", fieldInfo) + If db = 0 Then + MsgBox("Could not create NO_FILE", MsgBoxStyle.OKOnly) + End If + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX80.vb b/examples/source/VB.NET/EX80.vb new file mode 100644 index 0000000..9a24547 --- /dev/null +++ b/examples/source/VB.NET/EX80.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX80.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, expr As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + rc = d4go(db, 1) + 'FNAME and LNAME are character field names of data file DATA1.DBF + + expr = expr4parse(db, "F_NAME+' '+L_NAME") + If expr <> 0 Then + frm.ListBox1.Items.Add("F_NAME and L_NAME for record one: " & expr4str(expr)) + End If + Call expr4free(expr) + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX81.vb b/examples/source/VB.NET/EX81.vb new file mode 100644 index 0000000..75bc96f --- /dev/null +++ b/examples/source/VB.NET/EX81.vb @@ -0,0 +1,40 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX81.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, expr As Integer + Dim rc As Short + Dim count As Integer + Dim VoteAge As Double + + VoteAge = 18 + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + expr = expr4parse(db, "AGE") + count = 0 + rc = d4top(db) + Do While rc <> r4eof + If expr4double(expr) >= VoteAge Then + count = count + 1 + End If + rc = d4skip(db, 1) + Loop + frm.ListBox1.Items.Add("Possible voters: " & Str(count)) + Call expr4free(expr) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX82.vb b/examples/source/VB.NET/EX82.vb new file mode 100644 index 0000000..0b79009 --- /dev/null +++ b/examples/source/VB.NET/EX82.vb @@ -0,0 +1,40 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX82.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, fullName As Integer + Dim rc As Short + Dim nameStr, nextName As String + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + + rc = d4top(db) + fullName = expr4parse(db, "TRIM( L_NAME )+', '+F_NAME") + nameStr = expr4str(fullName) + + rc = d4skip(db, 1) + nextName = expr4str(fullName) + 'For illustration purposes only: Avoid using the expression module + 'when the field functions will suffice + frm.ListBox1.Items.Add(nameStr & " is the first person in the data file") + frm.ListBox1.Items.Add(nextName & " is the second person in the data file ") + + Call expr4free(fullName) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX83.vb b/examples/source/VB.NET/EX83.vb new file mode 100644 index 0000000..d08880c --- /dev/null +++ b/examples/source/VB.NET/EX83.vb @@ -0,0 +1,34 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX83.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim info, cb, db, expr As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "DATA1") + info = d4open(cb, fPath & "INFO") + + expr = expr4parse(db, "F_NAME+' '+DTOS( INFO->BIRTH_DATE)") + rc = d4top(db) + rc = d4top(info) + frm.ListBox1.Items.Add("First name from DATA1 and birth date from INFO: " & expr4str(expr)) + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX84.vb b/examples/source/VB.NET/EX84.vb new file mode 100644 index 0000000..979faef --- /dev/null +++ b/examples/source/VB.NET/EX84.vb @@ -0,0 +1,64 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX84.VB + + Dim db, cb, expr As Integer + Dim rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = d4top(db) + + expr = expr4parse(db, "NAME") + Call showExpr(frm) + Call expr4free(expr) + + expr = expr4parse(db, "AGE") + Call showExpr(frm) + Call expr4free(expr) + + expr = expr4parse(db, "BIRTH_DATE") + Call showExpr(frm) + Call expr4free(expr) + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub + + Sub showExpr(ByRef fm As Form1) + Dim typeExpr As String + typeExpr = expr4type(expr) + + Select Case typeExpr + Case r4date + fm.ListBox1.Items.Add("type is r4date") + Case r4dateDoub + fm.ListBox1.Items.Add("type is r4dateDoub") + Case r4log + fm.ListBox1.Items.Add("type is r4log") + Case r4num + fm.ListBox1.Items.Add("type is r4num") + Case r4numDoub + fm.ListBox1.Items.Add("type is r4numDoub") + Case r4str + fm.ListBox1.Items.Add("type is r4str") + Case r4memo + fm.ListBox1.Items.Add("type is r4memo") + End Select + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX85.vb b/examples/source/VB.NET/EX85.vb new file mode 100644 index 0000000..4b4a6a0 --- /dev/null +++ b/examples/source/VB.NET/EX85.vb @@ -0,0 +1,58 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX85.VB + + 'NOTE: 'today' is a reserved word under VB .NET + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, birthDate As Integer + Dim rc As Short + Dim today_Renamed, result As String + Dim ageInDays As Integer + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + birthDate = d4field(db, "BIRTH_DATE") + error4exitTest((cb)) + + rc = d4top(db) + If rc <> r4success Then + MsgBox("No records to display.") + Else + Call date4today(today_Renamed) + ageInDays = date4long(today_Renamed) - date4long(f4str(birthDate)) + frm.ListBox1.Items.Add("Age in days: " & Str(ageInDays)) + + 'display all current birth dates in formatted form + rc = d4top(db) + Do While rc = r4success + Call date4format(f4str(birthDate), result, "MMM DD, CCYY") + frm.ListBox1.Items.Add(result) + rc = d4skip(db, 1) + Loop + + 'assign today's date to all birth dates in the data file + rc = d4top(db) + Do While rc = r4success + Call f4assign(birthDate, today_Renamed) + rc = d4skip(db, 1) + Loop + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX86.vb b/examples/source/VB.NET/EX86.vb new file mode 100644 index 0000000..51c5af8 --- /dev/null +++ b/examples/source/VB.NET/EX86.vb @@ -0,0 +1,41 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX86.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, info As Integer + Dim infoName, dataLname As Integer + Dim rc As Short + + cb = code4init() + rc = code4accessMode(cb, OPEN4DENY_RW) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + info = d4open(cb, fPath & "INFO") + db = d4open(cb, fPath & "DATA1") + Call error4exitTest(cb) + + infoName = d4field(info, "NAME") + dataLname = d4field(db, "L_NAME") + rc = d4top(info) + rc = d4top(db) + Do While d4eof(info) = 0 And d4eof(db) = 0 + Call f4assignField(infoName, dataLname) 'copy "L_NAME" into "NAME" + rc = d4skip(info, 1) + rc = d4skip(db, 1) + Loop + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX87.vb b/examples/source/VB.NET/EX87.vb new file mode 100644 index 0000000..0766498 --- /dev/null +++ b/examples/source/VB.NET/EX87.vb @@ -0,0 +1,40 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX87.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub displayFieldStats(ByRef f As Integer, ByRef fm As Form1 ) + Dim dFile As Integer + + dFile = f4data(f) + fm.ListBox1.Items.Add("-----------------------------------------------------") + fm.ListBox1.Items.Add("DataFile: " & d4alias(dFile) & " Field : " & f4name(f)) + fm.ListBox1.Items.Add("Length: " & Str(f4len(f)) & " Type : " & Chr(f4type(f))) + fm.ListBox1.Items.Add("Decimals: " & Str(f4decimals(f))) + fm.ListBox1.Items.Add("-----------------------------------------------------") + End Sub + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + field = d4field(db, "NAME") + + Call displayFieldStats(field, frm) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX88.vb b/examples/source/VB.NET/EX88.vb new file mode 100644 index 0000000..f70275d --- /dev/null +++ b/examples/source/VB.NET/EX88.vb @@ -0,0 +1,39 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX88.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Function createBufCopy(ByRef f As Integer) As String + Dim buf As String + + buf = Space(f4len(f) + 1) + buf = Mid(f4str(f), 1) + createBufCopy = buf + End Function + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim buffer As String + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + field = d4field(db, "NAME") + rc = d4top(db) + buffer = createBufCopy(field) + frm.ListBox1.Items.Add("the copy of the buffer is " & buffer) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX89.vb b/examples/source/VB.NET/EX89.vb new file mode 100644 index 0000000..1e9858f --- /dev/null +++ b/examples/source/VB.NET/EX89.vb @@ -0,0 +1,42 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX89.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, comments As Integer + Dim rc As Short + Dim count As Integer + + cb = code4init() + db = d4open(cb, fPath & "DATA1") + comments = d4field(db, "COMMENT") + Call error4exitTest(cb) + + count = 0 + rc = d4top(db) + rc = f4memoAssign(comments, "There is one memo in this data file") + rc = d4flush(db) + Do While d4eof(db) = 0 + If f4memoLen(comments) > 0 Then + count = count + 1 + End If + rc = d4skip(db, 1) + rc = f4memoAssign(comments, "There is a second memo in this data file") + rc = d4flush(db) + + Loop + frm.ListBox1.Items.Add("There were " & Str(count) & " memo entries out of ") + frm.ListBox1.Items.Add(Str(d4recCount(db)) & " records") + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX9.vb b/examples/source/VB.NET/EX9.vb new file mode 100644 index 0000000..44feadb --- /dev/null +++ b/examples/source/VB.NET/EX9.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX9.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to data files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'ex9 example code + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + db = d4open(cb, fPath & "INFO") + + rc = code4readLock(cb, 1) + rc = code4lockAttempts(cb, 3) + + If d4top(db) = r4locked Then + MsgBox("Top rcord locked by another user") + MsgBox("Lock attempted" & Str(code4lockAttempts(cb, r4check)), MsgBoxStyle.OKOnly) + Else + MsgBox("Now the record is locked") + End If + + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX90.vb b/examples/source/VB.NET/EX90.vb new file mode 100644 index 0000000..8f149eb --- /dev/null +++ b/examples/source/VB.NET/EX90.vb @@ -0,0 +1,40 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX90.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub displayTheRecord(ByRef d As Integer, ByRef fm As Form1) + Dim numFields, curField As Short + Dim genericField As Integer + + numFields = d4numFields(d) + For curField = 1 To numFields + genericField = d4fieldJ(d, curField) + fm.ListBox1.Items.Add(f4memoStr(genericField)) + Next + fm.ListBox1.Items.Add("all records have been displayed") + End Sub + + Sub ExCode(ByRef frm As Form1) + Dim cb, db As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + rc = d4top(db) + displayTheRecord(db, frm) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX91.vb b/examples/source/VB.NET/EX91.vb new file mode 100644 index 0000000..4d396f2 --- /dev/null +++ b/examples/source/VB.NET/EX91.vb @@ -0,0 +1,28 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX91.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, field As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + field = d4fieldJ(db, 1) + frm.ListBox1.Items.Add("The first field is call " & f4name(field)) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX92.vb b/examples/source/VB.NET/EX92.vb new file mode 100644 index 0000000..2566d49 --- /dev/null +++ b/examples/source/VB.NET/EX92.vb @@ -0,0 +1,31 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX92.VB + + Public lf As String 'Line Feed + Public fpath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim field1, cb, db, field2 As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fpath = VB6.GetPath & "\" + + db = d4open(cb, fpath & "INFO") + field1 = d4fieldJ(db, 1) + field2 = d4fieldJ(db, 2) + rc = d4top(db) + frm.ListBox1.Items.Add("Field 1: " & f4str(field1)) + frm.ListBox1.Items.Add("Field 2: " & f4str(field2)) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX93.vb b/examples/source/VB.NET/EX93.vb new file mode 100644 index 0000000..244a7b9 --- /dev/null +++ b/examples/source/VB.NET/EX93.vb @@ -0,0 +1,50 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX93.VB + + Dim rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Function addLotsOfRecords(ByRef d As Integer) As Short + Dim index As Integer + Dim i As Short + + index = d4index(d, "INFO2") 'get the secondary index file + If index <> 0 Then + rc = i4close(index) + End If + + rc = d4top(d) + For i = 1 To 20 + rc = d4appendStart(d, 0) + rc = d4append(d) 'make 20 copies of the top record + Next + + 'open the index file and update it + index = i4open(d, "INFO2") + addLotsOfRecords = i4reindex(index) + End Function + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, index As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + index = i4open(db, "INFO2") + + rc = addLotsOfRecords(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX94.vb b/examples/source/VB.NET/EX94.vb new file mode 100644 index 0000000..4994e9b --- /dev/null +++ b/examples/source/VB.NET/EX94.vb @@ -0,0 +1,53 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX94.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, index As Integer + Dim fieldInfo() As FIELD4INFO + Dim tagInfo() As TAG4INFO + Dim rc As Short + + ReDim fieldInfo(2) + fieldInfo(0).fName = "FIELD_NAME" + fieldInfo(0).ftype = r4str + fieldInfo(0).flength = 10 + fieldInfo(0).fdecimals = 0 + + fieldInfo(1).fName = "VALUE" + fieldInfo(1).ftype = r4num + fieldInfo(1).flength = 7 + fieldInfo(1).fdecimals = 2 + + ReDim tagInfo(2) + tagInfo(0).name = "T_NAME" + tagInfo(0).expression = "FIELD_NAME" + tagInfo(0).filter_Renamed = "FIELD_NAME > 'A'" + + tagInfo(1).name = "NAME_TWO" + tagInfo(1).expression = "VALUE" + tagInfo(1).unique = e4unique + tagInfo(1).descending = r4descending + + cb = code4init() + rc = code4safety(cb, 0) + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4createData(cb, fPath & "DB_NAME", fieldInfo) + index = i4create(db, fPath & "NAME", tagInfo) + + rc = d4close(db) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX95.vb b/examples/source/VB.NET/EX95.vb new file mode 100644 index 0000000..8f338d8 --- /dev/null +++ b/examples/source/VB.NET/EX95.vb @@ -0,0 +1,35 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX95.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, index As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "STUDENT") + index = i4open(db, "STUDENT2") 'Open a seconday index file + + rc = code4lockAttempts(cb, WAIT4EVER) 'Wait until the lock succeeds + rc = d4lockAll(db) + If i4reindex(index) = r4success Then + frm.ListBox1.Items.Add("Reindexed successfully") + End If + + rc = code4close(cb) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX96.vb b/examples/source/VB.NET/EX96.vb new file mode 100644 index 0000000..dafccfb --- /dev/null +++ b/examples/source/VB.NET/EX96.vb @@ -0,0 +1,76 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX96.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'CODE4 pointer + Dim cb As Integer + 'DATA4 pointers + Dim master, enroll, student As Integer + 'TAG4 pointers + Dim enrollTag, studentTag As Integer + 'RELATE4 pointers + Dim relation1, MasterRelation, relation2 As Integer + 'FIELD4 pointers + Dim classTitle, classCode, enrollStudentId As Integer + Dim studentName As Integer + + Dim rc, count As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + enroll = d4open(cb, fPath & "ENROLL") + master = d4open(cb, fPath & "CLASSES") + student = d4open(cb, fPath & "STUDENT") + + enrollTag = d4tag(enroll, "ENR_CODE") + studentTag = d4tag(student, "STU_ID") + + MasterRelation = relate4init(master) + relation1 = relate4createSlave(MasterRelation, enroll, "CODE", enrollTag) + relation2 = relate4createSlave(relation1, student, "STU_ID_TAG", studentTag) + + rc = relate4type(relation1, relate4scan) + rc = relate4sortSet(MasterRelation, "STUDENT->L_NAME,8,0+ENROLL->CODE") + + classCode = d4field(master, "CODE") + classTitle = d4field(master, "TITLE") + enrollStudentId = d4field(enroll, "STU_ID_TAG") + studentName = d4field(student, "L_NAME") + + error4exitTest((cb)) + + rc = relate4top(MasterRelation) + Do While rc = r4success 'onle one f4str per statement + frm.ListBox1.Items.Add(f4str(studentName)) + frm.ListBox1.Items.Add(f4str(enrollStudentId)) + frm.ListBox1.Items.Add(f4str(classCode)) + frm.ListBox1.Items.Add(f4str(classTitle)) + frm.ListBox1.Items.Add("") + rc = relate4skip(MasterRelation, 1) + count = count + 1 + If count Mod 4 = 0 Then + MsgBox("Click for more...") + frm.ListBox1.Items.Clear() + End If + Loop + + frm.ListBox1.Items.Add("the number of records is ") + frm.ListBox1.Items.Add(Str(d4recCount(master))) + + rc = relate4free(MasterRelation, 1) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX97.vb b/examples/source/VB.NET/EX97.vb new file mode 100644 index 0000000..6a8e91b --- /dev/null +++ b/examples/source/VB.NET/EX97.vb @@ -0,0 +1,77 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX97.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'CODE4 pointer + Dim cb As Integer + 'DATA4 pointers + Dim office, employee, building As Integer + 'TAG4 pointers + Dim officeNo, buildNo As Integer + 'RELATE4 pointers + Dim toOffice, master, toBuilding As Integer + + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + employee = d4open(cb, fPath & "EMPLOYEE") + office = d4open(cb, fPath & "OFFICE") + building = d4open(cb, fPath & "BUILDING") + + 'set up the tags + officeNo = d4tag(office, "OFF_NUM") + buildNo = d4tag(building, "BUILD_NO") + + 'Create the relations + master = relate4init(employee) + toOffice = relate4createSlave(master, office, "EMPLOYEE->OFFICE_NO", officeNo) + toBuilding = relate4createSlave(toOffice, building, "OFFICE->BUILD_NO", buildNo) + 'Go to employee, at record 2 + rc = d4go(employee, 2) + + 'Lock the data files and their index files. + rc = relate4lockAdd(master) + rc = code4lock(cb) + + 'This call causes the corresponding records in data files "OFFICE" and + '"BUILDING" to be looked up. + rc = relate4doAll(master) + frm.ListBox1.Items.Add(Str(d4recNo(employee))) + frm.ListBox1.Items.Add(" employee rec no") + frm.ListBox1.Items.Add(Str(d4recNo(office))) + frm.ListBox1.Items.Add(" office rec no") + frm.ListBox1.Items.Add(Str(d4recNo(building))) + frm.ListBox1.Items.Add(" building rec no") + + 'Go to office, at record 3 + rc = d4go(office, 3) + + 'This call causes the building record to be looked up from the office + rc = relate4doOne(toBuilding) + frm.ListBox1.Items.Add(Str(d4recNo(employee))) + frm.ListBox1.Items.Add(" employee rec no") + frm.ListBox1.Items.Add(Str(d4recNo(office))) + frm.ListBox1.Items.Add(" office rec no") + frm.ListBox1.Items.Add(Str(d4recNo(building))) + frm.ListBox1.Items.Add(" building rec no") + + ' .. and so on + + rc = relate4free(master, 1) + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX98.vb b/examples/source/VB.NET/EX98.vb new file mode 100644 index 0000000..3c9a46d --- /dev/null +++ b/examples/source/VB.NET/EX98.vb @@ -0,0 +1,68 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX98.VB + + Dim rc As Short + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + 'CODE4 pointer + Dim cb As Integer + 'DATA4 pointers + Dim enroll, master As Integer + 'TAG4 pointers + Dim enrollTag, codeTag As Integer + 'RELATE4 pointers + Dim MasterRelation, relation1 As Integer + 'FIELD4 pointers + Dim classTitle, classCode, enrollStudentId As Integer + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + enroll = d4open(cb, fPath & "ENROLL") + master = d4open(cb, fPath & "CLASSES") + + enrollTag = d4tag(enroll, "ENR_CODE") + codeTag = d4tag(master, "CODE_TAG") + + MasterRelation = relate4init(master) + relation1 = relate4createSlave(MasterRelation, enroll, "CODE", enrollTag) + + rc = relate4type(relation1, relate4scan) + + classCode = d4field(master, "CODE") + classTitle = d4field(master, "TITLE") + enrollStudentId = d4field(enroll, "STU_ID_TAG") + + Call error4exitTest(cb) + + rc = seekMaster(master, relation1, codeTag, "MATH521") + frm.ListBox1.Items.Add(f4str(enrollStudentId)) + frm.ListBox1.Items.Add(f4str(classCode)) + frm.ListBox1.Items.Add(f4str(classTitle)) + + rc = relate4free(MasterRelation, 1) + rc = code4initUndo(cb) + End Sub + + Function seekMaster(ByRef master As Integer, ByRef r As Integer, ByRef masterTag As Integer, ByRef seekKey As String) As Short + Call d4tagSelect(master, masterTag) + rc = d4seek(master, seekKey) 'seek for requested value + If rc = r4success Then + rc = relate4doOne(r) 'position the slave data file to the + 'appropriate record, according to its master + End If + seekMaster = rc + End Function +End Module \ No newline at end of file diff --git a/examples/source/VB.NET/EX99.vb b/examples/source/VB.NET/EX99.vb new file mode 100644 index 0000000..2c5eefb --- /dev/null +++ b/examples/source/VB.NET/EX99.vb @@ -0,0 +1,41 @@ +Option Strict Off +Option Explicit On +Module EXAMPLE + 'EX99.VB + + Public lf As String 'Line Feed + Public fPath As String 'Full path name to db files + + Public Const MB_OK As Short = 0 + Public Const MB_YESNO As Short = 4 + Public Const MB_ICONQUESTION As Short = 32 + Public Const IDYES As Short = 6 + + Sub ExCode(ByRef frm As Form1) + Dim db, cb, TopMaster As Integer + Dim rc As Short + + cb = code4init() + + 'Specify full path if stand-alone + If u4switch() And &H80S Then fPath = VB6.GetPath & "\" + + db = d4open(cb, fPath & "INFO") + + TopMaster = relate4init(db) + + ' ... other code ... + + 'This relation tree is no longer needed. Create a new one + rc = relate4free(TopMaster, 0) + + TopMaster = relate4init(db) + + ' ... other code ... + ' Automatically close all files in the relation + rc = relate4free(TopMaster, 1) + + rc = code4close(cb) 'close any remaining files + rc = code4initUndo(cb) + End Sub +End Module \ No newline at end of file diff --git a/interfaces/CSharp/Codebase.cs b/interfaces/CSharp/Codebase.cs new file mode 100644 index 0000000..8a51768 --- /dev/null +++ b/interfaces/CSharp/Codebase.cs @@ -0,0 +1,3183 @@ +/* codebase.cs (c)Copyright Sequiter Software Inc., 1988-2002. All rights reserved. */ + +// AS Mar 23/06 - resolve WinCE vs. regular code discrepencies by handling marshalling via defines +/* +#define MARSHAL4I4 [MarshalAs(UnmanagedType.I4)] +#define MARSHAL4I2 [MarshalAs(UnmanagedType.I2)] +#define MARSHAL4U1 [MarshalAs(UnmanagedType.U1)] +#define MARSHAL4U2 [MarshalAs(UnmanagedType.U2)] +#define MARSHAL4U4 [MarshalAs(UnmanagedType.U4)] +#define MARSHAL4R8 [MarshalAs(UnmanagedType.R8)] +#define MARSHAL4LPSTR [MarshalAs(UnmanagedType.LPStr)] +#define MARSHAL4LPWSTR [MarshalAs(UnmanagedType.LPWStr)] +#define MARSHAL4LPARRAY [MarshalAs(UnmanagedType.LPArray)] +#define MARSHAL4LPSTRUCT [MarshalAs(UnmanagedType.LPStruct)] +*/ + +namespace CodeBase +{ + #pragma warning disable 1591 + + using System; + using System.Runtime.InteropServices; + using System.Text ; /* LY 2002/09/24 : for StringBuilder */ + + public class Error4 + { + protected IntPtr code4 ; // This is the most used member and is need in error handling. + + public const int cp0 = 0 ; /* this is the same as cp437 (i.e. US oem sequence) */ + public const int cp437 = 1 ; /* this is the same as cp0 (i.e. US oem sequence) */ + public const int cp1252 = 3 ; + + public const short collate4machine = 1 ; + public const short collate4general = 1001 ; + public const short collate4special = 1002 ; + + public const int r4success = 0 ; + public const int r4found = 1 ; /* Primary Key Match */ + public const int r4after = 2 ; + public const int r4eof = 3 ; + public const int r4bof = 4 ; + public const int r4entry = 5 ; /* No index file entry or no record (go) */ + public const int r4descending = 10 ; + public const int r4unique = 20 ; /* Key is not unique, do not write/append */ + public const int r4uniqueContinue = 25 ; /* Key is not unique, write/append anyway */ + public const int r4locked = 50 ; + public const int r4noCreate = 60 ; /* Could not create file */ + public const int r4noOpen = 70 ; /* Could not open file */ + public const int r4noTag = 80 ; /* DataIndex::seek, with no default tag */ + public const int r4terminate = 90 ; /* no relation match with terminate set */ + public const int r4inactive = 110 ; /* transactional state */ + public const int r4active = 120 ; /* transactional state */ + public const int r4rollback = 130 ; /* transactional state */ + public const int r4authorize = 140 ; /* lacks authorization rights to perform action */ + public const int r4connected = 150 ; + public const int r4logOn = 160 ; + public const int r4logOpen = 170 ; + public const int r4logOff = 180 ; + public const ushort r4null = 190 ; + public const int r4autoIncrement = 195 ; + public const int r4autoTimestamp = 200 ; + public const int r4done = 210 ; + + public const int e4lock = -50 ; + public const int e4fieldName = -210 ; + public const int e4unique = -340 ; + public const int e4info = -910 ; + public const int e4parm = -930 ; + public const int e4struct = -970 ; + + public const int INVALID4HANDLE = -1 ; + + public const int lock4read = 0 ; + public const int lock4write = 1 ; + public const int lock4any = 2 ; + + public const int LOG4ALWAYS = 2 ; + public const int LOG4ON = 1 ; + public const int LOG4TRANS = 0 ; + + public const int OPEN4DENY_NONE = 0 ; + public const int OPEN4DENY_WRITE = 2 ; + public const int OPEN4DENY_RW = 1 ; + + public const int OPT4EXCLUSIVE = -1 ; + public const int OPT4OFF = 0 ; + public const int OPT4ALL = 1 ; + + public const int relate4blank = 105 ; + public const int relate4skipRec = 106 ; + public const int relate4terminate = 107 ; + public const int relate4exact = 108 ; + public const int relate4scan = 109 ; + public const int relate4approx = 110 ; + + public const char r4bin = 'B' ; + public const char r4double = 'B' ; + public const char r4str = 'C' ; + public const char r4dateDoub = 'd' ; + public const char r4date = 'D' ; + public const char r4float = 'F' ; + public const char r4gen = 'G' ; + public const char r4int = 'I' ; + public const char r4log = 'L' ; + public const char r4memo = 'M' ; + public const char r4numDoub = 'n' ; + public const char r4num = 'N' ; + public const char r4dateTime = 'T' ; + public const char r4dateTimeMilli = '7' ; + public const char r5wstr = 'W' ; + public const char r4unicode = r5wstr ; + public const char r4memoBin = 'X' ; + public const char r4currency = 'Y' ; + public const char r4charBin = 'Z' ; + + public const int sort4machine = 0 ; + public const int sort4general = 1 ; + + public const short LOCK4OFF = 0 ; + public const short LOCK4ALL = 1 ; + public const short LOCK4DATA = 2 ; + + public const short WAIT4EVER = -1 ; + + /* using 2nd error numbers under !S4OFF_STRING */ + public const int E60523 = 60119 ; + public const int E60525 = 60121 ; + public const int E60601 = 60025 ; + public const int E60603 = 60027 ; + public const int E60281 = 60023 ; + public const int E60282 = 60024 ; + public const int E60201 = 60021 ; + public const int E60982 = 60225 ; + public const int E60983 = 60226 ; + public const int E60984 = 60227 ; + public const int E60991 = 60221 ; + public const int E61203 = 60107 ; + public const int E61204 = 60108 ; + + /* functions used by classes in addition to Code4 */ + [DllImport("c4dll.dll")] + protected static extern int c4getLockEnforce(IntPtr code4 ) ; + [DllImport("c4dll.dll")] + protected static extern short code4accessMode(IntPtr code4, [MarshalAs(UnmanagedType.I4)] int accessMode); + + /* functions used by classes in addition to Data4 */ + [DllImport("c4dll.dll")] + protected static extern short d4changed( IntPtr data4, [MarshalAs(UnmanagedType.I2)] short flag ) ; + [DllImport("c4dll.dll")] + protected static extern int d4recNoLow( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + protected static extern short d4numFields( IntPtr data4 ) ; + + /* functions used by classes Field4, Field4info, Field4memo */ + [DllImport("c4dll.dll")] + protected static extern IntPtr d4fieldJ(IntPtr data4, [MarshalAs(UnmanagedType.I2)] short number); + [DllImport("c4dll.dll")] + protected static extern IntPtr d4field(IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string name); + [DllImport("c4dll.dll")] + protected static extern int f4decimals( IntPtr field4 ) ; + [DllImport("c4dll.dll")] + protected static extern uint f4len( IntPtr field4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/24 : replaced f4name() (see Field4::name())*/ + protected static extern void f4nameW( IntPtr field4, System.Text.StringBuilder buff ) ; + [DllImport("c4dll.dll")] + protected static extern int f4null( IntPtr field4 ) ; + [DllImport("c4dll.dll")] + protected static extern char f4type( IntPtr field4 ) ; + + [DllImport("c4dll.dll")] + protected static extern void u4freeDefault( int ptr ) ; + + [DllImport("c4dll.dll")] + protected static extern int error4set( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errorCode ) ; + [DllImport("c4dll.dll")] + protected static extern int error4number2( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errorCode ) ; + [DllImport("c4dll.dll")] + protected static extern short code4errorCode( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short errorCode ) ; + [DllImport("c4dll.dll")] + private static extern short error4VB( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short errorCode ,[MarshalAs(UnmanagedType.I4)] int extraInfo ) ; + [DllImport("c4dll.dll")] + private static extern int error4describeDefault( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int er, [MarshalAs(UnmanagedType.I4)] int er2, + [MarshalAs(UnmanagedType.LPStr)] string p1, [MarshalAs(UnmanagedType.LPStr)] string p2, [MarshalAs(UnmanagedType.LPStr)] string p3) ; + [DllImport("c4dll.dll")] + private static extern int error4file( IntPtr code4, [MarshalAs(UnmanagedType.LPStr)] string fileName ,[MarshalAs(UnmanagedType.I4)] int overwrite ) ; + [DllImport("c4dll.dll")] + private static extern void error4exitTest( IntPtr code4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/24 : changed from error4text() */ + private static extern void error4textW( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errCode, StringBuilder buff ) ; + + public int throwError( short errorCode, int extraInfo ) + { + return error4VB( code4, errorCode, extraInfo) ; + } + public int error( int er, int er2, string p1, string p2, string p3 ) { return error4describeDefault( code4, er, er2, p1, p2, p3 ) ; } + public int errorSet( int c ) { return error4set( code4, c ) ; } + + public int errorFile( string fileName, int overwrite ) { return error4file( code4, fileName, overwrite ); } + public int errorNumber2(int errorCode) { return error4number2(code4, errorCode); } + public void exitTest() { error4exitTest( code4 ) ; } + public string errorText( int c ) + { + StringBuilder textBuff = new StringBuilder( 256 ) ; + error4textW( code4, c, textBuff ) ; + return textBuff.ToString() ; + } + } + + public class Expr4 + { + private IntPtr expr; //Contains a pointer to the EXPR4 structure in the CodeBase DLL + + public Expr4() { expr = IntPtr.Zero; } + public Expr4( IntPtr ex ) { expr = ex ; } + + [DllImport("c4dll.dll")] + private static extern IntPtr expr4parseLow( IntPtr data4, + [MarshalAs(UnmanagedType.LPStr)] string expression, + [MarshalAs(UnmanagedType.I4)] int tagFile + ) ; + [DllImport("c4dll.dll")] + private static extern double expr4double( IntPtr expr ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr expr4dataCB(IntPtr expr); + [DllImport("c4dll.dll")] + private static extern void expr4freeCB(IntPtr expr); + [DllImport("c4dll.dll")] + private static extern int expr4lenCB(IntPtr expr); + [DllImport("c4dll.dll")] + private static extern short expr4nullLow(IntPtr expr, [MarshalAs(UnmanagedType.I2)] short forAdd); + [DllImport("c4dll.dll")] /* LY 2002/09/24 : replaced expr4source() */ + private static extern void expr4sourceW(IntPtr expr, StringBuilder buff); + [DllImport("c4dll.dll")] /* LY 2002/09/24 : replaced expr4str() */ + private static extern void expr4strW(IntPtr expr, StringBuilder buff); + [DllImport("c4dll.dll")] + private static extern short expr4typeCB(IntPtr expr); + [DllImport("c4dll.dll")] + private static extern int expr4true(IntPtr expr); + + public IntPtr EXPR4 + { + get + { + return( expr ); + } + } + + public Expr4( Data4 d, string expression ) + { + expr = expr4parseLow( d.dat(), expression, 0 ) ; + } + public static explicit operator double( Expr4 a ) { return expr4double( a.expr ) ; } + + public Data4 data() + { + Data4 temp = new Data4( expr4dataCB( expr ) ) ; + return temp ; + } + public void free() { expr4freeCB(expr); expr = IntPtr.Zero; } + public int len() { return expr4lenCB( expr ) ; } + public int parse( Data4 db, string expression ) + { + int rc ; + if ( db.dat() == IntPtr.Zero ) + { + Error4 err = new Error4() ; + rc = err.throwError( Error4.e4struct, Error4.E60603 ) ; + } + else if (expr != IntPtr.Zero) + { + Error4 err = new Error4() ; + rc = err.throwError( Error4.e4info, Error4.E60601 ) ; + } + else + { + expr = expr4parseLow( db.dat(), expression, 0 ) ; + rc = db.getErrorCode() ; + } + return rc ; + } + public int isValid() { return (expr != IntPtr.Zero ? 1 : 0); } + public short isNull() { return expr4nullLow( expr, 1 ) ; } + public string source() + { + StringBuilder srcBuff = new StringBuilder( 512 ) ; + expr4sourceW( expr, srcBuff ) ; + return srcBuff.ToString() ; + } + public string str() + { + StringBuilder strBuff = new StringBuilder( this.len() + 1 ) ; + strBuff.Append( ' ', this.len() ) ; + expr4strW( expr, strBuff ) ; + // LY Mar 3/05 : Do not pass Expr4::len() to ::ToString() (OutOfRange exception will occur if expression uses trim function and returned string is shorter than Expr4::len()) + return strBuff.ToString() ; + } + + public double toDouble() { return expr4double( expr ) ; } + public char type() { return (char) expr4typeCB( expr ) ; } + public int isTrue() { return expr4true( expr ) ; } + } + + public class Code4 : Error4 + { + private short init_p ; + + //properties of the Code4 structure + [DllImport("c4dll.dll")] + private static extern int c4getCreateTemp(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrCreate(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrExpr(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrFieldName(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrGo(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrOpen(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrRelate(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrSkip(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getErrTagName(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern int c4getFileFlush(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern void c4setCreateTemp( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int createTemp ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrCreate( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errCreate ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrExpr( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errExpr ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrFieldName( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errFieldName ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrGo( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errGo ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrOpen( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errOpen ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrRelate( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errRelate ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrSkip( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errSkip ) ; + [DllImport("c4dll.dll")] + private static extern void c4setErrTagName( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int errTagName ) ; + [DllImport("c4dll.dll")] + private static extern void c4setFileFlush( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int fileFlush ) ; + [DllImport("c4dll.dll")] + private static extern void c4setLockEnforce( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int lockEnforce ) ; + [DllImport("c4dll.dll")] + private static extern short code4autoOpen( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int openMode ) ; + [DllImport("c4dll.dll")] + private static extern short code4codePage( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short codepage ) ; + [DllImport("c4dll.dll")] + private static extern short code4collate( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short collation ) ; + [DllImport("c4dll.dll")] + private static extern short code4collateUnicode( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short collation ) ; + [DllImport("c4dll.dll")] + private static extern short code4collatingSequence( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short collation ) ; + [DllImport("c4dll.dll")] + private static extern short code4compatibility( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short version ) ; + [DllImport("c4dll.dll")] + private static extern short code4errDefaultUnique( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short errDefaultUnique ) ; + [DllImport("c4dll.dll")] + private static extern short code4errOff( IntPtr code4, short mode ) ; + [DllImport("c4dll.dll")] + private static extern int code4hWnd( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int hWnd ) ; + [DllImport("c4dll.dll")] + private static extern short code4indexBlockSize(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern short code4indexBlockSizeSet( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short blockSize ) ; + [DllImport("c4dll.dll")] + private static extern short code4lockAttempts( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short lockAttempts ) ; + [DllImport("c4dll.dll")] + private static extern short code4lockAttemptsSingle( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short lockAttemptsSingle ) ; + [DllImport("c4dll.dll")] + private static extern int code4lockDelay( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int lockDelay ) ; + [DllImport("c4dll.dll")] + private static extern short code4log( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short log ) ; + [DllImport("c4dll.dll")] + private static extern short code4memExpandBlock( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memExpandBlock ) ; + [DllImport("c4dll.dll")] + private static extern short code4memExpandData( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memExpandData ) ; + [DllImport("c4dll.dll")] + private static extern short code4memExpandIndex( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memExpandIndex ) ; + [DllImport("c4dll.dll")] + private static extern short code4memExpandLock( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memExpandLock ) ; + [DllImport("c4dll.dll")] + private static extern short code4memExpandTag( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memExpandTag ) ; + [DllImport("c4dll.dll")] + private static extern int code4memSizeBlock( IntPtr code4, [MarshalAs(UnmanagedType.U4)] int memSizeBlock ) ; + [DllImport("c4dll.dll")] + private static extern int code4memSizeBuffer( IntPtr code4, [MarshalAs(UnmanagedType.U4)] int memSizeBuffer ) ; + [DllImport("c4dll.dll")] + private static extern short code4memSizeMemo( IntPtr code4, [MarshalAs(UnmanagedType.U2)] short memSizeMemo ) ; + [DllImport("c4dll.dll")] + private static extern int code4memSizeMemoExpr( IntPtr code4, [MarshalAs(UnmanagedType.U4)] int memSizeMemoExpr ) ; + [DllImport("c4dll.dll")] + private static extern int code4memSizeSortBuffer( IntPtr code4, [MarshalAs(UnmanagedType.U4)] int memSizeSortBuffer ) ; + [DllImport("c4dll.dll")] + private static extern int code4memSizeSortPool( IntPtr code4, [MarshalAs(UnmanagedType.U4)] int memSizeSortPool ) ; + [DllImport("c4dll.dll")] + private static extern short code4memStartBlock( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memStartBlock ) ; + [DllImport("c4dll.dll")] + private static extern int code4memStartData( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int memStartBlock ) ; + [DllImport("c4dll.dll")] + private static extern short code4memStartIndex( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memStartIndex ) ; + [DllImport("c4dll.dll")] + private static extern short code4memStartLock( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memStartLock ) ; + [DllImport("c4dll.dll")] + private static extern int code4memStartMax( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int memStartMax ) ; + [DllImport("c4dll.dll")] + private static extern short code4memStartTag( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short memStartTag ) ; + [DllImport("c4dll.dll")] + private static extern short code4optimize( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short optimize ) ; + [DllImport("c4dll.dll")] + private static extern short code4optimizeWrite( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short optimizeWrite ) ; + [DllImport("c4dll.dll")] + private static extern short code4readLock( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short readLock ) ; + [DllImport("c4dll.dll")] + private static extern short code4readOnly( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short readOnly ) ; + [DllImport("c4dll.dll")] + private static extern short code4safety( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short safety ) ; + [DllImport("c4dll.dll")] + private static extern short code4singleOpen( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short singleOpen ) ; + + public IntPtr cod() { return code4 ; } + + public short accessMode + { + get + { + return code4accessMode( code4, -5 ) ; + } + set + { + code4accessMode( code4, value ) ; + } + } + public short autoOpen + { + get + { + return code4autoOpen( code4, -5 ) ; + } + set + { + code4autoOpen( code4, value ) ; + } + } + public short codePage + { + get + { + return code4codePage( code4, -5 ) ; + } + set + { + code4codePage( code4, value ) ; + } + } + public short collate + { + get + { + return code4collate( code4, -1 ) ; + } + set + { + code4collate( code4, value ) ; + } + } + public short collateUnicode + { + get + { + return code4collateUnicode( code4, -1 ) ; + } + set + { + code4collateUnicode( code4, value ) ; + } + } + public short collatingSequence + { + get + { + return code4collatingSequence( code4, -5 ) ; + } + set + { + code4collatingSequence( code4, value ) ; + } + } + public short compatibility + { + get + { + return code4compatibility( code4, -5 ) ; + } + set + { + code4compatibility( code4, value ) ; + } + } + public int createTemp + { + get + { + return c4getCreateTemp( code4 ) ; + } + set + { + c4setCreateTemp( code4, value ) ; + } + } + + public int errCreate + { + get + { + return c4getErrCreate( code4 ) ; + } + set + { + c4setErrCreate( code4, value ) ; + } + } + + public short errDefaultUnique + { + get + { + return code4errDefaultUnique( code4, -5 ) ; + } + set + { + code4errDefaultUnique( code4, value ) ; + } + } + + public int errExpr + { + get + { + return c4getErrExpr( code4 ) ; + } + set + { + c4setErrExpr( code4, value ) ; + } + } + + public int errFieldName + { + get + { + return c4getErrFieldName( code4 ) ; + } + set + { + c4setErrFieldName( code4, value ) ; + } + } + + public int errGo + { + get + { + return c4getErrGo( code4 ) ; + } + set + { + c4setErrGo( code4, value ) ; + } + } + + public short errOff + { + get + { + return code4errOff( code4, -5 ) ; + } + set + { + code4errOff( code4, value ) ; + } + } + + public int errOpen + { + get + { + return c4getErrOpen( code4 ) ; + } + set + { + c4setErrOpen( code4, value ) ; + } + } + + public short errorCode + { + get + { + return code4errorCode( code4, -5 ) ; + } + set + { + error4set( code4, value ) ; + } + } + + public int errRelate + { + get + { + return c4getErrRelate( code4 ) ; + } + set + { + c4setErrRelate( code4, value ) ; + } + } + + public int errSkip + { + get + { + return c4getErrSkip( code4 ) ; + } + set + { + c4setErrSkip( code4, value ) ; + } + } + + public int errTagName + { + get + { + return c4getErrTagName( code4 ) ; + } + set + { + c4setErrTagName( code4, value ) ; + } + } + + public int fileFlush + { + get + { + return c4getFileFlush( code4 ) ; + } + set + { + c4setFileFlush( code4, value ) ; + } + } + + public int hWnd + { + get + { + return code4hWnd( code4, -5 ) ; + } + set + { + code4hWnd( code4, value ) ; + } + } + + public short indexBlockSize + { + get + { + return code4indexBlockSize( code4 ) ; + } + set + { + code4indexBlockSizeSet( code4, value ) ; + } + } + + public short lockAttempts + { + get + { + return code4lockAttempts( code4, -5 ) ; + } + set + { + code4lockAttempts( code4, value ) ; + } + } + + public short lockAttemptsSingle + { + get + { + return code4lockAttemptsSingle( code4, -5 ) ; + } + set + { + code4lockAttemptsSingle( code4, value ) ; + } + } + + public int lockDelay + { + get + { + return code4lockDelay( code4, -5 ) ; + } + set + { + code4lockDelay( code4, value ) ; + } + } + + public int lockEnforce + { + get + { + return c4getLockEnforce( code4 ) ; + } + set + { + c4setLockEnforce( code4, value ) ; + } + } + + public short log + { + get + { + return code4log( code4, -5 ) ; + } + set + { + code4log( code4, value ) ; + } + } + + public short memExpandBlock + { + get + { + return code4memExpandBlock( code4, -5 ) ; + } + set + { + code4memExpandBlock( code4, value ) ; + } + } + + public short memExpandData + { + get + { + return code4memExpandData( code4, -5 ) ; + } + set + { + code4memExpandData( code4, value ) ; + } + } + + public short memExpandIndex + { + get + { + return code4memExpandIndex( code4, -5 ) ; + } + set + { + code4memExpandIndex( code4, value ) ; + } + } + + public short memExpandLock + { + get + { + return code4memExpandLock( code4, -5 ) ; + } + set + { + code4memExpandLock( code4, value ) ; + } + } + + public short memExpandTag + { + get + { + return code4memExpandTag( code4, -5 ) ; + } + set + { + code4memExpandTag( code4, value ) ; + } + } + + + public int memSizeBlock + { + get + { + return code4memSizeBlock( code4, -5 ) ; + } + set + { + code4memSizeBlock( code4, value ) ; + } + } + + public int memSizeBuffer + { + get + { + return code4memSizeBuffer( code4, -5 ) ; + } + set + { + code4memSizeBuffer( code4, value ) ; + } + } + + public short memSizeMemo + { + get + { + return code4memSizeMemo( code4, -5 ) ; + } + set + { + code4memSizeMemo( code4, value ) ; + } + } + + public int memSizeMemoExpr + { + get + { + return code4memSizeMemoExpr( code4, -5 ) ; + } + set + { + code4memSizeMemoExpr( code4, value ) ; + } + } + + public int memSizeSortBuffer + { + get + { + return code4memSizeSortBuffer( code4, -5 ) ; + } + set + { + code4memSizeSortBuffer( code4, value ) ; + } + } + + public int memSizeSortPool + { + get + { + return code4memSizeSortPool( code4, -5 ) ; + } + set + { + code4memSizeSortPool( code4, value ) ; + } + } + + public short memStartBlock + { + get + { + return code4memStartBlock( code4, -5 ) ; + } + set + { + code4memStartBlock( code4, value ) ; + } + } + + public int memStartData + { + get + { + return code4memStartData( code4, -5 ) ; + } + set + { + code4memStartData( code4, value ) ; + } + } + + public short memStartIndex + { + get + { + return code4memStartIndex( code4, -5 ) ; + } + set + { + code4memStartIndex( code4, value ) ; + } + } + + public short memStartLock + { + get + { + return code4memStartLock( code4, -5 ) ; + } + set + { + code4memStartLock( code4, value ) ; + } + } + + public int memStartMax + { + get + { + return code4memStartMax( code4, -5 ) ; + } + set + { + code4memStartMax( code4, value ) ; + } + } + + public short memStartTag + { + get + { + return code4memStartTag( code4, -5 ) ; + } + set + { + code4memStartTag( code4, value ) ; + } + } + + public short optimize + { + get + { + return code4optimize( code4, -5 ) ; + } + set + { + code4optimize( code4, value ) ; + } + } + + public short optimizeWrite + { + get + { + return code4optimizeWrite( code4, -5 ) ; + } + set + { + code4optimizeWrite( code4, value ) ; + } + } + + public short readLock + { + get + { + return code4readLock( code4, -5 ) ; + } + set + { + code4readLock( code4, value ) ; + } + } + + public short readOnly + { + get + { + return code4readOnly( code4, -5 ) ; + } + set + { + code4readOnly( code4, value ) ; + } + } + + public short safety + { + get + { + return code4safety( code4, -5 ) ; + } + set + { + code4safety( code4, value ) ; + } + } + + public short singleOpen + { + get + { + return code4singleOpen( code4, -5 ) ; + } + set + { + code4singleOpen( code4, value ) ; + } + } + + //Functions of the Code4 + [DllImport("c4dll.dll")] + private static extern void code4autoIncrementStart( IntPtr code4, [MarshalAs(UnmanagedType.R8)] double autoIncCurrentVal ) ; + [DllImport("c4dll.dll")] + private static extern int code4calcCreate(IntPtr code4, + IntPtr expr, [MarshalAs(UnmanagedType.LPStr)] string name ) ; + [DllImport("c4dll.dll")] + private static extern void code4calcReset( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4close( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4connect( IntPtr code4, + [MarshalAs(UnmanagedType.LPStr)] string serverId, [MarshalAs(UnmanagedType.LPStr)] string processId, + [MarshalAs(UnmanagedType.LPStr)] string userName, [MarshalAs(UnmanagedType.LPStr)] string password, + [MarshalAs(UnmanagedType.LPStr)] string protocol ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr code4data( IntPtr code4, [MarshalAs(UnmanagedType.LPStr)] string alias ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/24 : changed from code4dateFormat() */ + private static extern void code4dateFormatW( IntPtr code4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int code4dateFormatSet( IntPtr code4, [MarshalAs(UnmanagedType.LPStr)] string format ) ; + [DllImport("c4dll.dll")] + private static extern int code4encryptInit(IntPtr code4, byte[] key, short keyLen); + [DllImport("c4dll.dll")] + private static extern void code4encryptFile(IntPtr code4, short encryptFlag); + [DllImport("c4dll.dll")] + private static extern void code4exit( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4flush( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4flushFiles( IntPtr code4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/24 : changed from code4indexExtension() */ + private static extern void code4indexExtensionW( IntPtr code4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int code4allocLow( [MarshalAs(UnmanagedType.I4)] int inititize, [MarshalAs(UnmanagedType.LPStr)] string protocol, [MarshalAs(UnmanagedType.I4)] int version ) ; + // CS 2007/09/18 Add code4initVB. + [DllImport("c4dll.dll")] + private static extern IntPtr code4initVB( ); + [DllImport("c4dll.dll")] + private static extern int code4initUndo(IntPtr code4); + [DllImport("c4dll.dll")] + private static extern void code4largeOn( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4lock( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern void code4lockClear( IntPtr code4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/24 : changed from code4lockFileName() */ + private static extern void code4lockFileNameW( IntPtr code4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int code4lockItem( IntPtr code4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/24 : changed from code4lockUserId() */ + private static extern void code4lockUserIdW( IntPtr code4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/24 : changed from code4lockNetworkId */ + private static extern void code4lockNetworkIdW( IntPtr code4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int code4logCreate( IntPtr code4, + [MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string userId ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : changed from code4logFileName() */ + private static extern void code4logFileNameW( IntPtr code4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int code4logOpen( IntPtr code4, + [MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string userId ) ; + [DllImport("c4dll.dll")] + private static extern void code4logOpenOff( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4optAll( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4optStart( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4optSuspend( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4timeout( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4timeoutSet( IntPtr code4, [MarshalAs(UnmanagedType.I4)] int l ) ; + [DllImport("c4dll.dll")] + private static extern int code4tranCommit( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4tranRollback( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4tranStart( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern short code4tranStatusCB( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int code4unlock( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern short code4unlockAutoCB( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern short code4unlockAutoSetCB( IntPtr code4, [MarshalAs(UnmanagedType.I2)] short c ) ; + [DllImport("c4dll.dll")] + private static extern int code4verifySet( IntPtr code4, [MarshalAs(UnmanagedType.LPStr)] string value ) ; + // CS 2007/09/18 + [DllImport("c4dll.dll")] + private static extern int error4callback(IntPtr code4, error4callbackFunction errorCallback); + + public Code4( ) + { + init() ; + } + public Code4( int initialize ) + { + init_p = 0 ; + if ( initialize != 0 ) + init() ; + } + + public void autoIncrementStart( double autoIncCurrentVal ) { code4autoIncrementStart( code4, autoIncCurrentVal ) ; } + public int calcCreate( Expr4 ex, string name ) { return ( code4calcCreate( code4, ex.EXPR4, name ) != 0 ? r4success : -1 ) ; } + public void calcReset() { code4calcReset( code4 ) ; } + public int closeAll() { return code4close( code4 ) ; } + public int connect( string serverId, string processId, string userName, string password, string protocol) + { + return code4connect( code4, serverId, processId, userName, password, protocol ) ; + } + public Data4 data( string alias ) + { + Data4 r = new Data4( code4data( code4, alias ) ) ; + return r ; + } + public string dateFormat + { + get + { + /* 20 = LEN4DATE_FORMAT */ + StringBuilder dateBuff = new StringBuilder( 20 ) ; + code4dateFormatW( code4, dateBuff ) ; + return dateBuff.ToString() ; + } + set + { + code4dateFormatSet( code4, value ) ; + } + } + + public delegate void error4callbackFunction([MarshalAs(UnmanagedType.I4)]int code4, [MarshalAs(UnmanagedType.I4)]int er, [MarshalAs(UnmanagedType.I4)]int er2, +[MarshalAs(UnmanagedType.LPStr)]string p1, [MarshalAs(UnmanagedType.LPStr)]string p2, [MarshalAs(UnmanagedType.LPStr)]string p3); + + public void errorCallback(error4callbackFunction errorCallback) + { + error4callback(code4, new error4callbackFunction(errorCallback)); + } + + public void encryptFile(short encryptFlag) { code4encryptFile(code4, encryptFlag); } + public int encryptInit(byte[] key, short keyLen) { return code4encryptInit(code4, key, keyLen); } + public void exit() { code4exit(code4); } + public int flushFiles() { return code4flush( code4 ) ; } + public string indexExtension() + { + StringBuilder extBuff = new StringBuilder( 3 ) ; + code4indexExtensionW( code4, extBuff ) ; + return extBuff.ToString( 0, 3 ) ; + } + public int init() + { + if ( init_p != 0 ) + code4initUndo( code4 ) ; + // CS 2007/09/18 Call code4initVB rather than code4allocLow. + code4 = code4initVB(); + if ( code4 != IntPtr.Zero ) + init_p = 1 ; + else + init_p = 0 ; + return ( init_p != 0 ? 1 : 0 ) ; + } + public int initUndo() + { + int rc = r4success ; + if ( init_p != 0 ) + { + rc = code4initUndo( code4 ) ; + if (rc == r4success) + { + init_p = 0 ; + code4 = IntPtr.Zero; + } + } + return rc ; + } + public void largeOn() { code4largeOn( code4 ) ; } + + // 'lock' is C# keyword - replaced 'lock()' with 'lockGroup' + public int lockGroup() { return code4lock( code4 ) ; } + public void lockClear() { code4lockClear( code4 ) ; } + public string lockFileName() + { + /* 250 = LEN4PATH */ + StringBuilder nameBuff = new StringBuilder( 250 ) ; + code4lockFileNameW( code4, nameBuff ) ; + return nameBuff.ToString() ; + } + public int lockItem() { return code4lockItem( code4 ) ; } + public string lockUserId() + { + /* 250 = LEN4PATH */ + StringBuilder idBuff = new StringBuilder( 250 ) ; + code4lockUserIdW( code4, idBuff ) ; + return idBuff.ToString() ; + } + public string lockNetworkId() + { + /* 250 = LEN4PATH */ + StringBuilder idBuff = new StringBuilder( 250 ) ; + code4lockNetworkIdW( code4, idBuff ) ; + return idBuff.ToString() ; + } + public int logCreate( string name, string userId ) { return code4logCreate( code4, name, userId) ; } + public string logFileName() + { + /* 250 = LEN4PATH */ + StringBuilder nameBuff = new StringBuilder( 250 ) ; + code4logFileNameW( code4, nameBuff ) ; + return nameBuff.ToString() ; + } + public int logOpen( string name, string userId ) { return code4logOpen( code4, name, userId ) ; } + public void logOpenOff() { code4logOpenOff( code4 ) ; } + public int optAll() { return code4optAll( code4 ) ; } + public int optStart() { return code4optStart( code4 ) ; } + public int optSuspend() { return code4optSuspend( code4 ) ; } + public int timeout + { + get + { + return code4timeout( code4 ) ; + } + set + { + code4timeoutSet( code4, value ) ; + } + } + + public int tranCommit() { return code4tranCommit( code4 ) ; } + public int tranRollback() { return code4tranRollback( code4 ) ; } + public int tranStart() { return code4tranStart( code4 ) ; } + public short tranStatus() { return code4tranStatusCB( code4 ); } + public int unlock() { return code4unlock( code4 ) ; } + public short unlockAuto + { + get + { + return code4unlockAutoCB( code4 ) ; + } + set + { + code4unlockAutoSetCB( code4, value ) ; + } + } + public void verifySet( string val ) { code4verifySet( code4, val ) ; } + } + + public class Data4 : Error4 + { + private IntPtr data ; + + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced d4alias() */ + private static extern void d4aliasW( IntPtr data4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern void d4aliasSet( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string alias ) ; + [DllImport("c4dll.dll")] + private static extern int d4append( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4appendBlank( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern short d4appendStart( IntPtr data4, [MarshalAs(UnmanagedType.I2)] short useMemo ) ; + [DllImport("c4dll.dll")] + private static extern void d4blank( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4bof( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4bottom( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4check( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4create( IntPtr code4, [MarshalAs(UnmanagedType.LPStr)] string name, IntPtr fieldInfo, IntPtr tagInfo ); + [DllImport("c4dll.dll")] + private static extern int d4close( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4code( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern void d4delete( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4deleted( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4eof( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4fieldNumber( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string fieldName ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4fieldsAdd( IntPtr data4, [MarshalAs(UnmanagedType.I2)] short nFields, IntPtr fieldInfo); + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced d4fileName() */ + private static extern void d4fileNameW( IntPtr data4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int d4flush( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4freeBlocks( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4goLow( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int recNo, [MarshalAs(UnmanagedType.I2)] short goForWrite ) ; + [DllImport("c4dll.dll")] + private static extern int d4goBof( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4goEof( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockInternal( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int recNum, [MarshalAs(UnmanagedType.U1)] byte doUnlock, [MarshalAs(UnmanagedType.I4)] int lockType ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockAdd( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int recNum ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockAddAppend( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockAddFile( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockAddAll( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockAllInternal( IntPtr data4, [MarshalAs(UnmanagedType.U1)] byte doUnlock ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockAppendInternal( IntPtr data4, [MarshalAs(UnmanagedType.U1)] byte doUnlock ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockFileInternal( IntPtr data4, [MarshalAs(UnmanagedType.U1)] byte doUnlock, [MarshalAs(UnmanagedType.I4)] int lockType ) ; + [DllImport("c4dll.dll")] + private static extern int d4log( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int logging ) ; + [DllImport("c4dll.dll")] + private static extern short d4logStatusCB( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4memoCompress(IntPtr data4); + [DllImport("c4dll.dll")] + private static extern IntPtr d4modifyStructure(IntPtr data4, IntPtr fieldInfo, IntPtr tagInfo ); + [DllImport("c4dll.dll")] + private static extern IntPtr d4open( IntPtr code4, [MarshalAs(UnmanagedType.LPStr)] string name ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4openClone( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4optimize( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int opt ) ; + [DllImport("c4dll.dll")] + private static extern int d4optimizeWrite( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int opt ) ; + [DllImport("c4dll.dll")] + private static extern int d4pack( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern double d4position( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4positionSet( IntPtr data4, [MarshalAs(UnmanagedType.R8)] double pos ) ; + [DllImport("c4dll.dll")] + private static extern void d4recall( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4recCountDo2( IntPtr data4, [MarshalAs(UnmanagedType.I2)] short assumeLocked ) ; + [DllImport("c4dll.dll")] + private static extern uint d4recWidthLow( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4refresh( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4refreshRecord( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4reindex( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4remove( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4seek( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string key ) ; + [DllImport("c4dll.dll")] + private static extern int d4seekN( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.I2)] short len ) ; + [DllImport("c4dll.dll")] + private static extern int d4seekDouble( IntPtr data4, [MarshalAs(UnmanagedType.R8)] double key ) ; + [DllImport("c4dll.dll")] + private static extern int d4seekNext( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string key ) ; + [DllImport("c4dll.dll")] + private static extern int d4seekNextN( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.I2)] short len ) ; + [DllImport("c4dll.dll")] + private static extern int d4seekNextDouble( IntPtr data4, [MarshalAs(UnmanagedType.R8)] double key ) ; + [DllImport("c4dll.dll")] + private static extern int d4seekNextUnicodeN( IntPtr data4, [MarshalAs(UnmanagedType.LPWStr)] string key, [MarshalAs(UnmanagedType.I2)] short len ) ; + [DllImport("c4dll.dll")] + private static extern int d4seekUnicodeN( IntPtr data4, [MarshalAs(UnmanagedType.LPWStr)] string key, [MarshalAs(UnmanagedType.I2)] short len ) ; + [DllImport("c4dll.dll")] + private static extern int d4skip( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int number ) ; + [DllImport("c4dll.dll")] + private static extern int d4tagSync( IntPtr data4, IntPtr tag4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4tagSelect( IntPtr data4, IntPtr tag4 ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4tagSelected( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4top( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4unlock( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4writeLow( IntPtr data4, + [MarshalAs(UnmanagedType.I4)] int number, + [MarshalAs(UnmanagedType.I4)] int unlock, + [MarshalAs(UnmanagedType.I4)] int doLock + ) ; + [DllImport("c4dll.dll")] + private static extern int d4zap( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int first, [MarshalAs(UnmanagedType.I4)] int last ) ; + + public Data4() { data = IntPtr.Zero; } + public Data4( Data4 d ) { data = d.data ; code4 = d.code4 ; } + + /* here because of Field4::data(), but do we really want this? */ + /* yes we do as it is also needed in the relation module. */ + public Data4( IntPtr d ) { data = d ; code4 = d4code( d ) ; } + + public Data4( Code4 code, string name ) { data = d4open( code.cod(), name ) ; if ( data != IntPtr.Zero ) code4 = d4code( data ) ; } + + public IntPtr cod() { return code4 ; } + + public string alias + { + get + { + /* 33 = LEN4DATA_ALIAS + 1 */ + StringBuilder buff = new StringBuilder( 33 ) ; + d4aliasW( data, buff ) ; + return buff.ToString() ; + } + set + { + d4aliasSet( data, value ) ; + } + } + public IntPtr dat() { return data ; } + + public int append() { return d4append( data ) ; } + public int appendBlank() { return d4appendBlank( data ) ; } + public short appendStart( short memo ){ return d4appendStart( data, memo ) ; } + public short appendStart( ) { return( d4appendStart( data, 0 ) ); } + public void blank() { d4blank( data ) ; } + public int bof() { return d4bof( data ) ; } + public int bottom() { return d4bottom( data ) ; } + public short changed + { + get + { + return d4changed( data, -1 ) ; + } + set + { + d4changed( data, value ) ; + } + } + public int checkIndex() { return d4check( data ) ; } + public int close() + { + if (data != IntPtr.Zero) + { + int rc = d4close( data ) ; + data = IntPtr.Zero; + return rc; + } + else + return 0 ; + } + + public int create( ref Code4 code, string name, ref Field4info f, ref Tag4info t) + { + data = d4create( code.cod(), name, f.fields(), t.tags() ) ; + if (data != IntPtr.Zero) + code4 = code.cod() ; + return code.errorCode ; + } + public int create( ref Code4 code, string name, ref Field4info f) + { + data = d4create(code.cod(), name, f.fields(), IntPtr.Zero); + if (data != IntPtr.Zero) + code4 = code.cod() ; + return code.errorCode ; + } + + public void deleteRec() { d4delete( data ) ; } + public int deleted() { return d4deleted( data ) ; } + public int eof() { return d4eof( data ) ; } + public int fieldNumber( string name ) { return d4fieldNumber( data, name ) ; } + public int fieldsAdd( ref Field4info f ) + { + // 2006/01/26 CS Add Data4.fieldsAdd method. + IntPtr new_data = d4fieldsAdd( data, (short)f.numFields(), f.fields() ) ; + if (new_data != IntPtr.Zero) + { + // success + data = new_data ; + return 0; + } + else + { + //fail + return -1; + } + } + public string fileName() + { + /* 250 = LEN4PATH */ + StringBuilder nameBuff = new StringBuilder( 250 ) ; + d4fileNameW( data, nameBuff ) ; + return nameBuff.ToString() ; + } + public int flush() { return d4flush( data ) ; } + public int freeBlocks() { return d4freeBlocks( data ) ; } + public int getErrorCode() { return code4errorCode( code4, -5 ) ; } + public int go( int rec ) { return d4goLow( data, rec, 1 ) ; } + public int goBof() { return d4goBof( data ) ; } + public int goEof() { return d4goEof( data ) ; } + public Index4 index( string name ) + { + Index4 idx = new Index4() ; + idx.init( this, name ) ; + return idx ; + } + public int isValid() { return ( data != IntPtr.Zero ? 1 : 0 ) ; } + public int lockRecord( int recNum ) { return d4lockInternal( data, recNum, 1, 1 ) ; } + public int lockAdd( int recnum ) { return d4lockAdd( data, recnum ) ; } + public int lockAddAppend() { return d4lockAddAppend( data ) ; } + public int lockAddFile() { return d4lockAddFile( data ) ; } + public int lockAddAll() { return d4lockAddAll( data ) ; } + public int lockAll() { return d4lockAllInternal( data, 1 ) ; } + public int lockAppend() { return d4lockAppendInternal( data, 1 ) ; } + public int lockFile() { return d4lockFileInternal( data, 1, 1 ) ; } + public int log + { + set + { + d4log( data, value ) ; + } + get + { + return d4log( data, -1 ) ; + } + } + public int logStatus() { return (int)d4logStatusCB( data ) ; } + public int memoCompress() { return d4memoCompress( data ) ; } + + public int modifyStructure(ref Field4info f, ref Tag4info t) + { + data = d4modifyStructure(data, f.fields(), t.tags()); + return getErrorCode(); + } + public int modifyStructure(ref Field4info f) + { + data = d4modifyStructure(data, f.fields(), IntPtr.Zero); + return getErrorCode(); + } + + public int numFields() { return (int)d4numFields( data ) ; } + public int open( ref Code4 code, string name ) + { + data = d4open( code.cod(), name ) ; + if (data != IntPtr.Zero) + code4 = code.cod() ; + return ( (code.errOpen == 0) ? (code.errorCode) : (code.errorCode < 0 ? (int) code.errorCode : 0 )) ; + } + public int openClone( Data4 d ) + { + data = d4openClone( d.dat() ) ; + if (data != IntPtr.Zero) + { + code4 = d.code4 ; + return getErrorCode() ; + } + else + return -1 ; + } + public int optimize( int optFlag ) { return d4optimize( data, optFlag ) ; } + public int optimizeWrite( int optFlag ) { return d4optimizeWrite( data, optFlag ) ; } + public int pack() { return d4pack( data ) ; } + public double position + { + get + { + return d4position( data ) ; + } + set + { + d4positionSet( data, value ) ; + } + } + public void recall() { d4recall( data ) ; } + public int recCount() { return d4recCountDo2( data, 0 ) ; } + public int recNo() { return d4recNoLow( data ) ; } + public uint recWidth() { return d4recWidthLow( data ) ; } + public int refresh() { return d4refresh( data ) ; } + public int refreshRecord() { return d4refreshRecord( data ) ; } + public int reindex() { return d4reindex( data ) ; } + + public int remove() + { + int rc = d4remove( data ) ; + if ( rc == 0 ) + data = IntPtr.Zero; + return rc ; + } + public int seek( string ptr ) { return d4seek( data, ptr ) ; } + public int seek( string ptr, short len ) { return d4seekN( data, ptr, len ) ; } + public int seek( double d ) { return d4seekDouble( data, d ) ; } + public int seekUnicode( string ptr ) { return d4seekUnicodeN( data, ptr, (short)(ptr.Length * 2) ) ; } + public int seekUnicode( string ptr, short len ) { return d4seekUnicodeN( data, ptr, len ) ; } + public int seekNext( string ptr ) { return d4seekNext( data, ptr ) ; } + public int seekNext( string ptr, short len ) { return d4seekNextN( data, ptr, len ) ; } + public int seekNext( double d ) { return d4seekNextDouble( data, d ) ; } + public int seekNextUnicode( string ptr ) { return d4seekNextUnicodeN( data, ptr, (short)(ptr.Length * 2) ) ; } + public int seekNextUnicode( string ptr, short len ) { return d4seekNextUnicodeN( data, ptr, len ) ; } + public void select() { d4tagSelect(data, IntPtr.Zero); } + public void select( Tag4 tag ) { d4tagSelect( data, tag.tg() ) ; } + public void select( string tagName ) + { + if( tagName.Length != 0 ) + { + Tag4 tag = new Tag4( this, tagName ) ; + d4tagSelect( data, tag.tg() ) ; + } + else + { + d4tagSelect(data, IntPtr.Zero); + } + } + public int skip( int n ) { return d4skip( data, n ) ; } + public int skip() { return d4skip( data, 1) ; } + public int tagSync() { return d4tagSync( data, d4tagSelected( data ) ) ; } + public int top() { return d4top( data ) ; } + public int unlock() { return d4unlock( data ) ; } + public int write( int rec ) { return d4writeLow( data, rec, 0, 1 ) ; } + public int write() { return d4writeLow( data, -1, 0, 1 ) ; } + public int zap( int f, int last ) { return d4zap( data, f, last ) ; } + public int zap() { return d4zap( data, 1, 1000000000 ) ; } + } ; + + public class Index4 : Error4 + { + private IntPtr index ; + private Data4 D4 ; + + [DllImport("c4dll.dll")] + private static extern IntPtr i4openW( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string name ) ; + [DllImport("c4dll.dll")] + private static extern int i4close( IntPtr index4 ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr i4create( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string name, IntPtr tagInfo ); + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced i4fileName() */ + private static extern void i4fileNameW( IntPtr index4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4index( IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string name ) ; + [DllImport("c4dll.dll")] + private static extern int i4reindex( IntPtr index4 ) ; + // [DllImport("c4dll.dll")] + // private static extern int i4tag( IntPtr index4, [MarshalAs(UnmanagedType.LPStr)] string name ) ; + + public IntPtr cod() { return code4 ; } + public IntPtr idx() { return index ; } + + public Index4() { index = IntPtr.Zero; } + public Index4( Data4 d, string name ) + { + index = i4openW( d.dat(), name ) ; + if (index != IntPtr.Zero) + { + code4 = d.cod() ; + D4 = d ; + } + } + public int close() + { + int rc = i4close( index ) ; + D4 = null ; + index = IntPtr.Zero; + code4 = IntPtr.Zero; + return rc; + } + public int create( ref Data4 data, string name, ref Tag4info t) + { + int rc ; + + code4 = data.cod() ; + if (data.dat() == IntPtr.Zero) + { + rc = throwError( e4struct, 60709 ) ; + } + else + { + index = i4create( data.dat(), name, t.tags() ) ; + if ( index != IntPtr.Zero ) + { + D4 = data ; + } + rc = data.getErrorCode() ; + } + return rc ; + } + public string fileName() + { + /* 250 = LEN4PATH */ + StringBuilder nameBuff = new StringBuilder( 250 ) ; + i4fileNameW( index, nameBuff ) ; + return nameBuff.ToString() ; + } + public void init( Data4 d, string name ) + { + index = d4index( d.dat(), name ); + if (index != IntPtr.Zero) + { + code4 = d.cod() ; + D4 = d ; + } + } + public int isValid() { return (index != IntPtr.Zero ? 1 : 0); } + public int open( Data4 d, string file ) + { + int rc ; + + code4 = d.cod() ; + if (d.dat() == IntPtr.Zero) + { + rc = throwError( e4struct, 60709 ) ; + } + else + { + index = i4openW( d.dat(), file ) ; + if (index != IntPtr.Zero) + { + D4 = d ; + } + rc = d.getErrorCode() ; + } + return rc ; + } + public int reindex() { return i4reindex( index ) ; } + public Tag4 tag( string name ) { return new Tag4( D4, name ) ; } + } ; + + public class Tag4 : Error4 + { + private IntPtr tag ; + private IntPtr data ; + + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced t4alias() */ + private static extern void t4aliasW( IntPtr tag4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int t4close( IntPtr tag4 ) ; + [DllImport("c4dll.dll")] + private static extern short t4descending( IntPtr tag4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced t4exprCB() */ + private static extern void t4exprW( IntPtr tag4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced t4filterCB */ + private static extern void t4filterW( IntPtr tag4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4tag(IntPtr data4, [MarshalAs(UnmanagedType.LPStr)] string name); + [DllImport("c4dll.dll")] + private static extern IntPtr d4tagSelected(IntPtr data4); + [DllImport("c4dll.dll")] + private static extern IntPtr d4tagNext( IntPtr data4, IntPtr tag4 ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr d4tagPrev(IntPtr data4, IntPtr tag4); + [DllImport("c4dll.dll")] + private static extern IntPtr t4openLow( IntPtr data4, IntPtr index4, [MarshalAs(UnmanagedType.LPStr)] string name ) ; + [DllImport("c4dll.dll")] + private static extern int t4seekN( IntPtr tag4, [MarshalAs(UnmanagedType.LPStr)] string seekValue, [MarshalAs(UnmanagedType.I2)] short len, [MarshalAs(UnmanagedType.I2)] short doDataPosition ) ; + [DllImport("c4dll.dll")] + private static extern int t4seekNW( IntPtr tag4, [MarshalAs(UnmanagedType.LPWStr)] string seekValue, [MarshalAs(UnmanagedType.I2)] short len, [MarshalAs(UnmanagedType.I2)] short doDataPosition ) ; + [DllImport("c4dll.dll")] + private static extern short t4unique( IntPtr tag4 ) ; + [DllImport("c4dll.dll")] + private static extern int t4uniqueSet( IntPtr tag4, [MarshalAs(UnmanagedType.I2)] short unique ) ; + + public Tag4() { tag = IntPtr.Zero; } + public Tag4( Data4 d, string name ) + { + init( d, name ); + if (tag != IntPtr.Zero) + code4 = d.cod() ; + } + + public Tag4( IntPtr dataPointer, IntPtr tagPointer ) + { + + tag = tagPointer ; + } + + public IntPtr tg() { return tag ; } + + public string alias() + { + /* 11 = LEN4TAG_ALIAS + 1 */ + StringBuilder buff = new StringBuilder( 11 ) ; + t4aliasW( tag, buff ) ; + return buff.ToString() ; + } + public int close() + { + int rc = t4close( tag ) ; + tag = IntPtr.Zero; + code4 = IntPtr.Zero ; + return rc ; + } + public int descending() + { + int rc; + + if (tag == IntPtr.Zero) + { + throwError( e4struct, 60913 ) ; + rc = 0 ; + } + else + rc = t4descending( tag ) ; + return rc ; + } + public string expr() + { + StringBuilder buff = new StringBuilder( 512 ) ; + t4exprW( tag, buff ) ; + return buff.ToString() ; + } + public string filter() + { + StringBuilder buff = new StringBuilder( 512 ) ; + t4filterW( tag, buff ) ; + return buff.ToString() ; + } + public void init( Data4 d, string name ) + { + if ( name.Length != 0 ) + tag = d4tag( d.dat(), name ) ; + else + { + tag = d4tagSelected( d.dat() ) ; + + if (tag == IntPtr.Zero) + tag = d4tagNext( d.dat(), IntPtr.Zero ) ; + } + if ( tag != IntPtr.Zero ) + { + data = d.dat() ; + code4 = d.cod() ; + } + else + { + data = IntPtr.Zero; + code4 = IntPtr.Zero ; + } + } + public void initFirst( Data4 d ) + { + tag = d4tagNext(d.dat(), IntPtr.Zero); + if (tag != IntPtr.Zero) + { + data = d.dat() ; + code4 = d.cod() ; + } + else + { + data = IntPtr.Zero; + code4 = IntPtr.Zero; + } + } + public void initLast( Data4 d ) + { + tag = d4tagPrev(d.dat(), IntPtr.Zero); + if (tag != IntPtr.Zero) + { + data = d.dat() ; + code4 = d.cod() ; + } + else + { + data = IntPtr.Zero; + code4 = IntPtr.Zero; + } + } + public void initNext() { if( isValid() != 0 ) tag = d4tagNext( data, tag ) ; } + public void initPrev() { if( isValid() != 0 ) tag = d4tagPrev( data, tag ) ; } + public void initSelected( Data4 d ) + { + tag = d4tagSelected( d.dat() ) ; + if (tag != IntPtr.Zero) + { + data = d.dat() ; + code4 = d.cod() ; + } + else + { + data = IntPtr.Zero; + code4 = IntPtr.Zero; + } + } + public int isValid() { return (tag != IntPtr.Zero ? 1 : 0); } + public void open( Data4 d, string name ) + { + tag = t4openLow(d.dat(), IntPtr.Zero, name); + if (tag != IntPtr.Zero) + { + data = d.dat() ; + code4 = d.cod() ; + } + else + { + data = IntPtr.Zero; + code4 = IntPtr.Zero; + } + } + public void open( Data4 d, Index4 i, string name ) + { + tag = t4openLow( d.dat(), i.idx(), name ) ; + if (tag != IntPtr.Zero) + { + data = d.dat() ; + code4 = d.cod() ; + } + else + { + data = IntPtr.Zero; + code4 = IntPtr.Zero; + } + } + public int seekN( string seekValue, short len, short doDataPosition ) + { + return t4seekN( tag, seekValue, len, doDataPosition ) ; + } + public int seekUnicodeN( string seekValue, short len, short doDataPosition ) + { + return t4seekNW( tag, seekValue, len, doDataPosition ) ; + } + public short unique + { + set + { + t4uniqueSet( tag, value ) ; + } + get + { + return t4unique( tag ) ; + } + } + } ; + + + public class Field4 : Error4 + { + private IntPtr field ; + private IntPtr db ; + + private const int r4cdx = 200 ; + + [DllImport("c4dll.dll")] + private static extern int code4indexFormat( IntPtr code4 ) ; + [DllImport("c4dll.dll")] + private static extern int d4lockTest( IntPtr data4, [MarshalAs(UnmanagedType.I4)] int recNo, [MarshalAs(UnmanagedType.I4)] int lockType ) ; + [DllImport("c4dll.dll")] + private static extern byte d4versionCB( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignBytesW( IntPtr field4, [MarshalAs(UnmanagedType.LPArray)] byte[] val, [MarshalAs(UnmanagedType.I4)] int len ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignCurrency( IntPtr field4, [MarshalAs(UnmanagedType.LPStr)] string val ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignDateTime( IntPtr field4, [MarshalAs(UnmanagedType.LPStr)] string val ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignDouble( IntPtr field4, [MarshalAs(UnmanagedType.R8)] double val ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignField( IntPtr fieldTo, IntPtr fieldFrom ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignN( IntPtr field4, [MarshalAs(UnmanagedType.LPStr)] string val, [MarshalAs(UnmanagedType.U4)] uint len ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignNotNull( IntPtr field4 ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignNull( IntPtr field4 ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignInt( IntPtr field4, [MarshalAs(UnmanagedType.I4)] int val ) ; + [DllImport("c4dll.dll")] + private static extern void f4assignUnicode( IntPtr field4, [MarshalAs(UnmanagedType.LPWStr)] string val ) ; + [DllImport("c4dll.dll")] + private static extern void f4bytesW( IntPtr field4, [MarshalAs(UnmanagedType.LPArray)] byte[] val, [MarshalAs(UnmanagedType.I4)] int len ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced f4currency() */ + private static extern void f4currencyW( IntPtr field4, [MarshalAs(UnmanagedType.I2)] short numDec, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern char f4char( IntPtr field4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced f4dateTime() */ + private static extern void f4dateTimeW( IntPtr field4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern double f4double( IntPtr field4 ) ; + [DllImport("c4dll.dll")] + private static extern int f4int( IntPtr field4 ) ; + [DllImport("c4dll.dll")] + private static extern int f4number( IntPtr field4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced f4str() */ + private static extern void f4strW( IntPtr field4, byte[] buff ) ; + [DllImport("c4dll.dll")] // LY Jun 23/04 : replaced f4strUnicode() + private static extern void f4strUnicodeW( IntPtr field4, [MarshalAs(UnmanagedType.LPWStr)] string buff ) ; + [DllImport("c4dll.dll")] + private static extern int f4true( IntPtr field4 ) ; + + public IntPtr cod() { return code4 ; } + public IntPtr dat() { return db ; } + public IntPtr fld() { return field ; } + + // AS Feb 23/06 - also support as an int...makes conversion avoidance (d4fieldNumber returns int) + public Field4( Data4 d, int j ) + { + field = d4fieldJ( d.dat(), (short)j ) ; + if (field != IntPtr.Zero) + { + db = d.dat() ; + code4 = d.cod() ; + } + } + public Field4( Data4 d, short j ) + { + field = d4fieldJ( d.dat(), j ) ; + if ( field != IntPtr.Zero ) + { + db = d.dat() ; + code4 = d.cod() ; + } + } + public Field4( Data4 d, string name ) + { + field = d4field( d.dat(), name ) ; + if (field != IntPtr.Zero) + { + db = d.dat() ; + code4 = d.cod() ; + } + } + public Field4( ref Field4 f ) + { + field = d4fieldJ( f.dat(), (short)f.number() ) ; + if (field != IntPtr.Zero) + { + db = f.dat() ; + code4 = f.code4 ; + } + } + + /* not allowed to overload int and double -- added 'get" */ + public char getChar() { return f4char( field ) ; } + public int getInt() { return f4int( field ) ; } + public double getDouble() { return f4double(field) ; } + + public void assign( string data ) { f4assignN( field, data, (uint)data.Length ) ; } + public void assign( string data, uint len ) { f4assignN( field, data, len ) ; } + public void assignBytes( byte[] data, int len ) { f4assignBytesW( field, data, len ) ; } + public void assignCurrency( string data ) { f4assignCurrency( field, data ) ; } + public void assignDateTime( string data ) { f4assignDateTime( field, data ) ; } + public void assignDouble( double data ) { f4assignDouble( field, data ) ; } + public void assignField( ref Field4 f ) { f4assignField( field, f.fld() ) ; } + public void assignInt( int data ) { f4assignInt( field, data ) ; } + public void assignNull() { f4assignNull( field ) ; } + public void assignUnicode( string str ) { f4assignUnicode( field, str ) ; } + public void bytes( byte[] data, int len ) { f4bytesW( field, data, len ) ; } + public void changed() + { + if (field == IntPtr.Zero) + throwError( e4struct, E61203 ); + else + d4changed( db, 1 ) ; + if ( d4versionCB( db ) == 0x30 ) + f4assignNotNull( field ) ; + } + public Data4 data() + { + Data4 dt = new Data4() ; + + if (field == IntPtr.Zero) + throwError( e4struct, 61204 ) ; + else + dt = new Data4( db ) ; + + return dt ; + } + + public string currency( short numDec ) + { + StringBuilder buff = new StringBuilder( 20 ) ; + f4currencyW( field, numDec, buff ) ; + return buff.ToString(0, Math.Min(20, buff.Length)).TrimEnd('\0'); + } + public string dateTime() + { + StringBuilder buff = new StringBuilder( 21 ) ; + f4dateTimeW( field, buff ) ; + return buff.ToString(0, Math.Min(20, buff.Length)).TrimEnd('\0'); // CS 2010/08/10 + } + public int decimals() { return f4decimals( field ) ; } + public int init( Data4 d, string name ) + { + field = d4field( d.dat(), name ) ; + if (field != IntPtr.Zero) + { + db = d.dat() ; + code4 = d.cod() ; + return 0 ; + } + else + { + db = IntPtr.Zero; + code4 = IntPtr.Zero; + return -1 ; + } + } + public int init( Data4 d, short j ) + { + field = d4fieldJ( d.dat(), j ) ; + if (field != IntPtr.Zero) + { + db = d.dat() ; + code4 = d.cod() ; + return 0 ; + } + else + { + db = IntPtr.Zero; + code4 = IntPtr.Zero; + return -1 ; + } + } + + public short isBinaryField() + { + switch ( f4type( field ) ) + { + case r4int: + case r4double: + case r4currency: + case r4dateTime: + /*case r5i2: + case r5ui2: + case r5ui4: + case r5i8: + case r5ui8:*/ + return 1 ; + default: + break ; + } + return 0; + } + + public int isNull() { return f4null( field ) ; } + public int isValid() { return (field != IntPtr.Zero ? 1 : 0); } + public int isTrue() { return f4true( field ) ; } + public uint len() { return f4len( field ) ; } + public uint len1() { return f4len( field ) ; } + public int lockCheck() + { + if ( code4accessMode( code4, -5 ) != OPEN4DENY_NONE) + return r4success ; + if ( c4getLockEnforce( code4 ) == 0 || d4recNoLow( db ) <= 0 ) + return r4success ; + // Check to see if the record is locked. + if ( d4lockTest( db, d4recNoLow( db ), lock4write ) != 0 ) + return r4success ; + return throwError( e4lock, E60201 ) ; + } + + public string name() + { + /* LY 2002/09/24 : .NET corrupting FIELD4 struct when using + f4name() (requires calling ::name() on >6 fields to appear) */ + StringBuilder nameBuff = new StringBuilder( 10 ) ; + f4nameW( field, nameBuff ) ; + if ( nameBuff.Length < 10 ) + return nameBuff.ToString() ; + else + return nameBuff.ToString( 0, 10 ) ; + } + + public int number() { return f4number( field ) ; } + + public char type() { return f4type( field ) ; } + public string str() + { + int tempLen = (int) this.len() ; + byte[] strBuff = new byte[tempLen]; + switch ( f4type( field ) ) + { + case r4int: + int ival = f4int( field ) ; + return ival.ToString() ; + case r4currency: + if ( code4indexFormat( code4 ) == r4cdx ) + { + StringBuilder buff = new StringBuilder( 20 ) ; + f4currencyW( field, 2, buff ) ; + return buff.ToString() ; + } + else + { + f4strW( field, strBuff ) ; + return System.Text.Encoding.Default.GetString(strBuff); + } + case r4dateTime: + if ( code4indexFormat( code4 ) == r4cdx ) + { + StringBuilder buff = new StringBuilder( 16 ) ; + f4dateTimeW( field, buff ) ; + return buff.ToString() ; + } + else + { + f4strW( field, strBuff ) ; + return System.Text.Encoding.Default.GetString(strBuff); + } + case r4double: + if ( code4indexFormat( code4 ) == r4cdx ) + { + double dval = f4double( field ) ; + return dval.ToString() ; + } + else + { + f4strW( field, strBuff ) ; + return System.Text.Encoding.Default.GetString(strBuff); + } + case r4unicode: + // CS 2006/12/12 Trim trailing nulls. + if ( code4indexFormat( code4 ) == r4cdx ) + { + String buff = new String( ' ', tempLen / 2 + tempLen % 2 ) ; + f4strUnicodeW( field, buff ) ; + return buff.TrimEnd('\0') ; + } + else + { + f4strW( field, strBuff ) ; + return System.Text.Encoding.Default.GetString(strBuff); + } + default : + f4strW( field, strBuff ) ; + return System.Text.Encoding.Default.GetString(strBuff); + } + } + + } ; + + + public class Field4info : Error4 + { + private IntPtr fldInfo ; + private int fldInfoSize ; + + [DllImport("c4dll.dll")] + private static extern IntPtr f4infoAdd( + IntPtr code4, + IntPtr fldInfo, + [MarshalAs(UnmanagedType.I4)] int fldInfoSize, + [MarshalAs(UnmanagedType.LPStr)] string name, + [MarshalAs(UnmanagedType.U2)] char type, + [MarshalAs(UnmanagedType.I4)] int len, + [MarshalAs(UnmanagedType.I4)] int dec, + [MarshalAs(UnmanagedType.I4)] int nulls ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr f4infoInit( + IntPtr code4, + [MarshalAs(UnmanagedType.LPStr)] string name, + [MarshalAs(UnmanagedType.U2)] char type, + [MarshalAs(UnmanagedType.I4)] int len, + [MarshalAs(UnmanagedType.I4)] int dec, + [MarshalAs(UnmanagedType.I4)] int nulls ) ; + [DllImport("c4dll.dll")] + private static extern int f4infoDel( + IntPtr code4, + IntPtr fldInfo, + [MarshalAs(UnmanagedType.I4)] int fldInfoSize, + [MarshalAs(UnmanagedType.I4)] int fldNum ) ; + [DllImport("c4dll.dll")] + private static extern int f4infoFree( + IntPtr fldInfo, + [MarshalAs(UnmanagedType.I4)] int fldInfoSize ) ; + [DllImport("c4dll.dll")] + private static extern void f4infoName( + IntPtr code4, + IntPtr fldInfo, + [MarshalAs(UnmanagedType.I4)] int fldNum, + StringBuilder buff) ; + + public Field4info( ref Code4 code ) + { + code4 = code.cod() ; + fldInfo = IntPtr.Zero; + fldInfoSize = 0 ; + } + + public Field4info( Data4 d ) + { + if (d.dat() == IntPtr.Zero) + { + Error4 err = new Error4() ; + err.throwError( Error4.e4struct, Error4.E60282 ) ; + } + fldInfo = IntPtr.Zero; + fldInfoSize = 0 ; + code4 = d.cod() ; + add( d ) ; + } + + ~Field4info() + { + if (fldInfo != IntPtr.Zero) + free() ; + } + public int add( string name, char type, int len, int dec, int options ) + { + IntPtr temp = f4infoAdd( code4, fldInfo, fldInfoSize, name, type, len, dec, options ) ; + if (temp != IntPtr.Zero) + { + fldInfo = temp ; + fldInfoSize++ ; + return 0 ; + } + else + return -1 ; + } + public int add( Field4 field) + { + return add( field.name(), field.type(), (int)field.len(), field.decimals(), (ushort)field.isNull() ) ; + } + public int del( string alias ) + { + StringBuilder nameBuff = new StringBuilder( 10 ) ; + + for( int i = 0 ; i < fldInfoSize ; i++ ) + { + f4infoName( code4, fldInfo, i, nameBuff ) ; + if ( nameBuff.ToString().ToUpper() == alias.ToUpper() ) + { + del( i ) ; + return 0 ; + } + } + error( e4fieldName, E60281, alias, "", "" ) ; + return -1 ; + } + public int add( Data4 data) + { + IntPtr f ; + short i, numFields ; + //char[] temp ; + /* LY 2002/09/24 : changed from string */ + StringBuilder currName = new StringBuilder( 10 ) ; + + numFields = d4numFields( data.dat() ) ; + for( i = 1 ; i <= numFields ; i++ ) + { + f = d4fieldJ( data.dat(), i ) ; + f4nameW( f, currName ) ; /* LY 2002/09/24 : changed from f4name() */ + /* LY 2002/09/24 : added ::toString() */ + if ( add( currName.ToString(), f4type( f ), (int)f4len( f ), + f4decimals(f), (ushort)f4null( f ) ) < 0 ) + return -1 ; + } + return 0 ; + } + + public int del( int index ) + { + if( index >= fldInfoSize || index < 0 ) + { + throwError( e4parm, E60281 ) ; + return -1 ; + } + + if ( f4infoDel( code4, fldInfo, fldInfoSize, index ) == 0 ) + { + fldInfoSize-- ; + return 0 ; + } + else + return -1 ; + } + + public void free() + { + f4infoFree( fldInfo, fldInfoSize ) ; + fldInfo = IntPtr.Zero; + } + + public int numFields() { return fldInfoSize ; } + public IntPtr fields() { return fldInfo ; } + } ; + + public class Tag4info : Error4 + { + [DllImport("c4dll.dll")] + private static extern IntPtr d4nextIndex(IntPtr code4, IntPtr data4, IntPtr index4); + [DllImport("c4dll.dll")] + private static extern IntPtr i4tagInfo(IntPtr index4) ; + [DllImport("c4dll.dll")] + private static extern IntPtr t4infoAdd( + IntPtr code4, + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int size, + [MarshalAs(UnmanagedType.LPStr)] string name, + [MarshalAs(UnmanagedType.LPStr)] string expr, + [MarshalAs(UnmanagedType.LPStr)] string filter, + [MarshalAs(UnmanagedType.I2)] short unique, + [MarshalAs(UnmanagedType.U2)] ushort desc ) ; + [DllImport("c4dll.dll")] + private static extern int t4infoDel( + IntPtr code4, + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int size, + [MarshalAs(UnmanagedType.I4)] int index ) ; + [DllImport("c4dll.dll")] + private static extern ushort t4infoDescend( + IntPtr code4, + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int index ) ; + [DllImport("c4dll.dll")] + private static extern void t4infoExpr( + IntPtr code4, + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int index, + StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern void t4infoFilter( + IntPtr code4, + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int index, + StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern void t4infoFree( + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int size ) ; + [DllImport("c4dll.dll")] + private static extern void t4infoFreeInternal( + IntPtr tag4info); + [DllImport("c4dll.dll")] + private static extern void t4infoName( + IntPtr code4, + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int index, + StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int t4infoSize( + IntPtr code4, + IntPtr tag4info ) ; + [DllImport("c4dll.dll")] + private static extern short t4infoUnique( + IntPtr code4, + IntPtr tag4info, + [MarshalAs(UnmanagedType.I4)] int index ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr t4tagInfo( + IntPtr tag4); + + private IntPtr tagInfo ; + private int tagInfoSize ; + + public Tag4info( Code4 code ) + { + tagInfoSize = 0 ; + code4 = code.cod() ; + tagInfo = IntPtr.Zero ; + } + public Tag4info( Data4 d ) + { + IntPtr index4ptr = IntPtr.Zero; + if (d.dat() == IntPtr.Zero) + throwError( e4struct, E60983 ) ; + + tagInfoSize = 0 ; + code4 = d.cod() ; + tagInfo = IntPtr.Zero; + + for( index4ptr = d4nextIndex( code4, d.dat(), index4ptr ) ; + index4ptr != IntPtr.Zero; + index4ptr = d4nextIndex( code4, d.dat(), index4ptr ) ) + { + addIndex_tags( index4ptr ) ; + } + } + public Tag4info( Index4 index ) + { + if (index.idx() == IntPtr.Zero) + throwError( e4struct, E60983 ) ; + + tagInfoSize = 0 ; + code4 = index.cod() ; + tagInfo = IntPtr.Zero; + + addIndex_tags( index.idx() ) ; + } + ~Tag4info() + { + if (tagInfo != IntPtr.Zero) + free() ; + } + + public int add( string name, string expr, string filter, short uniq, short desc ) + { + IntPtr temp = t4infoAdd( code4, tagInfo, tagInfoSize, name, expr, filter, uniq, (ushort)desc ) ; + + if (temp != IntPtr.Zero) + { + tagInfo = temp ; + tagInfoSize++ ; + return 0 ; + } + + return -1 ; + } + + public int add( Tag4 tag ) + { + IntPtr tagInfoInternal ; + int i = 0 ; + string name ; + //string expr, filter ; + StringBuilder tempName = new StringBuilder( 10 ) ; + StringBuilder tempExpr = new StringBuilder( 512 ) ; + StringBuilder tempFilter = new StringBuilder( 512 ) ; + + if ( tag.isValid() == 0 ) + { + throwError( e4struct, E60991 ) ; + return -1 ; + } + + tagInfoInternal = t4tagInfo( tag.tg() ) ; + if (tagInfoInternal == IntPtr.Zero) + { + throwError( e4struct, E60991 ) ; + return -1 ; + } + + name = tag.alias() ; + t4infoName( code4, tagInfoInternal, i, tempName ) ; + while( name.ToUpper() != tempName.ToString().ToUpper() + || i < tagInfoSize ) + { + i++ ; + t4infoName( code4, tagInfoInternal, i, tempName ) ; + } + + t4infoExpr( code4, tagInfoInternal, i, tempExpr ) ; + t4infoFilter( code4, tagInfoInternal, i, tempFilter ) ; + add( name, tempExpr.ToString(), tempFilter.ToString(), t4infoUnique( code4, tagInfoInternal, i), + (short)t4infoDescend( code4, tagInfoInternal, i ) ) ; + t4infoFreeInternal( tagInfoInternal ) ; + + return 0 ; + } + + private int addIndex_tags( IntPtr index4 ) + { + IntPtr tagInfoInternal; + int i, numTags ; + // string currName, currExpr, currFilter ; + StringBuilder tempName = new StringBuilder( 10 ) ; + StringBuilder tempExpr = new StringBuilder( 512 ) ; + StringBuilder tempFilter = new StringBuilder( 512 ) ; + + tagInfoInternal = i4tagInfo( index4 ) ; + if (tagInfoInternal == IntPtr.Zero) + throwError( e4struct, E60984 ) ; + numTags = t4infoSize( code4, tagInfoInternal ) ; + for ( i = 0 ; i < numTags ; i++ ) + { + t4infoName( code4, tagInfoInternal, i, tempName ) ; + t4infoExpr( code4, tagInfoInternal, i, tempExpr ) ; + t4infoFilter( code4, tagInfoInternal, i, tempFilter ) ; + add( tempName.ToString(), tempExpr.ToString(), tempFilter.ToString(), + t4infoUnique( code4, tagInfoInternal, i ), + (short)t4infoDescend( code4, tagInfoInternal, i ) ) ; + } + t4infoFreeInternal( tagInfoInternal ) ; + + return 0 ; + } + + public int del( int index ) + { + if (code4 == IntPtr.Zero) + { + throwError( e4struct, E60982 ) ; + return -1 ; + } + if ( index >= t4infoSize( code4, tagInfo ) || index < 0 ) + { + throwError( e4parm, E60982 ) ; + return -1 ; + } + if ( t4infoDel( code4, tagInfo, tagInfoSize, index ) == 0 ) + { + tagInfoSize-- ; + return 0 ; + } + else + return -1 ; + } + public int del( string name ) + { + int i ; + string temp = name.ToUpper() ; + StringBuilder tempName = new StringBuilder( 10 ) ; + temp.PadRight( 10, ' ' ) ; + + for( i = 0 ; i < tagInfoSize ; i++ ) + { + t4infoName( code4, tagInfo, i, tempName ) ; + if ( temp.Substring( 0, 10 ).ToUpper() == tempName.ToString().ToUpper() ) + { + del( i ) ; + return 0 ; + } + } + + error( e4parm, E60982, name, "", "" ) ; + return -1 ; + } + + public void free() + { + t4infoFree( tagInfo, tagInfoSize ) ; + tagInfo = IntPtr.Zero; + } + public int numTags() { return tagInfoSize ; } + public IntPtr tags() { return tagInfo ; } + } ; + + + public class Field4memo : Error4 + { + private IntPtr field ; + private IntPtr db ; + private int currentMemoPos, finalMemoLen ; + + [DllImport("c4dll.dll")] + private static extern void f4memoAssign( + IntPtr field4, + [MarshalAs(UnmanagedType.LPStr)] string val + ) ; + [DllImport("c4dll.dll")] + private static extern int f4memoAssignBytesW( + IntPtr field4, + [MarshalAs(UnmanagedType.LPArray)] byte[] val, + [MarshalAs(UnmanagedType.U4)] uint len + ) ; + [DllImport("c4dll.dll")] + private static extern void f4memoAssignN( + IntPtr field4, + [MarshalAs(UnmanagedType.LPStr)] string val, + [MarshalAs(UnmanagedType.U4)] uint len + ) ; + [DllImport("c4dll.dll")] + private static extern void f4memoAssignUnicode( + IntPtr field4, + [MarshalAs(UnmanagedType.LPWStr)] string val + ) ; + [DllImport("c4dll.dll")] + private static extern uint f4memoBytesW( + IntPtr field4, + [MarshalAs(UnmanagedType.LPArray)] byte[] val, + [MarshalAs(UnmanagedType.U4)] uint len + ) ; + [DllImport("c4dll.dll")] + private static extern void f4memoChanged( + IntPtr field4 + ) ; + [DllImport("c4dll.dll")] + private static extern void f4memoFree( + IntPtr field4 + ) ; + [DllImport("c4dll.dll")] + private static extern uint f4memoLen( + IntPtr field4 + ) ; + [DllImport("c4dll.dll")] + private static extern void f4memoReadW( + IntPtr field4, + [MarshalAs(UnmanagedType.U4)] uint readLen, + [MarshalAs(UnmanagedType.U4)] uint startPos, + StringBuilder buff + ) ; + [DllImport("c4dll.dll")] + private static extern int f4memoSetLenW( + IntPtr field4, + [MarshalAs(UnmanagedType.U4)] uint newLen + ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced f4memoStr() */ + private static extern void f4memoStrW( + IntPtr field4, + byte[] buff + ); + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced f4memoStr() */ + private static extern int f4memoReadPart( + IntPtr field4, + byte[] buff, + [MarshalAs(UnmanagedType.I4)] int readLen, + [MarshalAs(UnmanagedType.I4)] int startPos + ); + [DllImport("c4dll.dll")] + private static extern void f4memoUnicodeStrW( + IntPtr field4, + [MarshalAs(UnmanagedType.LPWStr)] string buff + ) ; + [DllImport("c4dll.dll")] + private static extern int f4memoWritePart( + IntPtr field4, + [MarshalAs(UnmanagedType.LPStr)] string dataToWrite, + [MarshalAs(UnmanagedType.U4)] uint dataLen, + [MarshalAs(UnmanagedType.I4)] int memoLen, + [MarshalAs(UnmanagedType.I4)] int offset + ) ; + [DllImport("c4dll.dll")] + private static extern int f4memoWriteFinish( + IntPtr data4 + ) ; + + public IntPtr cod() { return code4 ; } + public IntPtr dat() { return db ; } + public IntPtr fld() { return field ; } + + public Field4memo( Data4 d, short i ) + { + field = d4fieldJ( d.dat(), i ) ; + if (field != IntPtr.Zero) + { + db = d.dat() ; + code4 = d.cod() ; + } + } + public Field4memo( Data4 d, string name ) + { + field = d4field( d.dat(), name ) ; + if (field != IntPtr.Zero) + { + db = d.dat() ; + code4 = d.cod() ; + } + } + public Field4memo( Field4 f ) + { + field = f.fld() ; + if (field != IntPtr.Zero) + { + db = f.dat() ; + code4 = f.cod() ; + } + } + public Field4memo( Field4memo f ) + { + field = f.fld() ; + if (field != IntPtr.Zero) + { + db = f.dat() ; + code4 = f.cod() ; + } + } + + public void assign( string data ) { f4memoAssign( field, data ) ; } + public void assign( string data, uint len ) { f4memoAssignN( field, data, len ) ; } + public int assignBytes( byte[] data, uint len ) { return f4memoAssignBytesW( field, data, len ) ; } + public uint bytes( byte[] data, uint len ) { return f4memoBytesW( field, data, len ) ; } + public void changed() + { + if (field == IntPtr.Zero) + throwError( e4struct, E60523 ) ; + else + f4memoChanged( field ) ; + } + + public void free() { f4memoFree( field ) ; } + public int isNull() { return f4null( field ) ; } + public int isValid() { return (field != IntPtr.Zero ? 1 : 0); } + public uint len() { return f4memoLen( field ) ; } + public int setLen( uint newLen ) + { + if (field == IntPtr.Zero) + return throwError( e4struct, E60525 ) ; + else + return f4memoSetLenW( field, newLen ) ; + } + + public void assignUnicode( string str ) { f4memoAssignUnicode( field, str ) ; } + + // char S4PTR*ptr() { return f4memoPtr( field ) ; } + // char const S4PTR*ptr1() const { return f4memoPtr( field ) ; } + public string str() + { + int tempLen = (int)this.len(); + byte[] buff = new byte[tempLen]; + f4memoStrW(field, buff); + return System.Text.Encoding.Default.GetString(buff); + } + + public string str(int readLen, int startPos) + { + byte[] buff = new byte[readLen]; + int bytesRead = f4memoReadPart(field, buff, readLen, startPos); + return System.Text.Encoding.Default.GetString(buff); + } + + public string strUnicode() + { + int tempLen = (int)this.len() ; + string buff = new String( ' ', tempLen / 2 + tempLen % 2 ) ; + f4memoUnicodeStrW( field, buff ) ; + return buff ; + } + + // AS 03/29/00 Added partial read/write support independent of normal mechanism + public string read( uint readLen, uint startPos ) + { + StringBuilder buff = new StringBuilder( (int)readLen + 1 ) ; + f4memoReadW( field, readLen, startPos, buff ) ; + return buff.ToString() ; + } + public int write( string ptrToData, uint lenToWrite ) + { + int rc = f4memoWritePart( field, ptrToData, lenToWrite, finalMemoLen, currentMemoPos ) ; + currentMemoPos += (int)lenToWrite ; + return rc ; + } + public void writeStart( int memoLen ) { currentMemoPos = 0 ; finalMemoLen = memoLen ; } + public int writeFinish() { return f4memoWriteFinish( db ) ; } + } ; + + /* public class Date4 : Error4 + { + private int dt ; // C char pointer + private int result ; // for ::format(), ::timeNow() + + [DllImport("c4dll.dll")] + private static extern int date4alloc( [MarshalAs(UnmanagedType.LPStr)]UCT int code4, [MarshalAs(UnmanagedType.LPStr)] string pict ) ; + [DllImport("c4dll.dll")] + private static extern void date4assign( int ptr, [MarshalAs(UnmanagedType.I4)] int d ) ; + [DllImport("c4dll.dll")] + private static extern void date4assignW( int ptr, [MarshalAs(UnmanagedType.LPStr)] string d ) ; + [DllImport("c4dll.dll")] + private static extern string date4cdow( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern string date4cmonth( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern int date4day( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern int date4dow( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern void date4init( int ptr, [MarshalAs(UnmanagedType.LPStr)] string d, [MarshalAs(UnmanagedType.LPStr)] string pict ) ; + [DllImport("c4dll.dll")] + private static extern double date4formatMdx( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern string date4formatW( int ptr, int result, [MarshalAs(UnmanagedType.LPStr)] string pict ) ; + [DllImport("c4dll.dll")] + private static extern int date4long( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern int date4month( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern string date4timeNowW( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern void date4today( int ptr ) ; + [DllImport("c4dll.dll")] + private static extern int date4year( int ptr ) ; + + public Date4() + { + dt = date4alloc( code4, "CCYYMMDD" ) ; + } + ~Date4() + { + if ( dt != 0 ) + u4free( dt ) ; + } + public Date4( int l ) + { + dt = date4alloc( code4, "CCYYMMDD" ) ; + if ( dt != 0 ) + date4assign(dt, l) ; + } + public Date4( string d ) + { + dt = date4alloc( code4, "CCYYMMDD" ) ; + if ( dt != 0 ) + date4assignW( dt, d ) ; + } + public Date4( string d, string format ) + { + dt = date4alloc( code4, "CCYYMMDD" ) ; + if ( dt != 0 ) + date4init( dt, d, format ) ; + } + public Date4( Date4 s ) + { + dt = date4alloc( code4, "CCYYMMDD" ) ; + if ( dt != 0 ) + date4assign( dt, s.getInt() ) ; + } + // can't overload Date4 &operator =( const Str4 &s ) { assign( s ) ; return *this ; } + public int getInt() + { + if ( dt != 0 ) + return date4long( dt ) ; + else + return 0 ; + } + public double getdouble() + { + if ( dt != 0 ) + return date4formatMdx( dt ) ; + else + return 1.0E100 ; + } + public static int operator +( Date4 d, int l ) + { + if ( d.dt != 0 ) + return ( date4long( d.dt )+l ) ; + else + return 0 ; + } + public static int operator -( Date4 d, int l ) + { + if ( d.dt != 0 ) + return ( date4long( d.dt )-l ) ; + else + return 0 ; + } + // can't overload void operator +=( const long l ) { date4assign( ptr(), date4long( ptr() )+l ) ; } + public void add( int l ) + { + if ( dt != 0 ) + date4assign( dt, date4long( dt ) + l ) ; + } + // " " void operator -=( const long l ) { date4assign( ptr(), date4long( ptr() )-l ) ; } + public void subtract( int l ) + { + if ( dt != 0 ) + date4assign( dt, date4long( dt ) - l ) ; + } + + // problem: unary operators ++ and -- must return same type as parameter, + // but C++ Date ++ and -- return long values + // public static Date4 operator ++( Date4 d ) { d.add( 1 ) ; return d.getInt() ; } + // public static Date4 operator --( Date4 d ) { d.subtract( 1 ) ; return d.getInt() ; } + public void assign( int l ) + { + if ( dt != 0 ) + date4assign( dt , l ) ; + } + public void assign( string d ) + { + if ( dt != 0 ) + date4assignW( dt, d ) ; + } + public void assign( string p, string pict ) + { + if ( dt != 0 ) + date4init( dt, p, pict ) ; + } + // void assign( Str4 &s ) { Str4::assign( s ) ; } + public string cdow() + { + if ( dt != 0 ) + return date4cdow( dt ) ; + else + return " " ; + } + public string cmonth() + { + if ( dt != 0 ) + return date4cmonth( dt ) ; + else + return " " ; + } + public int day() + { + if ( dt != 0 ) + return date4day( dt ) ; // Day of month ( 1-31 ) + else + return 0 ; + } + public int dow() + { + if ( dt != 0 ) + return date4dow( dt ) ; // Day of week ( 1-7 ) + else + return 0 ; + } + public string format( string pict ) + { + result = date4alloc( cb, pict ) ; + if ( result != 0 ) + { + string temp = date4formatW( dt, result, pict ) ; + u4free( result ) ; + return temp ; + } + else + return " " ; + } + public int isLeap() + { + if ( dt != 0 ) + { + int y = date4year( dt ) ; + return ( y%4 == 0 && y%100 != 0 || y%400 == 0 ) ? 1 : 0 ; + } + else + return -1 ; + } + // unsigned long len() const { return 8 ; } + // unsigned long len1() const { return 8 ; } + public int month() + { + if ( dt != 0 ) + return date4month( dt ) ; // Month of year ( 1-12 ) + else + return 0 ; + } + public string timeNow() + { + result = date4alloc( cb, "HH:MM:SS" ) ; + if ( result != 0 ) + { + string temp = date4timeNowW( result ) ; + u4free( result ) ; + return temp ; + } + else + return " " ; + } + public void today() { date4today( dt ) ; } + public int year() { return date4year( dt ) ; } + // char S4PTR*ptr() { return dt ; } + // char const S4PTR*ptr1() const { return dt ; } + } ;*/ + + public class Relate4 : Error4 + { + [DllImport("c4dll.dll")] + private static extern IntPtr relate4createSlave( + IntPtr relate4, + IntPtr data4, + [MarshalAs(UnmanagedType.LPStr)] string masterExpr, + IntPtr tag ); + [DllImport("c4dll.dll")] + private static extern IntPtr relate4dataCB( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4dataTag( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4doOne( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4errorAction( IntPtr relate4, int value ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr relate4masterCB( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] /* LY 2002/09/25 : replaced relate4masterExprCB() */ + private static extern void relate4masterExprW( IntPtr relate4, StringBuilder buff ) ; + [DllImport("c4dll.dll")] + private static extern int relate4matchLen( IntPtr relate4, int value ) ; + [DllImport("c4dll.dll")] + private static extern int relate4type( IntPtr relate4, int value ) ; + [DllImport("c4dll.dll")] + protected static extern int relate4next( ref IntPtr relate4 ) ; + + public Relate4() { relate = IntPtr.Zero; } + public Relate4( Relate4 master, Data4 slave, string masterExpr, Tag4 t ) + { relate = relate4createSlave( master.rl(), slave.dat(), masterExpr, t.tg() ) ; } + public Relate4( Relate4 r ) { relate = r.rl() ; } + public Relate4( IntPtr rel ) { relate = rel ; } + public Data4 data() + { + if ( relate != IntPtr.Zero ) + return new Data4( relate4dataCB(relate) ) ; + else + return new Data4() ; + } + public Tag4 dataTag() + { + if (relate == IntPtr.Zero) + return new Tag4() ; + + Data4 dataTemp = new Data4( relate4dataCB( relate ) ) ; + return new Tag4( dataTemp, "" ) ; + } + public int doOne() { return relate4doOne( relate ) ; } + public int errorAction( int a ) { return relate4errorAction( relate, a ) ; } + public int init( Relate4 master, Data4 slave, string masterExpr, Tag4 t ) + { + relate = relate4createSlave( master.relate, slave.dat(), masterExpr, t.tg() ) ; + code4 = slave.cod() ; + return code4errorCode( code4, -5 ) ; + } + + public int isValid() { return (relate != IntPtr.Zero ? 1 : 0); } + public Relate4 master() + { + if (relate != IntPtr.Zero) + return new Relate4( relate4masterCB(relate) ); + else + return new Relate4( ) ; + } + + public string masterExpr() + { + StringBuilder buff = new StringBuilder( 512 ) ; + relate4masterExprW( relate, buff ) ; + return buff.ToString() ; + } + + public int matchLen( int p ) { return relate4matchLen( relate, p ) ; } + public int type( int p ) { return relate4type( relate, p ) ; } + + public IntPtr rl() { return relate ; } + + protected IntPtr relate ; + } ; + + public class Relate4iterator : Relate4 + { + public Relate4iterator() { relate = IntPtr.Zero; } + public Relate4iterator( Relate4 r ) { relate = r.rl() ; } + + public int next() { return ( relate4next( ref relate ) != 2 ? 1 : 0 ) ; } + public int nextPosition() { return relate4next( ref relate ) ; } + } ; + + public class Relate4set: Relate4 + { + [DllImport("c4dll.dll")] + private static extern int relate4bottom( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern void relate4changed( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern uint relate4count( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4doAll( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4eof( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4free( IntPtr relate4, int value ) ; + [DllImport("c4dll.dll")] + private static extern IntPtr relate4init( IntPtr data4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4lockAdd( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4optimizeable( IntPtr relate4 ) ; + [DllImport("c4dll.dll")] + private static extern int relate4querySet( IntPtr relate4, [MarshalAs(UnmanagedType.LPStr)] string query ) ; + [DllImport("c4dll.dll")] + private static extern int relate4skip( IntPtr relate4, [MarshalAs(UnmanagedType.I4)] int l ) ; + [DllImport("c4dll.dll")] + private static extern int relate4skipEnable( IntPtr relate4, [MarshalAs(UnmanagedType.I4)] int doEnable ) ; + [DllImport("c4dll.dll")] + private static extern int relate4sortSet( IntPtr relate4, [MarshalAs(UnmanagedType.LPStr)] string sort ) ; + [DllImport("c4dll.dll")] + private static extern int relate4top( IntPtr relate4 ) ; + + public Relate4set( Data4 data ) { relate = relate4init( data.dat() ) ; } + public Relate4set() { relate = IntPtr.Zero; } + public Relate4set( Relate4 r ) { relate = r.rl() ; } + + public int bottom() { return relate4bottom( relate ) ; } + public void changed() { relate4changed( relate ) ; } + public uint count() { return relate4count( relate ) ; } + public int doAll() { return relate4doAll( relate ) ; } + public int eof() { return relate4eof( relate ) ; } + public int free() { int rc = relate4free(relate, 0); relate = IntPtr.Zero; return rc; } + public int free(int p) { int rc = relate4free(relate, p); relate = IntPtr.Zero; return rc; } + public int init( Data4 data ) + { + relate = relate4init( data.dat() ) ; + code4 = data.cod() ; + return code4errorCode( code4, -5 ) ; + } + public int lockAdd() { return relate4lockAdd( relate ) ; } + public int optimizeable() { return relate4optimizeable( relate ) ; } + public int querySet( string p ) { return relate4querySet( relate, p ) ; } + public int skip( int n ) { return relate4skip( relate, n ) ; } + public int skip() { return relate4skip( relate, 1 ) ; } + public int skipEnable( int doEnable ) { return relate4skipEnable( relate, doEnable ) ; } + public int sortSet( string sort ) { return relate4sortSet( relate, sort ) ; } + public int top() { return relate4top( relate ) ; } + } ; + +} + diff --git a/interfaces/VB.NET/CodeBase.vb b/interfaces/VB.NET/CodeBase.vb new file mode 100644 index 0000000..72c3eaa --- /dev/null +++ b/interfaces/VB.NET/CodeBase.vb @@ -0,0 +1,1689 @@ +Option Strict Off +Option Explicit On + +Module CodeBase + ' codebase.vb (c)Copyright Sequiter Software Inc., 1988-2011. All rights reserved. + + 'Data Types Used by CodeBase + + Structure FIELD4INFOCB + Dim fName As Integer + Dim ftype As Short + Dim flength As Short + Dim fdecimals As Short + Dim fnulls As Short + End Structure + + Structure FIELD4INFO + Dim fName As String + Dim ftype As String + Dim flength As Short + Dim fdecimals As Short + Dim fnulls As Short + End Structure + + Structure TAG4INFOCB + Dim name As Integer + Dim expression As Integer + Dim filter_Renamed As Integer + Dim unique As Short + Dim descending As Short + End Structure + + Structure TAG4INFO + Dim name As String + Dim expression As String + Dim filter_Renamed As String + Dim unique As Short + Dim descending As Short + End Structure + + '=================================================================================== + ' + ' CODE4 Access function prototypes + ' + '=================================================================================== +#If USE_D4DLL Then + Declare Sub c4setAcceptTimeOut Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) + Declare Function code4actionCode Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4accessMode Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4autoIncrementStart Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Double) + Declare Function code4autoOpen Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4calcCreate Lib "d4dll.dll" (ByVal c4 As Integer, ByVal expr4 As Integer, ByVal fcnName As String) As Short + Declare Sub code4calcReset Lib "d4dll.dll" (ByVal c4 As Integer) + Declare Function code4codePage Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4collatingSequence Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4collate Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4compatibility Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4compress Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4connect Lib "d4dll.dll" (ByVal c4 As Integer, ByVal serverId As String, ByVal processId As String, ByVal userName As String, ByVal password As String, ByVal protocol As String) As Short + Declare Function code4close Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4createTemp Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4data Lib "d4dll.dll" (ByVal c4 As Integer, ByVal AliasName As String) As Integer + Declare Function code4dateFormatVB Lib "d4dll.dll" Alias "code4dateFormat" (ByVal c4 As Integer) As Integer + Declare Function code4dateFormatSet Lib "d4dll.dll" (ByVal c4 As Integer, ByVal fmt As String) As Short + Declare Function code4errCreate Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errDefaultUnique Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errorCode Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errExpr Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errFieldName Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errGo Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errSkip Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errTagName Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4exit Lib "d4dll.dll" (ByVal c4 As Integer) + Declare Function code4fileFlush Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4flush Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4hInst Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4indexBlockSize Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4indexBlockSizeSet Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4indexExtensionVB Lib "d4dll.dll" Alias "code4indexExtension" (ByVal c4 As Integer) As Integer + Declare Function code4hWnd Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4allocDll Lib "d4dll.dll" (ByVal dllName As String) As Integer + Declare Function code4initUndo Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Sub code4largeOn Lib "d4dll.dll" (ByVal c4 As Integer) + Declare Function code4lock Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4lockAttempts Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4lockAttemptsSingle Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4lockClear Lib "d4dll.dll" (ByVal c4 As Integer) + Declare Function code4lockDelay Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4lockEnforce Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4lockFileNameVB Lib "d4dll.dll" Alias "code4lockFileName" (ByVal c4 As Integer) As Integer + Declare Function code4lockItem Lib "d4dll.dll" (ByVal c4 As Integer) As Integer + Declare Function code4lockNetworkIdVB Lib "d4dll.dll" Alias "code4lockNetworkId" (ByVal c4 As Integer) As Integer + Declare Function code4lockUserIdVB Lib "d4dll.dll" Alias "code4lockUserId" (ByVal c4 As Integer) As Integer + Declare Function code4log Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4logCreate Lib "d4dll.dll" (ByVal c4 As Integer, ByVal logName As String, ByVal userId As String) As Short + Declare Function code4logFileNameVB Lib "d4dll.dll" (ByVal c4 As Integer) As Integer + Declare Function code4logOpen Lib "d4dll.dll" (ByVal c4 As Integer, ByVal logName As String, ByVal userId As String) As Short + Declare Sub code4logOpenOff Lib "d4dll.dll" (ByVal c4 As Integer) + Declare Function code4memExpandBlock Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandData Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandIndex Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandLock Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandTag Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memSizeBlock Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeBuffer Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeMemo Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memSizeMemoExpr Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeSortBuffer Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeSortPool Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memStartBlock Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartData Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartIndex Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartLock Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartMax Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memStartTag Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errOff Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errOpen Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4optAll Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4optimize Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4optStart Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4optSuspend Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4optimizeWrite Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4readLock Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4readOnly Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errRelate Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4safety Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4singleOpen Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4serverOS Lib "d4dll.dll" (ByVal c4 As Integer) As Integer + Declare Function code4timeout Lib "d4dll.dll" (ByVal c4 As Integer) As Integer + Declare Sub code4timeoutSet Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) + Declare Function code4tranStart Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4tranStatus Lib "d4dll.dll" Alias "code4tranStatusCB" (ByVal c4 As Integer) As Short + Declare Function code4tranCommit Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4tranRollback Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4unlock Lib "d4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4unlockAuto Lib "d4dll.dll" Alias "code4unlockAutoCB" (ByVal c4 As Integer) As Short + Declare Function code4useGeneralTagsInRelate Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4unlockAutoSet Lib "d4dll.dll" Alias "code4unlockAutoSetCB" (ByVal c4 As Integer, ByVal value As Short) + Declare Sub code4verifySet Lib "d4dll.dll" (ByVal c4 As Integer, ByVal value As String) +#Else + Declare Sub c4setAcceptTimeOut Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) + Declare Function code4actionCode Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4accessMode Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4autoIncrementStart Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Double) + Declare Function code4autoOpen Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4calcCreate Lib "c4dll.dll" (ByVal c4 As Integer, ByVal expr4 As Integer, ByVal fcnName As String) As Short + Declare Sub code4calcReset Lib "c4dll.dll" (ByVal c4 As Integer) + Declare Function code4codePage Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4collatingSequence Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4collate Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4compatibility Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4compress Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4connect Lib "c4dll.dll" (ByVal c4 As Integer, ByVal serverId As String, ByVal processId As String, ByVal userName As String, ByVal password As String, ByVal protocol As String) As Short + Declare Function code4close Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4createTemp Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4data Lib "c4dll.dll" (ByVal c4 As Integer, ByVal AliasName As String) As Integer + Declare Function code4dateFormatVB Lib "c4dll.dll" Alias "code4dateFormat" (ByVal c4 As Integer) As Integer + Declare Function code4dateFormatSet Lib "c4dll.dll" (ByVal c4 As Integer, ByVal fmt As String) As Short + Declare Sub code4encryptFile Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) + Declare Function code4encryptInit Lib "c4dll.dll" (ByVal c4 As Integer, ByVal key As String, ByVal length As Short) As Short + Declare Function code4errCreate Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errDefaultUnique Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errorCode Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errExpr Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errFieldName Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errGo Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errSkip Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errTagName Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4exit Lib "c4dll.dll" (ByVal c4 As Integer) + Declare Function code4fileFlush Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4flush Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4hInst Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4indexBlockSize Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4indexBlockSizeSet Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4indexExtensionVB Lib "c4dll.dll" Alias "code4indexExtension" (ByVal c4 As Integer) As Integer + Declare Function code4hWnd Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4init Lib "c4dll.dll" Alias "code4initVB" () As Integer + Declare Function code4initUndo Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Sub code4largeOn Lib "c4dll.dll" (ByVal c4 As Integer) + Declare Sub code4limitKeySizeSet Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) + Declare Function code4lock Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4lockAttempts Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4lockAttemptsSingle Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4lockClear Lib "c4dll.dll" (ByVal c4 As Integer) + Declare Function code4lockDelay Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4lockEnforce Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4lockFileNameVB Lib "c4dll.dll" Alias "code4lockFileName" (ByVal c4 As Integer) As Integer + Declare Function code4lockItem Lib "c4dll.dll" (ByVal c4 As Integer) As Integer + Declare Function code4lockNetworkIdVB Lib "c4dll.dll" Alias "code4lockNetworkId" (ByVal c4 As Integer) As Integer + Declare Function code4lockUserIdVB Lib "c4dll.dll" Alias "code4lockUserId" (ByVal c4 As Integer) As Integer + Declare Function code4log Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4logCreate Lib "c4dll.dll" (ByVal c4 As Integer, ByVal logName As String, ByVal userId As String) As Short + Declare Function code4logFileNameVB Lib "c4dll.dll" (ByVal c4 As Integer) As Integer + Declare Function code4logOpen Lib "c4dll.dll" (ByVal c4 As Integer, ByVal logName As String, ByVal userId As String) As Short + Declare Sub code4logOpenOff Lib "c4dll.dll" (ByVal c4 As Integer) + Declare Function code4memExpandBlock Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandData Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandIndex Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandLock Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memExpandTag Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memoCompress Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Integer + Declare Function code4memSizeBlock Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeBuffer Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeMemo Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memSizeMemoExpr Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeSortBuffer Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memSizeSortPool Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memStartBlock Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartData Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartIndex Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartLock Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4memStartMax Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) As Integer + Declare Function code4memStartTag Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errOff Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errOpen Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4optAll Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4optimize Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4optStart Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4optSuspend Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4optimizeWrite Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4ping Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4readLock Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4readOnly Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4errRelate Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4safety Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4singleOpen Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Function code4serverOS Lib "c4dll.dll" (ByVal c4 As Integer) As Integer + Declare Function code4timeout Lib "c4dll.dll" (ByVal c4 As Integer) As Integer + Declare Sub code4timeoutSet Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Integer) + Declare Function code4tranStart Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4tranStatus Lib "c4dll.dll" Alias "code4tranStatusCB" (ByVal c4 As Integer) As Short + Declare Function code4tranCommit Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4tranRollback Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4unlock Lib "c4dll.dll" (ByVal c4 As Integer) As Short + Declare Function code4unlockAuto Lib "c4dll.dll" Alias "code4unlockAutoCB" (ByVal c4 As Integer) As Short + Declare Function code4useGeneralTagsInRelate Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As Short) As Short + Declare Sub code4unlockAutoSet Lib "c4dll.dll" Alias "code4unlockAutoSetCB" (ByVal c4 As Integer, ByVal value As Short) + Declare Sub code4verifySet Lib "c4dll.dll" (ByVal c4 As Integer, ByVal value As String) +#End If + '=============================================================================================== + ' + ' Data File Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Function d4aliasCB Lib "d4dll.dll" Alias "d4alias"(ByVal d4 As Integer) As Integer + Declare Sub d4aliasSet Lib "d4dll.dll" (ByVal d4 As Integer, ByVal AliasValue As String) + Declare Function d4append Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4appendBlank Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4appendStart Lib "d4dll.dll" (ByVal d4 As Integer, ByVal UseMemoEntries As Short) As Short + Declare Sub d4blank Lib "d4dll.dll" (ByVal d4 As Integer) + Declare Function d4bof Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4bottom Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4changed Lib "d4dll.dll" (ByVal d4 As Integer, ByVal intFlag As Short) As Short + Declare Function d4check Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4close Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4codePage Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4createCB Lib "d4dll.dll" Alias "d4create"(ByVal c4 As Integer, ByVal DbfName As String, ByVal fieldinfo As Integer, ByVal tagInfo As Integer) As Integer + Declare Function d4createLow Lib "d4dll.dll" Alias "d4create" (ByVal c4 As Integer, ByVal DbfName As String, ByRef fieldinfo As FIELD4INFOCB, ByRef tagInfo As TAG4INFOCB) As Integer + Declare Function d4createLow Lib "d4dll.dll" Alias "d4create" (ByVal c4 As Integer, ByVal DbfName As String, ByRef fieldinfo As FIELD4INFOCB, Optional ByVal tagInfo As Integer = 0) As Integer + Declare Sub d4delete Lib "d4dll.dll" (ByVal d4 As Integer) + Declare Function d4deleted Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4eof Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4field Lib "d4dll.dll" (ByVal d4 As Integer, ByVal FieldName As String) As Integer + Declare Function d4fieldInfo Lib "d4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4fieldJ Lib "d4dll.dll" (ByVal d4 As Integer, ByVal JField As Short) As Integer + Declare Function d4fieldNumber Lib "d4dll.dll" (ByVal d4 As Integer, ByVal FieldName As String) As Short + Declare Function d4fieldsAddCB Lib "d4dll.dll" Alias "d4fieldsAdd" (ByVal d4 As Integer, ByVal nFields As Short, ByRef fieldinfo As FIELD4INFOCB) As Integer + Declare Function d4fieldsRemoveCB Lib "d4dll.dll" Alias "d4fieldsRemove" (ByRef d4 As Integer, ByVal nFields As Short, ByRef fieldNames As Integer) As Integer + Declare Function d4fileNameCB Lib "d4dll.dll" Alias "d4fileName"(ByVal d4 As Integer) As Integer + Declare Function d4flush Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4freeBlocks Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4goLow Lib "d4dll.dll" (ByVal d4 As Integer, ByVal RecNum As Integer, ByVal goForWrite As Short) As Short + Declare Function d4goBof Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4goEof Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4index Lib "d4dll.dll" (ByVal d4 As Integer, ByVal IndexName As String) As Integer + Declare Function d4log Lib "d4dll.dll" Alias "d4logVB"(ByVal d4 As Integer, ByVal logging As Short) As Short + Declare Function d4lock Lib "d4dll.dll" Alias "d4lockVB"(ByVal d4 As Integer, ByVal recordNum As Integer) As Short + Declare Function d4lockAdd Lib "d4dll.dll" (ByVal d4 As Integer, ByVal recordNum As Integer) As Short + Declare Function d4lockAddAll Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4lockAddAppend Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4lockAddFile Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4lockAll Lib "d4dll.dll" Alias "d4lockAllVB"(ByVal d4 As Integer) As Short + Declare Function d4lockAppend Lib "d4dll.dll" Alias "d4lockAppendVB"(ByVal d4 As Integer) As Short + Declare Function d4lockFile Lib "d4dll.dll" Alias "d4lockFileVB"(ByVal d4 As Integer) As Short + Declare Function d4logStatus Lib "d4dll.dll" Alias "d4logStatusCB"(ByVal d4 As Integer) As Short + Declare Function d4memoCompress Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4numFields Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4open Lib "d4dll.dll" (ByVal c4 As Integer, ByVal DbfName As String) As Integer + Declare Function d4openClone Lib "d4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4optimize Lib "d4dll.dll" Alias "d4optimizeVB"(ByVal d4 As Integer, ByVal OptFlag As Short) As Short + Declare Function d4optimizeWrite Lib "d4dll.dll" Alias "d4optimizeWriteVB"(ByVal d4 As Integer, ByVal OptFlag As Short) As Short + Declare Function d4pack Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4packData Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4position Lib "d4dll.dll" (ByVal d4 As Integer) As Double + Declare Function d4positionSet Lib "d4dll.dll" (ByVal d4 As Integer, ByVal Percentage As Double) As Short + Declare Function d4readBuffer Lib "d4dll.dll" (ByVal d4 As Integer, ByVal numRecsToBuf As Integer, ByVal doMemos As Short) As Integer + Declare Sub d4recall Lib "d4dll.dll" (ByVal d4 As Integer) + Declare Function d4recCount Lib "d4dll.dll" Alias "d4recCountDo"(ByVal d4 As Integer) As Integer + Declare Function d4recNo Lib "d4dll.dll" Alias "d4recNoLow"(ByVal d4 As Integer) As Integer + Declare Function d4record Lib "d4dll.dll" Alias "d4recordLow"(ByVal d4 As Integer) As Integer + Declare Function d4recWidth Lib "d4dll.dll" Alias "d4recWidth_v"(ByVal d4 As Integer) As Integer + Declare Function d4remove Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4refresh Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4refreshRecord Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4reindex Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Delegate Function d4reindexWithProgressDelegate(ByVal percent As Double) As Short + Declare Function d4reindexWithProgress Lib "d4dll.dll" (ByVal d4 As Integer, ByVal callback As d4reindexWithProgressDelegate, ByVal milliseconds As Integer) As Short + Declare Function d4seek Lib "d4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String) As Short + Declare Function d4seekDouble Lib "d4dll.dll" (ByVal d4 As Integer, ByVal value As Double) As Short + Declare Function d4seekN Lib "d4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String, ByVal seekLen As Short) As Short + Declare Function d4seekNext Lib "d4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String) As Short + Declare Function d4seekNextDouble Lib "d4dll.dll" (ByVal d4 As Integer, ByVal seekValue As Double) As Short + Declare Function d4seekNextN Lib "d4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String, ByVal seekLen As Short) As Short + Declare Function d4skip Lib "d4dll.dll" (ByVal d4 As Integer, ByVal NumberRecords As Integer) As Short + Declare Function d4tag Lib "d4dll.dll" (ByVal d4 As Integer, ByVal TagName As String) As Integer + Declare Function d4tagDefault Lib "d4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4tagNext Lib "d4dll.dll" (ByVal d4 As Integer, ByVal TagOn As Integer) As Integer + Declare Function d4tagPrev Lib "d4dll.dll" (ByVal d4 As Integer, ByVal TagOn As Integer) As Integer + Declare Sub d4tagSelect Lib "d4dll.dll" (ByVal d4 As Integer, ByVal tPtr As Integer) + Declare Function d4tagSelected Lib "d4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4tagSync Lib "d4dll.dll" (ByVal d4 As Integer, ByVal tPtr As Integer) As Short + Declare Function d4top Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4unlock Lib "d4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4unlockFiles Lib "d4dll.dll" Alias "code4unlock"(ByVal d4 As Integer) As Short + Declare Function d4write Lib "d4dll.dll" Alias "d4writeVB"(ByVal d4 As Integer, ByVal RecNum As Integer) As Short + Declare Function d4writeBuffer Lib "d4dll.dll" (ByVal r4 As Integer, ByVal numRecs As Integer) As Integer + Declare Function d4zap Lib "d4dll.dll" (ByVal d4 As Integer, ByVal StartRecord As Integer, ByVal EndRecord As Integer) As Short +#Else + Declare Function d4aliasCB Lib "c4dll.dll" Alias "d4alias" (ByVal d4 As Integer) As Integer + Declare Sub d4aliasSet Lib "c4dll.dll" (ByVal d4 As Integer, ByVal AliasValue As String) + Declare Function d4append Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4appendBlank Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4appendStart Lib "c4dll.dll" (ByVal d4 As Integer, ByVal UseMemoEntries As Short) As Short + Declare Sub d4blank Lib "c4dll.dll" (ByVal d4 As Integer) + Declare Function d4bof Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4bottom Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4changed Lib "c4dll.dll" (ByVal d4 As Integer, ByVal intFlag As Short) As Short + Declare Function d4check Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4close Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4codePage Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4compress Lib "c4dll.dll" (ByVal d4 As Integer, ByVal compressedName As String, ByVal blockSize As Short) As Integer + Declare Function d4createCB Lib "c4dll.dll" Alias "d4create" (ByVal c4 As Integer, ByVal DbfName As String, ByVal fieldinfo As Integer, ByVal tagInfo As Integer) As Integer + Declare Function d4createLow Lib "c4dll.dll" Alias "d4create" (ByVal c4 As Integer, ByVal DbfName As String, ByRef fieldinfo As FIELD4INFOCB, ByRef tagInfo As TAG4INFOCB) As Integer + Declare Function d4createLow Lib "c4dll.dll" Alias "d4create" (ByVal c4 As Integer, ByVal DbfName As String, ByRef fieldinfo As FIELD4INFOCB, Optional ByVal tagInfo As Integer = 0) As Integer + Declare Sub d4delete Lib "c4dll.dll" (ByVal d4 As Integer) + Declare Function d4deleted Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4eof Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4field Lib "c4dll.dll" (ByVal d4 As Integer, ByVal FieldName As String) As Integer + Declare Function d4fieldInfo Lib "c4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4fieldJ Lib "c4dll.dll" (ByVal d4 As Integer, ByVal JField As Short) As Integer + Declare Function d4fieldNumber Lib "c4dll.dll" (ByVal d4 As Integer, ByVal FieldName As String) As Short + Declare Function d4fieldsAddCB Lib "c4dll.dll" Alias "d4fieldsAdd" (ByVal d4 As Integer, ByVal nFields As Short, ByRef fieldinfo As FIELD4INFOCB) As Integer + Declare Function d4fieldsRemoveCB Lib "c4dll.dll" Alias "d4fieldsRemove" (ByRef d4 As Integer, ByVal nFields As Short, ByRef fieldNames As Integer) As Integer + Declare Function d4fileNameCB Lib "c4dll.dll" Alias "d4fileName" (ByVal d4 As Integer) As Integer + Declare Function d4flush Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4freeBlocks Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4goLow Lib "c4dll.dll" (ByVal d4 As Integer, ByVal RecNum As Integer, ByVal goForWrite As Short) As Short + Declare Function d4goBof Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4goEof Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4index Lib "c4dll.dll" (ByVal d4 As Integer, ByVal IndexName As String) As Integer + Declare Function d4log Lib "c4dll.dll" Alias "d4logVB" (ByVal d4 As Integer, ByVal logging As Short) As Short + Declare Function d4lock Lib "c4dll.dll" Alias "d4lockVB" (ByVal d4 As Integer, ByVal recordNum As Integer) As Short + Declare Function d4lockAdd Lib "c4dll.dll" (ByVal d4 As Integer, ByVal recordNum As Integer) As Short + Declare Function d4lockAddAll Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4lockAddAppend Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4lockAddFile Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4lockAll Lib "c4dll.dll" Alias "d4lockAllVB" (ByVal d4 As Integer) As Short + Declare Function d4lockAppend Lib "c4dll.dll" Alias "d4lockAppendVB" (ByVal d4 As Integer) As Short + Declare Function d4lockFile Lib "c4dll.dll" Alias "d4lockFileVB" (ByVal d4 As Integer) As Short + Declare Function d4logStatus Lib "c4dll.dll" Alias "d4logStatusCB" (ByVal d4 As Integer) As Short + Declare Function d4memoCompress Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4numFields Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4open Lib "c4dll.dll" (ByVal c4 As Integer, ByVal DbfName As String) As Integer + Declare Function d4openClone Lib "c4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4optimize Lib "c4dll.dll" Alias "d4optimizeVB" (ByVal d4 As Integer, ByVal OptFlag As Short) As Short + Declare Function d4optimizeWrite Lib "c4dll.dll" Alias "d4optimizeWriteVB" (ByVal d4 As Integer, ByVal OptFlag As Short) As Short + Declare Function d4pack Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4packData Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Delegate Function d4packWithProgressDelegate(ByVal percent As Double) As Short + Declare Function d4packWithProgress Lib "c4dll.dll" (ByVal d4 As Integer, ByVal callback As d4packWithProgressDelegate, ByVal milliseconds As Integer) As Short + Declare Function d4position Lib "c4dll.dll" (ByVal d4 As Integer) As Double + Declare Function d4positionSet Lib "c4dll.dll" (ByVal d4 As Integer, ByVal Percentage As Double) As Short + Declare Function d4readBuffer Lib "c4dll.dll" (ByVal d4 As Integer, ByVal numRecsToBuf As Integer, ByVal doMemos As Short) As Integer + Declare Sub d4recall Lib "c4dll.dll" (ByVal d4 As Integer) + Declare Function d4recCount Lib "c4dll.dll" Alias "d4recCountDo" (ByVal d4 As Integer) As Integer + Declare Function d4recNo Lib "c4dll.dll" Alias "d4recNoLow" (ByVal d4 As Integer) As Integer + Declare Function d4record Lib "c4dll.dll" Alias "d4recordLow" (ByVal d4 As Integer) As Integer + Declare Function d4recWidth Lib "c4dll.dll" Alias "d4recWidth_v" (ByVal d4 As Integer) As Integer + Declare Function d4remove Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4refresh Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4refreshRecord Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4reindex Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Delegate Function d4reindexWithProgressDelegate(ByVal percent As Double) As Short + Declare Function d4reindexWithProgress Lib "c4dll.dll" (ByVal d4 As Integer, ByVal callback As d4reindexWithProgressDelegate, ByVal milliseconds As Integer) As Short + Declare Function d4seek Lib "c4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String) As Short + Declare Function d4seekDouble Lib "c4dll.dll" (ByVal d4 As Integer, ByVal value As Double) As Short + Declare Function d4seekN Lib "c4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String, ByVal seekLen As Short) As Short + Declare Function d4seekNext Lib "c4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String) As Short + Declare Function d4seekNextDouble Lib "c4dll.dll" (ByVal d4 As Integer, ByVal seekValue As Double) As Short + Declare Function d4seekNextN Lib "c4dll.dll" (ByVal d4 As Integer, ByVal seekValue As String, ByVal seekLen As Short) As Short + Declare Function d4skip Lib "c4dll.dll" (ByVal d4 As Integer, ByVal NumberRecords As Integer) As Short + Declare Function d4tag Lib "c4dll.dll" (ByVal d4 As Integer, ByVal TagName As String) As Integer + Declare Function d4tagDefault Lib "c4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4tagNext Lib "c4dll.dll" (ByVal d4 As Integer, ByVal TagOn As Integer) As Integer + Declare Function d4tagPrev Lib "c4dll.dll" (ByVal d4 As Integer, ByVal TagOn As Integer) As Integer + Declare Sub d4tagSelect Lib "c4dll.dll" (ByVal d4 As Integer, ByVal tPtr As Integer) + Declare Function d4tagSelected Lib "c4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function d4tagSync Lib "c4dll.dll" (ByVal d4 As Integer, ByVal tPtr As Integer) As Short + Declare Function d4top Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4unlock Lib "c4dll.dll" (ByVal d4 As Integer) As Short + Declare Function d4unlockFiles Lib "c4dll.dll" Alias "code4unlock" (ByVal d4 As Integer) As Short + Declare Function d4write Lib "c4dll.dll" Alias "d4writeVB" (ByVal d4 As Integer, ByVal RecNum As Integer) As Short + Declare Function d4writeBuffer Lib "c4dll.dll" (ByVal r4 As Integer, ByVal numRecs As Integer) As Integer + Declare Function d4zap Lib "c4dll.dll" (ByVal d4 As Integer, ByVal StartRecord As Integer, ByVal EndRecord As Integer) As Short +#End If + + '=============================================================================================== + ' + ' Date Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Sub date4assignLow Lib "d4dll.dll" (ByVal dateForm As String, ByVal julianDay As Integer, ByVal isOle As Short) + Declare Function date4cdowCB Lib "d4dll.dll" Alias "date4cdow"(ByVal dateForm As String) As Integer + Declare Function date4cmonthCB Lib "d4dll.dll" Alias "date4cmonth"(ByVal dateForm As String) As Integer + Declare Function date4day Lib "d4dll.dll" Alias "date4day_v"(ByVal dateForm As String) As Short + Declare Function date4dow Lib "d4dll.dll" (ByVal dateForm As String) As Short + Declare Sub date4formatCB Lib "d4dll.dll" Alias "date4format"(ByVal dateForm As String, ByVal Result As String, ByVal pic As String) + Declare Sub date4initCB Lib "d4dll.dll" Alias "date4init"(ByVal dateForm As String, ByVal value As String, ByVal pic As String) + Declare Function date4isLeap Lib "d4dll.dll" (ByVal dateForm As String) As Short + Declare Function date4long Lib "d4dll.dll" (ByVal dateForm As String) As Integer + Declare Function date4month Lib "d4dll.dll" Alias "date4month_v"(ByVal dateForm As String) As Short + Declare Sub date4timeNow Lib "d4dll.dll" (ByVal TimeForm As String) + Declare Sub date4todayCB Lib "d4dll.dll" Alias "date4today"(ByVal dateForm As String) + Declare Function date4year Lib "d4dll.dll" Alias "date4year_v"(ByVal dateForm As String) As Short +#Else + Declare Sub date4assignLow Lib "c4dll.dll" (ByVal dateForm As String, ByVal julianDay As Integer, ByVal isOle As Short) + Declare Function date4cdowCB Lib "c4dll.dll" Alias "date4cdow" (ByVal dateForm As String) As Integer + Declare Function date4cmonthCB Lib "c4dll.dll" Alias "date4cmonth" (ByVal dateForm As String) As Integer + Declare Function date4day Lib "c4dll.dll" Alias "date4day_v" (ByVal dateForm As String) As Short + Declare Function date4dow Lib "c4dll.dll" (ByVal dateForm As String) As Short + Declare Sub date4formatCB Lib "c4dll.dll" Alias "date4format" (ByVal dateForm As String, ByVal Result As String, ByVal pic As String) + Declare Sub date4initCB Lib "c4dll.dll" Alias "date4init" (ByVal dateForm As String, ByVal value As String, ByVal pic As String) + Declare Function date4isLeap Lib "c4dll.dll" (ByVal dateForm As String) As Short + Declare Function date4long Lib "c4dll.dll" (ByVal dateForm As String) As Integer + Declare Function date4month Lib "c4dll.dll" Alias "date4month_v" (ByVal dateForm As String) As Short + Declare Sub date4timeNow Lib "c4dll.dll" (ByVal TimeForm As String) + Declare Sub date4todayCB Lib "c4dll.dll" Alias "date4today" (ByVal dateForm As String) + Declare Function date4year Lib "c4dll.dll" Alias "date4year_v" (ByVal dateForm As String) As Short +#End If + + '=============================================================================================== + ' + ' Error Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Function error4 Lib "d4dll.dll" Alias "error4VB"(ByVal c4 As Integer, ByVal errCode As Short, ByVal extraInfo As Integer) As Short + Declare Sub error4exitTest Lib "d4dll.dll" (ByVal c4 As Integer) + Declare Function error4describe Lib "d4dll.dll" Alias "error4describeVB"(ByVal c4 As Integer, ByVal errCode As Short, ByVal extraInfo As Integer, ByVal desc1 As String, ByVal desc2 As String, ByVal desc3 As String) As Short + Declare Function error4file Lib "d4dll.dll" (ByVal c4 As Integer, ByVal fileName As String, ByVal overwrite As Short) As Short + Declare Function error4lastDescription Lib "d4dll.dll" (ByVal c4 As Integer) As String + Declare Function error4set Lib "d4dll.dll" (ByVal c4 As Integer, ByVal errCode As Short) As Short + Declare Function error4textCB Lib "d4dll.dll" Alias "error4text"(ByVal c4 As Integer, ByVal errCode As Integer) As Integer +#Else + Declare Function error4 Lib "c4dll.dll" Alias "error4VB" (ByVal c4 As Integer, ByVal errCode As Short, ByVal extraInfo As Integer) As Short + Declare Sub error4exitTest Lib "c4dll.dll" (ByVal c4 As Integer) + Declare Function error4describe Lib "c4dll.dll" Alias "error4describeVB" (ByVal c4 As Integer, ByVal errCode As Short, ByVal extraInfo As Integer, ByVal desc1 As String, ByVal desc2 As String, ByVal desc3 As String) As Short + Declare Function error4file Lib "c4dll.dll" (ByVal c4 As Integer, ByVal fileName As String, ByVal overwrite As Short) As Short + Declare Function error4lastDescription Lib "c4dll.dll" (ByVal c4 As Integer) As String + Declare Function error4set Lib "c4dll.dll" (ByVal c4 As Integer, ByVal errCode As Short) As Short + Declare Function error4textCB Lib "c4dll.dll" Alias "error4text" (ByVal c4 As Integer, ByVal errCode As Integer) As Integer +#End If + + '=============================================================================================== + ' + ' Expression Evaluation Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Function expr4data Lib "d4dll.dll" Alias "expr4dataCB"(ByVal exprPtr As Integer) As Integer + Declare Function expr4double Lib "d4dll.dll" (ByVal exprPtr As Integer) As Double + Declare Sub expr4free Lib "d4dll.dll" Alias "expr4freeCB"(ByVal exprPtr As Integer) + Declare Function expr4len Lib "d4dll.dll" Alias "expr4lenCB"(ByVal exprPtr As Integer) As Integer + Declare Function expr4nullLow Lib "d4dll.dll" (ByVal exprPtr As Integer, ByVal forAdd As Short) As Short + Declare Function expr4parse Lib "d4dll.dll" Alias "expr4parseCB"(ByVal d4 As Integer, ByVal expression As String) As Integer + Declare Function expr4sourceCB Lib "d4dll.dll" Alias "expr4source"(ByVal exprPtr As Integer) As Integer + Declare Function expr4strCB Lib "d4dll.dll" Alias "expr4str"(ByVal exprPtr As Integer) As Integer + Declare Function expr4true Lib "d4dll.dll" (ByVal exprPtr As Integer) As Short + Declare Function expr4typeCB Lib "d4dll.dll" (ByVal exprPtr As Integer) As Short +#Else + Declare Function expr4data Lib "c4dll.dll" Alias "expr4dataCB" (ByVal exprPtr As Integer) As Integer + Declare Function expr4double Lib "c4dll.dll" (ByVal exprPtr As Integer) As Double + Declare Sub expr4free Lib "c4dll.dll" Alias "expr4freeCB" (ByVal exprPtr As Integer) + Declare Function expr4len Lib "c4dll.dll" Alias "expr4lenCB" (ByVal exprPtr As Integer) As Integer + Declare Function expr4nullLow Lib "c4dll.dll" (ByVal exprPtr As Integer, ByVal forAdd As Short) As Short + Declare Function expr4parse Lib "c4dll.dll" Alias "expr4parseCB" (ByVal d4 As Integer, ByVal expression As String) As Integer + Declare Function expr4sourceCB Lib "c4dll.dll" Alias "expr4source" (ByVal exprPtr As Integer) As Integer + Declare Function expr4strCB Lib "c4dll.dll" Alias "expr4str" (ByVal exprPtr As Integer) As Integer + Declare Function expr4true Lib "c4dll.dll" (ByVal exprPtr As Integer) As Short + Declare Function expr4typeCB Lib "c4dll.dll" (ByVal exprPtr As Integer) As Short +#End If + + '=============================================================================================== + ' + ' Field Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Sub f4assignBinaryVB Lib "d4dll.dll" Alias "f4assignN"(ByVal fPtr As Integer, ByRef value As Byte, ByVal length As Short) + Declare Sub f4assignChar Lib "d4dll.dll" Alias "f4assignCharVB"(ByVal fPtr As Integer, ByVal Char_Renamed As Short) + Declare Sub f4assignCurrency Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal value As String) + Declare Sub f4assignDateTime Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal value As String) + Declare Sub f4assignDouble Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal value As Double) + Declare Sub f4assignField Lib "d4dll.dll" (ByVal fPtrTo As Integer, ByVal fPtrFrom As Integer) + Declare Sub f4assignIntVB Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal value As Short) + Declare Sub f4assignLong Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal value As Integer) + Declare Sub f4assignN Lib "d4dll.dll" Alias "f4assignNVB"(ByVal fPtr As Integer, ByVal value As String, ByVal length As Short) + Declare Sub f4assignNull Lib "d4dll.dll" (ByVal fPtr As Integer) + Declare Sub f4assignUnicodeVB Lib "d4dll.dll" Alias "f4assignUnicode" (ByVal fPtr As Integer, ByRef value As Byte) + Declare Sub f4blank Lib "d4dll.dll" (ByVal fPtr As Integer) + Declare Function f4char Lib "d4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4currencyCB Lib "d4dll.dll" Alias "f4currency"(ByVal fPtr As Integer, ByVal numDec As Short) As Integer + Declare Function f4data Lib "d4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4dateTimeCB Lib "d4dll.dll" Alias "f4dateTime"(ByVal fPtr As Integer) As Integer + Declare Function f4decimals Lib "d4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4double Lib "d4dll.dll" (ByVal fPtr As Integer) As Double + Declare Function f4int Lib "d4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4len Lib "d4dll.dll" Alias "f4len_v"(ByVal fPtr As Integer) As Short + Declare Function f4long Lib "d4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4memoAssign Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal value As String) As Short + Declare Function f4memoAssignBinaryVB Lib "d4dll.dll" Alias "f4memoAssignNVB" (ByVal fPtr As Integer, ByRef value As Byte, ByVal length As Short) As Short + Declare Function f4memoAssignN Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal value As String, ByVal length As Integer) As Short + Declare Sub f4memoAssignUnicodeVB Lib "d4dll.dll" Alias "f4memoAssignUnicode" (ByVal fPtr As Integer, ByRef value As String) + Declare Sub f4memoFree Lib "d4dll.dll" (ByVal fPtr As Integer) + Declare Function f4memoLen Lib "d4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4memoNcpy Lib "d4dll.dll" (ByVal fPtr As Integer, ByVal memPtr As String, ByVal memLen As Short) As Short + Declare Function f4memoNcpyBinary Lib "d4dll.dll" Alias "f4memoNcpy" (ByVal fPtr As Integer, ByRef memPtr As Byte, ByVal memLen As Short) As Short + Declare Function f4memoPtr Lib "d4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4nameCB Lib "d4dll.dll" Alias "f4name"(ByVal fPtr As Integer) As Integer + Declare Function f4ncpyBinary Lib "d4dll.dll" Alias "f4ncpy" (ByVal fPtr As Integer, ByRef memPtr As Byte, ByVal memLength As Short) As Short + Declare Function f4ncpyCB Lib "d4dll.dll" Alias "f4ncpy"(ByVal fPtr As Integer, ByVal memPtr As String, ByVal memLength As Short) As Short + Declare Function f4number Lib "d4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4null Lib "d4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4ptr Lib "d4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4strCB Lib "d4dll.dll" Alias "f4str"(ByVal fPtr As Integer) As Integer + Declare Function f4true Lib "d4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4type Lib "d4dll.dll" (ByVal fPtr As Integer) As Short +#Else + Declare Sub f4assignBinaryVB Lib "c4dll.dll" Alias "f4assignN" (ByVal fPtr As Integer, ByRef value As Byte, ByVal length As Short) + Declare Sub f4assignChar Lib "c4dll.dll" Alias "f4assignCharVB" (ByVal fPtr As Integer, ByVal Char_Renamed As Short) + Declare Sub f4assignCurrency Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal value As String) + Declare Sub f4assignDateTime Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal value As String) + Declare Sub f4assignDouble Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal value As Double) + Declare Sub f4assignField Lib "c4dll.dll" (ByVal fPtrTo As Integer, ByVal fPtrFrom As Integer) + Declare Sub f4assignIntVB Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal value As Short) + Declare Sub f4assignLong Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal value As Integer) + Declare Sub f4assignN Lib "c4dll.dll" Alias "f4assignNVB" (ByVal fPtr As Integer, ByVal value As String, ByVal length As Short) + Declare Sub f4assignNull Lib "c4dll.dll" (ByVal fPtr As Integer) + Declare Sub f4assignUnicodeVB Lib "c4dll.dll" Alias "f4assignUnicode" (ByVal fPtr As Integer, ByRef value As Byte) + Declare Sub f4blank Lib "c4dll.dll" (ByVal fPtr As Integer) + Declare Function f4char Lib "c4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4currencyCB Lib "c4dll.dll" Alias "f4currency" (ByVal fPtr As Integer, ByVal numDec As Short) As Integer + Declare Function f4data Lib "c4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4dateTimeCB Lib "c4dll.dll" Alias "f4dateTime" (ByVal fPtr As Integer) As Integer + Declare Function f4decimals Lib "c4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4double Lib "c4dll.dll" (ByVal fPtr As Integer) As Double + Declare Function f4int Lib "c4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4len Lib "c4dll.dll" Alias "f4len_v" (ByVal fPtr As Integer) As Short + Declare Function f4long Lib "c4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4memoAssign Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal value As String) As Short + Declare Function f4memoAssignBinaryVB Lib "c4dll.dll" Alias "f4memoAssignNVB" (ByVal fPtr As Integer, ByRef value As Byte, ByVal length As Short) As Short + Declare Function f4memoAssignN Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal value As String, ByVal length As Integer) As Short + Declare Sub f4memoAssignUnicodeVB Lib "c4dll.dll" Alias "f4memoAssignUnicode" (ByVal fPtr As Integer, ByRef value As String) + Declare Sub f4memoFree Lib "c4dll.dll" (ByVal fPtr As Integer) + Declare Function f4memoLen Lib "c4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4memoNcpy Lib "c4dll.dll" (ByVal fPtr As Integer, ByVal memPtr As String, ByVal memLen As Short) As Short + Declare Function f4memoNcpyBinary Lib "c4dll.dll" Alias "f4memoNcpy" (ByVal fPtr As Integer, ByRef memPtr As Byte, ByVal memLen As Short) As Short + Declare Function f4memoPtr Lib "c4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4nameCB Lib "c4dll.dll" Alias "f4name" (ByVal fPtr As Integer) As Integer + Declare Function f4ncpyBinary Lib "c4dll.dll" Alias "f4ncpy" (ByVal fPtr As Integer, ByRef memPtr As Byte, ByVal memLength As Short) As Short + Declare Function f4ncpyCB Lib "c4dll.dll" Alias "f4ncpy" (ByVal fPtr As Integer, ByVal memPtr As String, ByVal memLength As Short) As Short + Declare Function f4number Lib "c4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4null Lib "c4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4ptr Lib "c4dll.dll" (ByVal fPtr As Integer) As Integer + Declare Function f4strCB Lib "c4dll.dll" Alias "f4str" (ByVal fPtr As Integer) As Integer + Declare Function f4true Lib "c4dll.dll" (ByVal fPtr As Integer) As Short + Declare Function f4type Lib "c4dll.dll" (ByVal fPtr As Integer) As Short +#End If + + '=============================================================================================== + ' + ' Index Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Function i4close Lib "d4dll.dll" (ByVal i4 As Integer) As Short + Declare Function i4createCB Lib "d4dll.dll" Alias "i4create"(ByVal d4 As Integer, ByVal fileName As String, ByRef tagInfo As TAG4INFOCB) As Integer + Declare Function i4fileNameCB Lib "d4dll.dll" Alias "i4fileName"(ByVal i4 As Integer) As Integer + Declare Function i4openCB Lib "d4dll.dll" Alias "i4open" (ByVal d4 As Integer, ByVal fileName As String) As Integer + Declare Function i4reindex Lib "d4dll.dll" (ByVal i4 As Integer) As Short + Declare Function i4tag Lib "d4dll.dll" (ByVal i4 As Integer, ByVal fileName As String) As Integer + Declare Function i4tagInfo Lib "d4dll.dll" (ByVal i4 As Integer) As Integer + Declare Function i4tagAddCB Lib "d4dll.dll" Alias "i4tagAdd"(ByVal i4 As Integer, ByRef tagInfo As TAG4INFOCB) As Short + Declare Function i4tagRemove Lib "d4dll.dll" (ByVal t4 As Integer) As Short +#Else + Declare Function i4close Lib "c4dll.dll" (ByVal i4 As Integer) As Short + Declare Function i4createCB Lib "c4dll.dll" Alias "i4create" (ByVal d4 As Integer, ByVal fileName As String, ByRef tagInfo As TAG4INFOCB) As Integer + Declare Function i4fileNameCB Lib "c4dll.dll" Alias "i4fileName" (ByVal i4 As Integer) As Integer + Declare Function i4openCB Lib "c4dll.dll" Alias "i4open" (ByVal d4 As Integer, ByVal fileName As String) As Integer + Declare Function i4reindex Lib "c4dll.dll" (ByVal i4 As Integer) As Short + Declare Function i4tag Lib "c4dll.dll" (ByVal i4 As Integer, ByVal fileName As String) As Integer + Declare Function i4tagInfo Lib "c4dll.dll" (ByVal i4 As Integer) As Integer + Declare Function i4tagAddCB Lib "c4dll.dll" Alias "i4tagAdd" (ByVal i4 As Integer, ByRef tagInfo As TAG4INFOCB) As Short + Declare Function i4tagRemove Lib "c4dll.dll" (ByVal t4 As Integer) As Short +#End If + + '=============================================================================================== + ' + ' Relate Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Function relate4bottom Lib "d4dll.dll" (ByVal r4 As Integer) As Short + Declare Sub relate4changed Lib "d4dll.dll" (ByVal r4 As Integer) + Declare Function relate4createSlave Lib "d4dll.dll" (ByVal r4 As Integer, ByVal d4 As Integer, ByVal mExpr As String, ByVal t4 As Integer) As Integer + Declare Function relate4count Lib "d4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function relate4data Lib "d4dll.dll" Alias "relate4dataCB"(ByVal r4 As Integer) As Integer + Declare Function relate4dataTag Lib "d4dll.dll" Alias "relate4dataTagCB"(ByVal r4 As Integer) As Integer + Declare Function relate4doAll Lib "d4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4doOne Lib "d4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4eof Lib "d4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4errorAction Lib "d4dll.dll" Alias "relate4errorActionVB"(ByVal r4 As Integer, ByVal ErrAction As Short) As Short + Declare Function relate4free Lib "d4dll.dll" Alias "relate4freeVB"(ByVal r4 As Integer, ByVal CloseFlag As Short) As Short + Declare Function relate4init Lib "d4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function relate4lockAdd Lib "d4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4master Lib "d4dll.dll" Alias "relate4masterCB"(ByVal r4 As Integer) As Integer + Declare Function relate4masterExprCB Lib "d4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function relate4matchLen Lib "d4dll.dll" Alias "relate4matchLenVB"(ByVal r4 As Integer, ByVal length As Short) As Short + Declare Function relate4next Lib "d4dll.dll" (ByRef r4 As Integer) As Short + Declare Function relate4optimizeable Lib "d4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4querySet Lib "d4dll.dll" (ByVal r4 As Integer, ByVal expr As String) As Short + Declare Function relate4readBuffer Lib "d4dll.dll" (ByVal r4 As Integer, ByVal numRecsToBuf As Integer, ByVal doMemos As Short) As Integer + Declare Function relate4retain Lib "d4dll.dll" (ByVal r4 As Integer, ByVal value As Short) As Short + Declare Function relate4retrieve Lib "d4dll.dll" (ByVal c4 As Integer, ByVal fileName As String, ByVal openFiles As Short, ByVal dataPathName As String) As Integer + Declare Function relate4save Lib "d4dll.dll" (ByVal rel4 As Integer, ByVal fileName As String, ByVal savePathNames As Short) As Short + Declare Function relate4skip Lib "d4dll.dll" (ByVal r4 As Integer, ByVal NumRecs As Integer) As Short + Declare Function relate4skipEnable Lib "d4dll.dll" Alias "relate4skipEnableVB" (ByVal r4 As Integer, ByVal DoEnable As Short) As Short + Declare Function relate4skipMaster Lib "d4dll.dll" (ByVal r4 As Integer, ByVal numSkip As Integer) As Short + Declare Function relate4sortSet Lib "d4dll.dll" (ByVal r4 As Integer, ByVal expr As String) As Short + Declare Function relate4top Lib "d4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4topMaster Lib "d4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function relate4type Lib "d4dll.dll" Alias "relate4typeVB" (ByVal r4 As Integer, ByVal rType As Short) As Short +#Else + Declare Function relate4bottom Lib "c4dll.dll" (ByVal r4 As Integer) As Short + Declare Sub relate4changed Lib "c4dll.dll" (ByVal r4 As Integer) + Declare Function relate4createSlave Lib "c4dll.dll" (ByVal r4 As Integer, ByVal d4 As Integer, ByVal mExpr As String, ByVal t4 As Integer) As Integer + Declare Function relate4count Lib "c4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function relate4data Lib "c4dll.dll" Alias "relate4dataCB" (ByVal r4 As Integer) As Integer + Declare Function relate4dataTag Lib "c4dll.dll" Alias "relate4dataTagCB" (ByVal r4 As Integer) As Integer + Declare Function relate4doAll Lib "c4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4doOne Lib "c4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4eof Lib "c4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4errorAction Lib "c4dll.dll" Alias "relate4errorActionVB" (ByVal r4 As Integer, ByVal ErrAction As Short) As Short + Declare Function relate4free Lib "c4dll.dll" Alias "relate4freeVB" (ByVal r4 As Integer, ByVal CloseFlag As Short) As Short + Declare Function relate4init Lib "c4dll.dll" (ByVal d4 As Integer) As Integer + Declare Function relate4lockAdd Lib "c4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4master Lib "c4dll.dll" Alias "relate4masterCB" (ByVal r4 As Integer) As Integer + Declare Function relate4masterExprCB Lib "c4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function relate4matchLen Lib "c4dll.dll" Alias "relate4matchLenVB" (ByVal r4 As Integer, ByVal length As Short) As Short + Declare Function relate4next Lib "c4dll.dll" (ByRef r4 As Integer) As Short + Declare Function relate4optimizeable Lib "c4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4querySet Lib "c4dll.dll" (ByVal r4 As Integer, ByVal expr As String) As Short + Declare Function relate4readBuffer Lib "c4dll.dll" (ByVal r4 As Integer, ByVal numRecsToBuf As Integer, ByVal doMemos As Short) As Integer + Declare Function relate4retain Lib "c4dll.dll" (ByVal r4 As Integer, ByVal value As Short) As Short + Declare Function relate4retrieve Lib "c4dll.dll" (ByVal c4 As Integer, ByVal fileName As String, ByVal openFiles As Short, ByVal dataPathName As String) As Integer + Declare Function relate4save Lib "c4dll.dll" (ByVal rel4 As Integer, ByVal fileName As String, ByVal savePathNames As Short) As Short + Declare Function relate4skip Lib "c4dll.dll" (ByVal r4 As Integer, ByVal NumRecs As Integer) As Short + Declare Function relate4skipEnable Lib "c4dll.dll" Alias "relate4skipEnableVB" (ByVal r4 As Integer, ByVal DoEnable As Short) As Short + Declare Function relate4skipMaster Lib "c4dll.dll" (ByVal r4 As Integer, ByVal numSkip As Integer) As Short + Declare Function relate4sortSet Lib "c4dll.dll" (ByVal r4 As Integer, ByVal expr As String) As Short + Declare Function relate4top Lib "c4dll.dll" (ByVal r4 As Integer) As Short + Declare Function relate4topMaster Lib "c4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function relate4type Lib "c4dll.dll" Alias "relate4typeVB" (ByVal r4 As Integer, ByVal rType As Short) As Short +#End If + + '=============================================================================================== + ' + ' Report function prototypes + ' + '================================================================================================ +#If USE_D4DLL Then + Declare Function report4caption Lib "d4dll.dll" (ByVal r4 As Integer, ByVal caption As String) As Short + Declare Function report4currency Lib "d4dll.dll" (ByVal r4 As Integer, ByVal currncy As String) As Short + Declare Function report4dateFormat Lib "d4dll.dll" (ByVal r4 As Integer, ByVal dateFmt As String) As Short + Declare Function report4decimal Lib "d4dll.dll" Alias "report4decimal_v"(ByVal r4 As Integer, ByVal decChar As String) As Short + Declare Function report4do Lib "d4dll.dll" Alias "report4doCB"(ByVal r4 As Integer) As Short + Declare Sub report4freeLow Lib "d4dll.dll" (ByVal r4 As Integer, ByVal freeRelate As Short, ByVal closeFiles As Short, ByVal doPrinterFree As Short) + Declare Function report4margins Lib "d4dll.dll" (ByVal r4 As Integer, ByVal mLeft As Integer, ByVal mRight As Integer, ByVal mTop As Integer, ByVal mBottom As Integer, ByVal uType As Short) As Short + Declare Function report4pageSize Lib "d4dll.dll" (ByVal r4 As Integer, ByVal pHeight As Integer, ByVal pWidth As Integer, ByVal uType As Short) As Short + Declare Function report4parent32 Lib "d4dll.dll" Alias "report4parent" (ByVal r4 As Integer, ByVal hWnd As IntPtr) As Short + Declare Sub report4printerSelect Lib "d4dll.dll" (ByVal r4 As Integer) + Declare Function report4querySet Lib "d4dll.dll" (ByVal r4 As Integer, ByVal queryExpr As String) As Short + Declare Function report4relate Lib "d4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function report4retrieve Lib "d4dll.dll" (ByVal c4 As Integer, ByVal fileName As String, ByVal openFiles As Short, ByVal dataPath As String) As Integer + Declare Function report4save Lib "d4dll.dll" (ByVal r4 As Integer, ByVal fileName As String, ByVal savePaths As Short) As Short + Declare Function report4screenBreaks Lib "d4dll.dll" (ByVal r4 As Integer, ByVal value As Short) As Short + Declare Function report4separator Lib "d4dll.dll" Alias "report4separator_v"(ByVal r4 As Integer, ByVal separator As String) As Short + Declare Function report4sortSet Lib "d4dll.dll" (ByVal r4 As Integer, ByVal sortExpr As String) As Short + Declare Function report4toScreen Lib "d4dll.dll" (ByVal r4 As Integer, ByVal toScreen As Short) As Short +#Else + Declare Function report4caption Lib "c4dll.dll" (ByVal r4 As Integer, ByVal caption As String) As Short + Declare Function report4currency Lib "c4dll.dll" (ByVal r4 As Integer, ByVal currncy As String) As Short + Declare Function report4dateFormat Lib "c4dll.dll" (ByVal r4 As Integer, ByVal dateFmt As String) As Short + Declare Function report4decimal Lib "c4dll.dll" Alias "report4decimal_v" (ByVal r4 As Integer, ByVal decChar As String) As Short + Declare Function report4do Lib "c4dll.dll" Alias "report4doCB" (ByVal r4 As Integer) As Short + Declare Sub report4freeLow Lib "c4dll.dll" (ByVal r4 As Integer, ByVal freeRelate As Short, ByVal closeFiles As Short, ByVal doPrinterFree As Short) + Declare Function report4margins Lib "c4dll.dll" (ByVal r4 As Integer, ByVal mLeft As Integer, ByVal mRight As Integer, ByVal mTop As Integer, ByVal mBottom As Integer, ByVal uType As Short) As Short + Declare Function report4pageSize Lib "c4dll.dll" (ByVal r4 As Integer, ByVal pHeight As Integer, ByVal pWidth As Integer, ByVal uType As Short) As Short + Declare Function report4parent32 Lib "c4dll.dll" Alias "report4parent" (ByVal r4 As Integer, ByVal hWnd As IntPtr) As Short + Declare Sub report4printerSelect Lib "c4dll.dll" (ByVal r4 As Integer) + Declare Function report4querySet Lib "c4dll.dll" (ByVal r4 As Integer, ByVal queryExpr As String) As Short + Declare Function report4relate Lib "c4dll.dll" (ByVal r4 As Integer) As Integer + Declare Function report4retrieve Lib "c4dll.dll" (ByVal c4 As Integer, ByVal fileName As String, ByVal openFiles As Short, ByVal dataPath As String) As Integer + Declare Function report4save Lib "c4dll.dll" (ByVal r4 As Integer, ByVal fileName As String, ByVal savePaths As Short) As Short + Declare Function report4screenBreaks Lib "c4dll.dll" (ByVal r4 As Integer, ByVal value As Short) As Short + Declare Function report4separator Lib "c4dll.dll" Alias "report4separator_v" (ByVal r4 As Integer, ByVal separator As String) As Short + Declare Function report4sortSet Lib "c4dll.dll" (ByVal r4 As Integer, ByVal sortExpr As String) As Short + Declare Function report4toScreen Lib "c4dll.dll" (ByVal r4 As Integer, ByVal toScreen As Short) As Short +#End If + + '=============================================================================================== + ' + ' Tag Functions' Prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Function t4aliasCB Lib "d4dll.dll" Alias "t4alias"(ByVal t4 As Integer) As Integer + Declare Function t4close Lib "d4dll.dll" (ByVal t4 As Integer) As Short + Declare Function t4descending Lib "d4dll.dll" Alias "tfile4isDescending"(ByVal t4 As Integer) As Short + Declare Function t4exprCB Lib "d4dll.dll" (ByVal t4 As Integer) As Integer + Declare Function t4filterCB Lib "d4dll.dll" (ByVal t4 As Integer) As Integer + Declare Function t4open Lib "d4dll.dll" Alias "t4openCB" (ByVal dbPtr As Integer, ByVal IndexName As String) As Integer + Declare Function t4seekN Lib "d4dll.dll" (ByVal t4 As Integer, ByVal seekValue As String, ByVal inputKeyLen As Short, ByVal doDataPosition As Short) As Short + Declare Function t4unique Lib "d4dll.dll" (ByVal t4 As Integer) As Short + Declare Function t4uniqueSet Lib "d4dll.dll" Alias "t4uniqueSetVB"(ByVal t4 As Integer, ByVal value As Short) As Short +#Else + Declare Function t4aliasCB Lib "c4dll.dll" Alias "t4alias" (ByVal t4 As Integer) As Integer + Declare Function t4close Lib "c4dll.dll" (ByVal t4 As Integer) As Short + Declare Function t4descending Lib "c4dll.dll" Alias "tfile4isDescending" (ByVal t4 As Integer) As Short + Declare Function t4exprCB Lib "c4dll.dll" (ByVal t4 As Integer) As Integer + Declare Function t4filterCB Lib "c4dll.dll" (ByVal t4 As Integer) As Integer + Declare Function t4open Lib "c4dll.dll" Alias "t4openCB" (ByVal dbPtr As Integer, ByVal IndexName As String) As Integer + Declare Function t4seekN Lib "c4dll.dll" (ByVal t4 As Integer, ByVal seekValue As String, ByVal inputKeyLen As Short, ByVal doDataPosition As Short) As Short + Declare Function t4unique Lib "c4dll.dll" (ByVal t4 As Integer) As Short + Declare Function t4uniqueSet Lib "c4dll.dll" Alias "t4uniqueSetVB" (ByVal t4 As Integer, ByVal value As Short) As Short +#End If + + '======================================================================================= + ' + ' Utility function prototypes + ' + '----------------------------------------------------------------------------------------------- +#If USE_D4DLL Then + Declare Function u4alloc Lib "d4dll.dll" Alias "u4allocDefault"(ByVal amt As Integer) As Integer + Declare Function u4allocFree Lib "d4dll.dll" Alias "u4allocFreeDefault"(ByVal c4 As Integer, ByVal amt As Integer) As Integer + Declare Sub u4free Lib "d4dll.dll" Alias "u4freeDefault"(ByVal memPtr As Integer) + + '16-Bit versions + Declare Function u4ncpy Lib "d4dll.dll" (ByVal MemPtr1 As String, ByVal memptr2 As Integer, ByVal memLength As Short) As Short + Declare Function u4ncpy2 Lib "d4dll.dll" Alias "u4ncpy"(ByVal MemPtr1 As Integer, ByVal memptr2 As String, ByVal memLength As Short) As Short + + '32-Bit versions + 'Declare Function u4ncpy& Lib "d4dll.dll" (ByVal MemPtr1$, ByVal memptr2&, ByVal memLength&) + 'Declare Function u4ncpy2& Lib "d4dll.dll" Alias "u4ncpy" (ByVal MemPtr1&, ByVal memptr2$, ByVal memLength&) + + Declare Sub u4memCpy Lib "d4dll.dll" (ByVal dest As String, ByVal source As Integer, ByVal numCopy As Integer) + Declare Function u4switch Lib "d4dll.dll" () As Integer +#Else + Declare Function u4alloc Lib "c4dll.dll" Alias "u4allocDefault" (ByVal amt As Integer) As Integer + Declare Function u4allocFree Lib "c4dll.dll" Alias "u4allocFreeDefault" (ByVal c4 As Integer, ByVal amt As Integer) As Integer + Declare Sub u4free Lib "c4dll.dll" Alias "u4freeDefault" (ByVal memPtr As Integer) + + '16-Bit versions + Declare Function u4ncpy Lib "c4dll.dll" (ByVal MemPtr1 As String, ByVal memptr2 As Integer, ByVal memLength As Short) As Short + Declare Function u4ncpy2 Lib "c4dll.dll" Alias "u4ncpy" (ByVal MemPtr1 As Integer, ByVal memptr2 As String, ByVal memLength As Short) As Short + + '32-Bit versions + 'Declare Function u4ncpy& Lib "c4dll.dll" (ByVal MemPtr1$, ByVal memptr2&, ByVal memLength&) + 'Declare Function u4ncpy2& Lib "c4dll.dll" Alias "u4ncpy" (ByVal MemPtr1&, ByVal memptr2$, ByVal memLength&) + + Declare Sub u4memCpy Lib "c4dll.dll" (ByVal dest As String, ByVal source As Integer, ByVal numCopy As Integer) + Declare Function u4switch Lib "c4dll.dll" () As Integer +#End If + '======================================================================================= + ' + ' Misc. function prototypes + ' + '======================================================================================== +#If USE_D4DLL Then + Declare Function v4Cstring Lib "d4dll.dll" (ByVal s As String) As Integer + Declare Sub v4Cstringfree Lib "d4dll.dll" (ByVal s As Integer) +#Else + Declare Function v4Cstring Lib "c4dll.dll" (ByVal s As String) As Integer + Declare Sub v4Cstringfree Lib "c4dll.dll" (ByVal s As Integer) +#End If + + Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal dest As String, ByVal src As String) As Integer + + 'CodeBase Return Code Constants + + Public Const r4success As Short = 0 + Public Const r4same As Short = 0 + Public Const r4found As Short = 1 + Public Const r4down As Short = 1 + Public Const r4after As Short = 2 + Public Const r4complete As Short = 2 + Public Const r4eof As Short = 3 + Public Const r4bof As Short = 4 + Public Const r4entry As Short = 5 + Public Const r4descending As Short = 10 + Public Const r4unique As Short = 20 + Public Const r4uniqueContinue As Short = 25 + Public Const r4locked As Short = 50 + Public Const r4noCreate As Short = 60 + Public Const r4noOpen As Short = 70 + Public Const r4notag As Short = 80 + Public Const r4terminate As Short = 90 + Public Const r4inactive As Short = 110 + Public Const r4active As Short = 120 + Public Const r4authorize As Short = 140 + Public Const r4connected As Short = 150 + Public Const r4logOpen As Short = 170 + Public Const r4logOff As Short = 180 + Public Const r4null As Short = 190 + Public Const r4timeout As Short = 225 + + Public Const relate4filterRecord As Short = 101 + Public Const relate4doRemove As Short = 102 + Public Const relate4skipped As Short = 104 + Public Const relate4blank As Short = 105 + Public Const relate4skipRec As Short = 106 + Public Const relate4terminate As Short = 107 + Public Const relate4exact As Short = 108 + Public Const relate4scan As Short = 109 + Public Const relate4approx As Short = 110 + Public Const relate4sortSkip As Short = 120 + Public Const relate4sortDone As Short = 121 + + 'CodeBasic Field Definition Constants + Public Const r4logLen As Short = 1 + Public Const r4dateLen As Short = 8 + Public Const r4memoLen As Short = 10 + Public Const r4bin As String = "B" ' Binary + Public Const r4str As String = "C" ' Character + Public Const r4charBin As String = "Z" ' Character (binary) + Public Const r4currency As String = "Y" ' Currency + Public Const r4date As String = "D" ' Date + Public Const r4dateTime As String = "T" ' DateTime + Public Const r4double As String = "B" ' Double + Public Const r4float As String = "F" ' Float + Public Const r4gen As String = "G" ' General + Public Const r4int As String = "I" ' Integer + Public Const r4log As String = "L" ' Logical + Public Const r4memo As String = "M" ' Memo + Public Const r4memoBin As String = "X" ' Memo (binary) + Public Const r4num As String = "N" ' Numeric + Public Const r4dateDoub As String = "d" ' Date as Double + Public Const r4numDoub As String = "n" ' Numeric as Double + Public Const r4unicode As String = "W" ' Unicode character (same as r5wstr) + + Public Const r4system As String = "0" ' used by FoxPro for null field value field + Public Const r5wstrLen As String = "O" + Public Const r5ui4 As String = "P" + Public Const r5i2 As String = "Q" + Public Const r5ui2 As String = "R" + Public Const r5guid As String = "V" + Public Const r5wstr As String = "W" + Public Const r5i8 As String = "1" ' 8-byte long signed value (LONGLONG) + Public Const r5dbDate As String = "2" ' struct DBDATE (6 bytes) + Public Const r5dbTime As String = "3" ' struct DBTIME (6 bytes) + Public Const r5dbTimeStamp As String = "4" ' struct DBTIMESTAMP (16 bytes) + Public Const r5date As String = "5" + + 'Other CodeBase Constants + Public Const cp0 As Short = 0 'code4.codePage constant + Public Const cp437 As Short = 1 + Public Const cp850 As Short = 2 ' LY Jun 24/04 + Public Const cp1252 As Short = 3 + Public Const LOCK4OFF As Short = 0 + Public Const LOCK4ALL As Short = 1 + Public Const LOCK4DATA As Short = 2 + Public Const LOG4TRANS As Short = 0 + Public Const LOG4ON As Short = 1 + Public Const LOG4ALWAYS As Short = 2 + Public Const OPEN4DENY_NONE As Short = 0 + Public Const OPEN4DENY_RW As Short = 1 + Public Const OPEN4DENY_WRITE As Short = 2 + Public Const OPT4EXCLUSIVE As Short = -1 + Public Const OPT4OFF As Short = 0 + Public Const OPT4ALL As Short = 1 + Public Const r4check As Short = -5 + Public Const r4maxVBStringLen As Integer = 65500 + Public Const r4maxVBStrFunction As Short = 32767 + Public Const collate4machine As Short = 1 + Public Const collate4general As Short = 1001 + Public Const collate4special As Short = 1002 + Public Const sort4machine As Short = 0 'code4.collatingSequence constant + Public Const sort4general As Short = 1 + Public Const WAIT4EVER As Short = -1 + + ' Constants for code4serverOS + Public Const OS4UNKNOWN As Short = &H0S + Public Const OS4WIN32 As Short = &H1S + Public Const OS4UNIX As Short = &H2S + + + 'CodeBasic Error Code Constants + Public Const e4close As Short = -10 + Public Const e4create As Short = -20 + Public Const e4len As Short = -30 + Public Const e4lenSet As Short = -40 + Public Const e4lock As Short = -50 + Public Const e4open As Short = -60 + Public Const e4permiss As Short = -61 + Public Const e4access As Short = -62 + Public Const e4numFiles As Short = -63 + Public Const e4fileFind As Short = -64 + Public Const e4instance As Short = -69 + Public Const e4read As Short = -70 + Public Const e4remove As Short = -80 + Public Const e4rename As Short = -90 + Public Const e4seek As Short = -250 + Public Const e4unlock As Short = -110 + Public Const e4write As Short = -120 + Public Const e4data As Short = -200 + Public Const e4fieldName As Short = -210 + Public Const e4fieldType As Short = -220 + Public Const e4recordLen As Short = -230 + Public Const e4append As Short = -240 + Public Const e4entry As Short = -300 + Public Const e4index As Short = -310 + Public Const e4tagName As Short = -330 + Public Const e4unique As Short = -340 + Public Const e4tagInfo As Short = -350 + Public Const e4commaExpected As Short = -400 + Public Const e4complete As Short = -410 + Public Const e4dataName As Short = -420 + Public Const e4lengthErr As Short = -422 + Public Const e4notConstant As Short = -425 + Public Const e4numParms As Short = -430 + Public Const e4overflow As Short = -440 + Public Const e4rightMissing As Short = -450 + Public Const e4typeSub As Short = -460 + Public Const e4unrecFunction As Short = -470 + Public Const e4unrecOperator As Short = -480 + Public Const e4unrecValue As Short = -490 + Public Const e4undetermined As Short = -500 + Public Const e4tagExpr As Short = -510 + Public Const e4opt As Short = -610 + Public Const e4optSuspend As Short = -620 + Public Const e4optFlush As Short = -630 + Public Const e4relate As Short = -710 + Public Const e4lookupErr As Short = -720 + Public Const e4relateRefer As Short = -730 + Public Const e4info As Short = -910 + Public Const e4memory As Short = -920 + Public Const e4parm As Short = -930 + Public Const e4parmNull As Short = -935 + Public Const e4demo As Short = -940 + Public Const e4result As Short = -950 + Public Const e4verify As Short = -960 + Public Const e4struct As Short = -970 + Public Const e4notSupported As Short = -1090 + Public Const e4version As Short = -1095 + Public Const e4memoCorrupt As Short = -1110 + Public Const e4memoCreate As Short = -1120 + Public Const e4transViolation As Short = -1200 + Public Const e4trans As Short = -1210 + Public Const e4rollback As Short = -1220 + Public Const e4commit As Short = -1230 + Public Const e4transAppend As Short = -1240 + Public Const e4corrupt As Short = -1300 + Public Const e4connection As Short = -1310 + Public Const e4socket As Short = -1320 + Public Const e4net As Short = -1330 + Public Const e4loadlib As Short = -1340 + Public Const e4timeOut As Short = -1350 + Public Const e4message As Short = -1360 + Public Const e4packetLen As Short = -1370 + Public Const e4packet As Short = -1380 + Public Const e4max As Short = -1400 + Public Const e4codeBase As Short = -1410 + Public Const e4name As Short = -1420 + Public Const e4authorize As Short = -1430 + Public Const e4server As Short = -2100 + Public Const e4config As Short = -2110 + Public Const e4cat As Short = -2120 + + Public Const ACTION4NONE As Short = 0 + Public Const ACTION4REINDEX As Short = 1 + Public Const ACTION4INITIALIZING As Short = 32767 + + 'ADO Constants + Public Const e5badBinding As Short = 200 + Public Const e5conversion As Short = 210 + Public Const e5delete As Short = 220 + Public Const e5property As Short = 230 + + Function b4String(ByRef p As Integer) As String + 'This is a utility function for copying a 'C' string to a VB string. + + Dim s As String = New String(CChar(" "), 256) + Dim rc As Short + + If p <> 0 Then + rc = u4ncpy(s, p, 256) + End If + + b4String = Left(s, rc) + End Function + + Function code4dateFormat(ByRef c4Ptr As Integer) As String + 'This function returns the CODE4.dateFormat member + code4dateFormat = b4String(code4dateFormatVB(c4Ptr)) + End Function + + Function code4indexExtension(ByRef c4Ptr As Integer) As String + 'This function returns the CodeBase DLL index format + code4indexExtension = b4String(code4indexExtensionVB(c4Ptr)) + End Function + + Function code4lockFileName(ByRef c4Ptr As Integer) As String + 'This function returns the locked file name + code4lockFileName = b4String(code4lockFileNameVB(c4Ptr)) + End Function + + Function code4lockNetworkId(ByRef c4Ptr As Integer) As String + 'This function returns the user's network id + 'who has locked the current file + code4lockNetworkId = b4String(code4lockNetworkIdVB(c4Ptr)) + End Function + + Function code4lockUserId(ByRef c4Ptr As Integer) As String + 'This function returns the user's name + 'who has locked the current file + code4lockUserId = b4String(code4lockUserIdVB(c4Ptr)) + End Function + + Function code4logFileName(ByRef c4Ptr As Integer) As String + 'This function returns the locked file name + code4logFileName = b4String(code4lockFileNameVB(c4Ptr)) + End Function + + Function d4alias(ByRef dbPtr As Integer) As String + 'This function returns the data file alias + d4alias = b4String(d4aliasCB(dbPtr)) + End Function + + Function d4create(ByVal cb As Integer, ByRef dbname As String, ByRef D() As FIELD4INFO, ByRef n() As TAG4INFO) As Integer + + ' d4create calls d4createLow() to create a new database. + ' This function is the same as d4createData() except that + ' it requires an additional parameter which it uses to + ' create tag information for a database. + ' + ' Variable n is an array of type TAG4INFO which corresponds + ' to TAG4INFOCB, a structure that can be used by d4create. + ' The difference once again is merely the difference in the + ' representation of strings between C and Basic. + ' d4create takes the contents from the TAG4INFO structure + ' and builds a TAG4INFOCB structure which it passes to d4createLow(). + ' Note: the TAG4INFOCB array is one size larger than the TAG4INFO + ' array. The extra empty (zero filled) array element is the + ' way that d4createLow() detects the end of the array. + + + Dim i As Short + + Dim flb As Short + Dim fub As Short + Dim fs As Short + + Dim tlb As Short + Dim tub As Short + Dim ts As Short + + + flb = LBound(D) + fub = UBound(D) + ' LY Apr 13/04 : changed from fs = fub - 1, since Microsoft docs wrong about + ' array sizes (i.e. dim array(N) contains elements 0 to N, not 0 to N - 1) + fs = fub + + + Dim f((fub + 1)) As FIELD4INFOCB + i = flb + Do While D(i).fName <> "" And i <= fs + f(i).fName = v4Cstring(D(i).fName) ' note: this function allocates memory + f(i).ftype = Asc(D(i).ftype) + f(i).flength = D(i).flength + f(i).fdecimals = D(i).fdecimals + f(i).fnulls = D(i).fnulls + i = i + 1 + Loop + + tlb = LBound(n) + tub = UBound(n) + ' LY Apr 13/04 : changed from ts = tub - 1, since Microsoft docs wrong about + ' array sizes (i.e. dim array(N) contains elements 0 to N, not 0 to N - 1) + ts = tub + Dim t((tub + 1)) As TAG4INFOCB + i = tlb + Do While n(i).name <> "" And i <= ts + t(i).name = v4Cstring(n(i).name) + t(i).expression = v4Cstring(n(i).expression) + t(i).filter_Renamed = v4Cstring(n(i).filter_Renamed) + t(i).unique = n(i).unique + t(i).descending = n(i).descending + i = i + 1 + Loop + d4create = d4createLow(cb, (dbname), f(0), t(0)) + + ' Since v4Cstring allocates memory for the storage of + ' C strings, we must free the memory after it has been + ' used. + ' LY Jul 14/04 : changed from "1 to fs" to "flb to fs - 1" + For i = flb To fs - 1 + Call v4Cstringfree(f(i).fName) + Next i + + ' LY Jul 14/04 : changed from "1 to ts" to "tlb to ts - 1" + For i = tlb To ts - 1 + Call v4Cstringfree(t(i).name) + Call v4Cstringfree(t(i).expression) + Call v4Cstringfree(t(i).filter_Renamed) + Next i + + End Function + + Function d4createData(ByVal cb As Integer, ByRef dbname As String, ByRef D() As FIELD4INFO) As Integer + + ' d4createData() calls d4createLow() to create a new database. + ' d4create() builds the FIELD4INFOCB array which is + ' the one recognized by d4create (note that the only difference + ' is that the fname field is a string in type FIELD4INFO + ' and type long in FIELD4INFOCB which is how strings are represented + ' in C). Furthermore, the size of f (our FIELD4INFOCB array) is one + ' larger than the size s of FIELD4INFO d. This is because + ' d4create doesn't know the size of the array f and therefore it stops + ' when it reaches an array element that is filled with zeros which + ' the extra (s+1)'th element of f provides. + + Dim i As Short + + ' Make this array 1 larger than the one passed in. + Dim f(1 + UBound(D) - LBound(D)) As FIELD4INFOCB + + i = 0 + For Each fielddef As FIELD4INFO In D + If Len(fielddef.fName) = 0 Then + Exit For + End If + f(i).fName = v4Cstring(fielddef.fName) ' note: this function allocates memory + f(i).ftype = Asc(fielddef.ftype) + f(i).flength = fielddef.flength + f(i).fdecimals = fielddef.fdecimals + f(i).fnulls = fielddef.fnulls + i = i + 1 + Next fielddef + + d4createData = d4createLow(cb, (dbname), f(0), 0) + + ' Since v4Cstring allocates memory for the storage of + ' C strings, we must free the memory after it has been + ' used. + ' LY Jul 14/04 : changed from "lb to s" to "lb to s - 1" + For Each cf As FIELD4INFOCB In f + Call v4Cstringfree(cf.fName) + Next cf + End Function + + Function d4encodeHandle(ByRef temp As Integer) As Object + Dim EncodedString As String + EncodedString = "#" & Str(temp) + d4encodeHandle = EncodedString + End Function + + Function d4fieldsAdd(ByRef DATA4 As Integer, ByRef fields() As FIELD4INFO) As Integer + Dim i As Short + Dim ub As Short + + ub = UBound(fields) + Dim f(ub + 1) As FIELD4INFOCB + For i = LBound(fields) To ub + f(i).fName = v4Cstring(fields(i).fName) ' note: this function allocates memory + f(i).ftype = Asc(fields(i).ftype) + f(i).flength = fields(i).flength + f(i).fdecimals = fields(i).fdecimals + f(i).fnulls = fields(i).fnulls + Next i + + d4fieldsAdd = d4fieldsAddCB(DATA4, ub, f(LBound(f))) + If d4fieldsAdd <> 0 Then + DATA4 = d4fieldsAdd + End If + + ' Since v4Cstring allocates memory for the storage of + ' C strings, we must free the memory after it has been + ' used. + For i = LBound(f) To UBound(f) + Call v4Cstringfree(f(i).fName) + Next i + End Function + + Function d4fieldsRemove(ByRef DATA4 As Integer, ByRef fieldNames() As String) As Integer + Dim addrs() As Integer + Dim i As Short + ReDim addrs(UBound(fieldNames)) + For i = LBound(fieldNames) To UBound(fieldNames) + addrs(i) = v4Cstring(fieldNames(i)) + Next i + + d4fieldsRemove = d4fieldsRemoveCB(DATA4, UBound(fieldNames) - LBound(fieldNames) + 1, addrs(LBound(addrs))) + + For i = LBound(addrs) To UBound(addrs) + Call v4Cstring(CStr(addrs(i))) + Next i + End Function + + Function d4fileName(ByRef dbfPtr As Integer) As String + d4fileName = b4String(d4fileNameCB(dbfPtr)) + End Function + + Function d4go(ByRef DATA4 As Integer, ByRef recordNumber As Integer) As Short + d4go = d4goLow(DATA4, recordNumber, 1) + End Function + + Sub date4assign(ByRef dateString_Renamed As String, ByRef julianDay As Integer) + 'This functions converts the julian day into standard format + 'and puts the result in dateString + + 'Size dateString$ + dateString_Renamed = Space(8 + 1) + + Call date4assignLow(dateString_Renamed, julianDay, 0) + dateString_Renamed = Left(dateString_Renamed, 8) + End Sub + + Function date4cdow(ByRef dateString_Renamed As String) As String + 'This function returns the day of the week in a character + 'string based on the value in 'DateString' + + ' CS 2006/05/12 Fix so function always returns a value. + If Len(dateString_Renamed) < 8 Then + date4cdow = "" + Else + Dim datePtr As Integer + datePtr = date4cdowCB(dateString_Renamed) 'Get pointer to day + If datePtr <> 0 Then + date4cdow = b4String(datePtr) + Else + date4cdow = "" + End If + End If + End Function + + Function date4cmonth(ByRef dateString_Renamed As String) As String + 'This function returns the month in 'DateString' as a + 'character string + + ' CS 2006/05/12 Fix so function always returns a value. + If Len(dateString_Renamed) < 8 Then + date4cmonth = "" + Else + Dim datePtr As Integer + datePtr = date4cmonthCB(dateString_Renamed) 'Get pointer to month + If datePtr <> 0 Then + date4cmonth = b4String(datePtr) 'Return month name + Else + date4cmonth = "" + End If + End If + End Function + + Sub date4format(ByRef dateString_Renamed As String, ByRef Result As String, ByRef pic As String) + 'This function formats Result$ using the date value + ' in 'dateString$' and the format info. in 'Pic$' + + 'Size Result$ + Result = Space(Len(pic) + 1) + + Call date4formatCB(dateString_Renamed, Result, pic) + Result = Left(Result, Len(pic)) + End Sub + + Sub date4init(ByRef Result As String, ByRef dateString_Renamed As String, ByRef pic As String) + 'This function copies the date, specified by dateString, + 'and formatted according to pic, into Result. The date copied + 'will be in standard dBASE format, + + 'Size Result$ + Result = Space(9) + + Call date4initCB(Result, dateString_Renamed, pic) + Result = Left(Result, 8) + End Sub + + Sub date4today(ByRef dateS As String) + If Len(dateS) < 8 Then dateS = Space(8) + Call date4todayCB(dateS) + End Sub + + Function error4text(ByRef c4 As Integer, ByRef errCode As Integer) As String + 'This function returns the error message string + error4text = b4String(error4textCB(c4, errCode)) + End Function + + Function expr4null(ByRef exPtr As Integer) As Short + expr4null = expr4nullLow(exPtr, 1) + End Function + + Function expr4source(ByRef exPtr As Integer) As String + 'This function returns a copy of the original + 'dBASE expression string + expr4source = b4String(expr4sourceCB(exPtr)) + End Function + + Function expr4str(ByRef exPtr As Integer) As String + 'This function returns the parsed string + + 'Get pointer to alias string + Dim exprPtr As Integer = expr4strCB(exPtr) + + If exprPtr = 0 Then + Return "" + Else + Return Left(b4String(exprPtr), expr4len(exPtr)) + End If + End Function + + Function expr4type(ByRef exPtr As Integer) As String + 'This function returns the type of the parsed string + + Dim exprType As Short + + ' CS 2006/05/12 Fix so function always returns a value. + 'Get ASCII value of type + exprType = expr4typeCB(exPtr) + If exprType <> 0 Then + expr4type = Chr(exprType) + Else + expr4type = "" + End If + End Function + + Sub f4assign(ByRef fPtr As Integer, ByRef fStr As String) + Call f4assignN(fPtr, fStr, Len(fStr)) + End Sub + + Sub f4assignBinary(ByRef fPtr As Integer, ByRef value() As Byte) + Call f4assignBinaryVB(fPtr, value(LBound(value)), UBound(value) - LBound(value)) + End Sub + + Sub f4assignUnicode(ByRef fPtr As Integer, ByRef value As String) + Dim bArray() As Byte + bArray = System.Text.UnicodeEncoding.Unicode.GetBytes(value & ControlChars.NullChar) + Call f4assignUnicodeVB(fPtr, bArray(0)) + End Sub + + Sub f4assignInt(ByRef fldPtr As Integer, ByRef fldVal As Short) + Call f4assignIntVB(fldPtr, fldVal) + End Sub + + Function f4binary(ByRef field As Integer) As Object + Dim fLen As Integer + fLen = f4len(field) + Dim buffer() As Byte + If fLen = 0 Then + ReDim buffer(0) + Else + ReDim buffer((fLen + 1)) ' 1 greater because f4ncpy null-terminates the buffer + fLen = f4ncpyBinary(field, buffer(0), fLen + 1) + ReDim Preserve buffer(fLen - 1) + End If + f4binary = buffer + End Function + + Function f4currency(ByRef field As Integer, ByRef numDec As Short) As String + 'This function returns the contents of a field + f4currency = b4String(f4currencyCB(field, numDec)) + End Function + + Function f4dateTime(ByRef field As Integer) As String + 'This function returns the contents of a field + f4dateTime = b4String(f4dateTimeCB(field)) + End Function + + Function f4memoAssignBinary(ByRef fPtr As Integer, ByRef value() As Byte) As Short + f4memoAssignBinary = f4memoAssignBinaryVB(fPtr, value(LBound(value)), UBound(value) - LBound(value) + 1) + End Function + + Sub f4memoAssignUnicode(ByRef fPtr As Integer, ByRef value As String) + Dim bArray() As Byte + bArray = System.Text.UnicodeEncoding.Unicode.GetBytes(value & ControlChars.NullChar) + Call f4memoAssignUnicodeVB(fPtr, bArray(0)) + End Sub + + Function f4memoBinary(ByRef field As Integer) As Object + Dim fLen As Integer + fLen = f4memoLen(field) + Dim buffer() As Byte + If fLen = 0 Then + ReDim buffer(0) + Else + ' CS 2007/04/23 Fixes because Lbound is always 0. + ReDim buffer(fLen) + fLen = f4memoNcpyBinary(field, buffer(0), fLen + 1) + ReDim Preserve buffer(fLen - 1) + End If + f4memoBinary = buffer + End Function + + Function f4memoStr(ByRef fPtr As Integer) As String + 'This function returns a string corresponding to the memo + 'field pointer argument. + Dim MemoLen, MemoPtr As Integer + + MemoLen = f4memoLen(fPtr) 'Get memo length + + If MemoLen > &H7FFFFFFF Then + MsgBox("Error #: -910" & ControlChars.CrLf & "Unexpected Information" & vbCrLf & "Memo entry too long to return in a Visual Basic string." & vbCrLf & "Field Name:" & vbCrLf & f4name(fPtr), 16, "CodeBase Error") + Return "" + End If + + MemoPtr = f4memoPtr(fPtr) + If MemoPtr = 0 Then Return "" + + Dim MemoString As String + MemoString = New String(" ", MemoLen) + + 'Copy 'MemoPtr' to VB string 'MemoString' + u4memCpy(MemoString, MemoPtr, MemoLen) + + f4memoStr = MemoString + End Function + + Sub f4memoStr64(ByRef fPtr As Integer, ByRef src As String) + + 'This function copies a large memo entry (32K-64K) + 'into a user supplied string + + Dim r4line As String + r4line = Chr(10) & Chr(13) + + Dim MemoLen, MemoPtr As Integer + + MemoLen = f4memoLen(fPtr) 'Get memo length + + ' 'r4maxVBStringLen' defined in 'Constants' section of this file + If MemoLen > r4maxVBStringLen Then + MsgBox("Error #: -910" & r4line & "Unexpected Information" & r4line & "Memo entry too long to retrieve into VB string." & r4line & "Field Name:" & r4line & f4name(fPtr), 16, "CodeBasic Error") + Exit Sub + End If + + MemoPtr = f4memoPtr(fPtr) + If MemoPtr = 0 Then Exit Sub + + src = New String(" ", MemoLen) + + 'Copy 'MemoPtr' to VB string 'src' + u4memCpy(src, MemoPtr, MemoLen) + + End Sub + + Function f4name(ByRef fPtr As Integer) As String + 'This function returns the name of a field + + Dim FldNamePtr As Integer 'Pointer to field name + FldNamePtr = f4nameCB(fPtr) 'Get pointer + + f4name = b4String(FldNamePtr) + End Function + + Function f4nCpy(ByRef field As Integer, ByRef s As String, ByRef slen As Short) As Short + 'This function copies the fields contents into a string + s = Space(slen) 'Make s$ one byte longer for null character that u4ncpy adds + Dim fPtr As Integer + fPtr = f4ptr(field) + + If fPtr = 0 Then Exit Function + + u4memCpy(s, fPtr, slen) + + f4nCpy = Len(s) + End Function + + Function f4str(ByRef field As Integer) As String + 'This function returns the contents of a field + Dim s As String + Dim fPtr As Integer + Dim fLen As Short + + fPtr = f4ptr(field) + If fPtr = 0 Then Return "" + + fLen = f4len(field) 'Get field length + s = Space(fLen) 'Make s$ one byte longer for null character that u4ncpy adds + + u4memCpy(s, fPtr, fLen) + + f4str = s + End Function + + Function f4strUnicode(ByRef field As Integer) As String + 'This function returns the contents of a Unicode field + Dim bArray() As Byte + bArray = f4binary(field) + f4strUnicode = RTrimNulls(Left(System.Text.UnicodeEncoding.Unicode.GetString(bArray), f4len(field))) + End Function + + Function f4memoStrUnicode(ByRef field As Integer) As String + 'This function returns the contents of a Unicode memo field + Dim bArray() As Byte + bArray = f4memoBinary(field) + f4memoStrUnicode = RTrimNulls(Left(System.Text.UnicodeEncoding.Unicode.GetString(bArray), f4memoLen(field))) + End Function + + Function i4create(ByVal dbPtr As Integer, ByRef IndexName As String, ByRef n() As TAG4INFO) As Integer + ' i4create() calls i4createCB() to create a new + ' index file. Variable n is an array of type TAG4INFO + ' which corresponds to TAG4INFOCB, a structure that + ' can be used by i4createCB(). The difference once + ' again is merely the difference in the representation + ' of strings between C and Basic. + ' + ' i4create() takes the contents from the TAG4INFO + ' structure and builds a TAG4INFOCB structure which + ' it passes to i4createCB(). Note: the TAG4INFOCB + ' arrary is one size larger than the TAG4INFO array. + ' The extra empty (zero filled) array element is the + ' way that i4create detects the end of the array. + ' + ' Note also, that if 'IndexName' is an empty string, + ' the index file that is created will become a + ' "production" index file. i.e. it will be opened every + ' time the corresponding data file is opened. + + Dim i As Short + + ' CS 2006/06/21 Improve array handling. + Dim c_tag_array(UBound(n) - LBound(n)) As TAG4INFOCB ' Array size needs to be one more than VB array for null terminator. + i = 0 + For Each tag As TAG4INFO In n + c_tag_array(i).name = v4Cstring(tag.name) + c_tag_array(i).expression = v4Cstring(tag.expression) + c_tag_array(i).filter_Renamed = v4Cstring(tag.filter_Renamed) + c_tag_array(i).unique = tag.unique + c_tag_array(i).descending = tag.descending + i = i + 1 + Next tag + + ' LY Apr 18/05 : see LY Apr 18/05 in i4create.c + i4create = i4createCB(dbPtr, IndexName, c_tag_array(0)) + + ' Since v4Cstring allocates memory for the storage of + ' C strings, we must free the memory after it has been + ' used. + + For Each tag As TAG4INFOCB In c_tag_array + If tag.name <> 0 Then Call v4Cstringfree(tag.name) + If tag.expression <> 0 Then Call v4Cstringfree(tag.expression) + If tag.filter_Renamed <> 0 Then Call v4Cstringfree(tag.filter_Renamed) + Next tag + End Function + + Function i4fileName(ByRef iPtr As Integer) As String + 'This function returns the file name of an index tag + i4fileName = b4String(i4fileNameCB(iPtr)) + End Function + + Function i4open(ByRef d4 As Integer, ByRef fName As String) As Integer + If fName = "" Then + i4open = i4openCB(d4, 0) 'Use data file name + Else + i4open = i4openCB(d4, fName) 'Use supplied name + End If + End Function + + Function i4tagAdd(ByVal i4Ptr As Integer, ByRef n() As TAG4INFO) As Short + ' i4tagAdd adds additional tags to an existing + ' index. + + ' i4tagAdd takes the contents from the TAG4INFO + ' structure and builds a TAG4INFOCB structure which + ' is passed to i4tagAddCB. + + Dim i As Short + + Dim tlb As Short + Dim tub As Short + Dim ts As Short + + + tlb = LBound(n) + tub = UBound(n) + ts = tub - tlb + 1 + Dim t((ts + 1)) As TAG4INFOCB + For i = 1 To ts + t(i).name = v4Cstring(n((tlb - 1) + i).name) + t(i).expression = v4Cstring(n((tlb - 1) + i).expression) + t(i).filter_Renamed = v4Cstring(n((tlb - 1) + i).filter_Renamed) + t(i).unique = n((tlb - 1) + i).unique + t(i).descending = n((tlb - 1) + i).descending + Next i + + i4tagAdd = i4tagAddCB(i4Ptr, t(1)) + + End Function + + Function relate4masterExpr(ByRef r4Ptr As Integer) As String + 'This function returns the Relations expression string + relate4masterExpr = b4String(relate4masterExprCB(r4Ptr)) + End Function + + Function report4parent(ByVal r4 As Integer, ByVal hWnd As IntPtr) As Short + report4parent = report4parent32(r4, hWnd) + End Function + + Sub report4free(ByRef pReport As Integer, ByRef freeRelate As Short, ByRef closeFiles As Short) + Call report4freeLow(pReport, freeRelate, closeFiles, 1) + End Sub + + Function t4Alias(ByRef tPtr As Integer) As String + t4Alias = b4String(t4aliasCB(tPtr)) + End Function + + Function t4expr(ByRef tPtr As Integer) As String + 'This function returns the original tag expression + t4expr = b4String(t4exprCB(tPtr)) + End Function + + Function t4filter(ByRef tPtr As Integer) As String + + 'This function returns the tag filter expression + + Dim FilterPtr As Integer + + 'Get pointer to parsed filter expression + FilterPtr = t4filterCB(tPtr) + + If FilterPtr = 0 Then + t4filter = "" + Exit Function 'No filter + End If + + t4filter = b4String(FilterPtr) + + End Function + + Function u4descend(ByRef charString As String) As String + Dim Result As String = "" + Dim i As Short + + For i = 1 To Len(charString) + Result = Result & Chr(128 And Asc(Mid(charString, i, 1))) + Next + + u4descend = Result + End Function + + Private Function RTrimNulls(ByRef str_Renamed As String) As String + ' Returns a String containing a copy + ' of str without trailing nulls. + Dim curLength, newLength As Integer + curLength = Len(str_Renamed) + If curLength = 0 Then Return "" + + For newLength = 1 To curLength + If Mid(str_Renamed, newLength, 1) = ControlChars.NullChar Then + RTrimNulls = Left(str_Renamed, newLength - 1) + Exit Function + End If + Next + + RTrimNulls = str_Renamed + End Function +End Module diff --git a/test/CSharp/t4all.cs b/test/CSharp/t4all.cs new file mode 100644 index 0000000..cc35eb7 --- /dev/null +++ b/test/CSharp/t4all.cs @@ -0,0 +1,695 @@ +using System; +using CodeBase ; +namespace ConsoleApplication1 +{ + /// + /// Summary description for t4all1. + /// + class t4all + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + // + // TODO: Add code to start application here + // + Code4 cb ; + Data4 data = new Data4(), data2 = new Data4(); + Tag4 tag = new Tag4() ; + Index4 index ; + Expr4 expr = new Expr4() ; + Relate4set rel = new Relate4set() ; + Relate4 relS = new Relate4() ; + string strTemp ; + Field4 fStr, fNum, fLog, fCur, fDT, fDouble ; + Field4memo fMem ; + int rc ; + short sRc ; + + cb = new Code4() ; + + // CODE4 structure members + + sRc = cb.accessMode ; + sRc = cb.autoOpen ; + rc = cb.codePage ; + rc = cb.collatingSequence ; + cb.compatibility = 30 ; + rc = cb.createTemp ; + rc = cb.errCreate ; + rc = cb.errDefaultUnique ; + rc = cb.errExpr ; + rc = cb.errFieldName ; + rc = cb.errGo ; + rc = cb.errOff ; + rc = cb.errorCode ; + rc = cb.errOpen ; + rc = cb.errRelate ; + rc = cb.errSkip ; + rc = cb.errTagName ; + rc = cb.fileFlush ; + cb.hWnd = 0 ; + rc = cb.lockAttempts ; + rc = cb.lockAttemptsSingle ; + cb.lockDelay = 10 ; + rc = cb.lockEnforce ; + rc = cb.log ; + rc = cb.memExpandBlock ; + rc = cb.memExpandData ; + rc = cb.memExpandIndex ; + rc = cb.memExpandLock ; + rc = cb.memExpandTag ; + cb.memSizeBlock = 1024 ; + cb.memSizeBuffer = 32768 ; + cb.memSizeMemo = 512 ; + cb.memSizeMemoExpr = 1024 ; + cb.memSizeSortBuffer = 4096 ; + cb.memSizeSortPool = 0xF000 ; + cb.memStartBlock = 10 ; + cb.memStartData = 10 ; + cb.memStartIndex = 10 ; + sRc = cb.memStartLock ; + rc = cb.memStartMax ; + cb.memStartTag = 10 ; + rc = cb.optimize ; + rc = cb.optimizeWrite ; + rc = cb.readLock ; + rc = cb.readOnly ; + rc = cb.safety ; + rc = cb.singleOpen ; + rc = cb.timeout ; + cb.timeout = 100 ; + + cb.errOff = 1 ; + cb.connect( "localhost", "23165", "", "", "" ) ; + cb.errOff = 0 ; + cb.errorCode = 0 ; + + cb.readOnly = 1 ; + cb.compatibility = 30 ; + if ( cb.indexExtension().ToUpper() == "NTX" ) + data.open( ref cb, "c:\\dbfs\\ntx\\student" ); + else + data.open( ref cb, "h:\\savetest\\student" ); + cb.readOnly = 0 ; + expr.parse( data, new Field4(data, 1).name() ); + cb.calcCreate( expr, "FFF" ) ; + cb.calcReset() ; + + cb.closeAll() ; + + cb.readOnly = 1 ; + cb.compatibility = 30 ; + if ( cb.indexExtension().ToUpper() == "NTX" ) + data.open( ref cb, "c:\\dbfs\\ntx\\student" ) ; + else + data.open( ref cb, "h:\\savetest\\student" ) ; + cb.readOnly = 0 ; + cb.data( "STUDENT" ) ; + data.close() ; + + string datestr = cb.dateFormat ; + cb.dateFormat = "MMM DD CCYY" ; + + // code4exit(); -- see end + + cb.flushFiles() ;; + + string extstr = cb.indexExtension() ; + + // code4init(); -- see beginning + // code4initUndo(); -- see end + + cb.lockGroup() ; + + cb.lockClear() ; + + cb.lockFileName() ; + + cb.lockItem() ; + + cb.lockNetworkId() ; + + cb.lockUserId() ; + + cb.logOpenOff() ; + + cb.safety = 0 ; + cb.logCreate( "t4all.log", "t4all" ) ; + + cb.logFileName() ; + + cb.initUndo() ; + cb.init() ; + + cb.errOff = 1 ; + cb.connect( "localhost", "23165", "", "", "" ) ; + cb.errOff = 0 ; + cb.errorCode = 0 ; + + cb.logOpen( "t4all.log", "t4all" ) ; + + cb.optAll() ; + + cb.optStart() ; + + cb.optSuspend() ; + + cb.compatibility = 30 ; + cb.safety = 0 ; + + Field4info fields = new Field4info( ref cb ) ; + fields.add( "STR", Code4.r4str, 10, 0, Code4.r4null ) ; + fields.add( "NUM", Code4.r4num, 4, 0, 0 ) ; + fields.add( "LOG", Code4.r4log, 10, 0, 0 ) ; + if ( cb.indexExtension().ToUpper() == "CDX" ) + { + fields.add( "CUR", Code4.r4currency, 10, 0, 0 ) ; + fields.add( "DOUBLE", Code4.r4double, 10, 0, 0 ) ; + fields.add( "DT", Code4.r4dateTime, 10, 0, 0 ) ; + } + fields.add( "MEM", Code4.r4memo, 10, 0, 0 ) ; + + Tag4info tags = new Tag4info( cb ) ; + tags.add( "STR", "STR", "", 0, 0 ) ; + tags.add( "NUM", "NUM", "", Code4.r4uniqueContinue, 0 ) ; + + data.create( ref cb, "t4all", ref fields, ref tags); + + cb.tranStart() ; + cb.tranCommit() ; + + cb.tranStart() ; + cb.tranRollback() ; + + cb.tranStatus() ; + + data.close() ; + + cb.unlock() ; + + rc = cb.unlockAuto ; + + cb.unlockAuto = Code4.LOCK4ALL ; + + /////////////////////////////////////////// + + cb.compatibility = 30 ; + cb.safety = 0 ; + data.create( ref cb, "t4all", ref fields, ref tags ); + + string newStr = data.alias ; + + data.alias = "newalias" ; + + data.appendStart( 0 ); + + data.append() ; + + data.appendBlank() ; + + data.blank() ; + + data.eof() ; + + data.bottom() ; + + data.changed = 0 ; + + data.checkIndex() ; + + data.close() ; + + // d4create: see above + + // d4createCB: should be performed by d4create() + + cb.compatibility = 30 ; + cb.safety = 0 ; + data.create( ref cb, "t4all", ref fields ) ; + + data.appendBlank() ; + data.deleteRec() ; + + data.deleted() ; + + data.eof() ; + + // d4field(data, 'str'); + + // u4free(PVoid(d4fieldInfo(data))); + + data.fieldNumber( new Field4( data, 1).name() ) ; + + data.fileName() ; + + data.flush() ; + + data.freeBlocks() ; + + rc = data.appendBlank() ; + data.go( 1 ); + + data.goBof() ; + + data.goEof() ; + + data.index( "" ) ; + + data.lockRecord( 1 ); + + data.lockAdd( 1 ) ; + + data.lockAddAll() ; + + data.lockAddAppend() ; + + data.lockAddFile() ; + + data.lockAll() ; + + data.lockAppend() ; + + data.lockFile() ; + + data.log = 0 ; + + rc = data.log ; + + data.memoCompress() ; + + data.numFields() ; + + data.close() ; + cb.compatibility = 30 ; + data.open( ref cb, "t4all" ); + + data2.openClone( data ) ; + data2.close() ; + + data.optimize( Code4.OPT4OFF ) ; + + data.optimizeWrite( Code4.OPT4OFF ) ; + + data.pack() ; + + double newDouble = data.position ; + + data.position = 0.5 ; + + data.recall() ; + + // d4record(data); + + data.recWidth() ; + + data.refresh() ; + + data.refreshRecord() ; + + data.reindex() ; + + data.remove() ; + cb.compatibility = 30 ; + cb.safety = 0 ; + data.create( ref cb, "t4all", ref fields, ref tags ) ; + + data.select( new Tag4( data, "STR") ); + data.seek( "s" ); + + data.seekNext( "s" ); + + data.seek( "sssss", 2 ) ; + + data.seekNext( "sssss", 2 ) ; + + data.select( new Tag4(data, "NUM") ); + data.seek( 2.0 ); + + data.seekNext( 2.0 ); + + data.top() ; + data.skip( 1 ) ; + + // d4tag: see d4seek(); + + tag.initFirst( data ) ; + + tag.initNext() ; + + tag.initPrev() ; + + // d4tagSelect: see d4seek(); + + tag.init( data, "" ) ; + + data.tagSync() ; + + data.top() ; + + data.unlock() ; + + data.appendBlank() ; + data.appendBlank() ; + data.write( 1 ) ; + + data.zap( 2, 99 ) ; + + ////////////////////////////////////////////// + + strTemp = "" ; + // date4assign(strTemp, date4long('19980909')); + + //date4cdow('19980909'); + + //date4cmonth('19980909'); + + //date4day('19980909'); + + //date4format('19980909', strTemp, 'CCYYMMDD'); + + //date4init(strTemp, '19980909', 'CCYYMMDD'); + + //date4isLeap('19980909'); + + //{date4long: see date4assign();} + + //date4month('19980909'); + + //date4today(strTemp); + + //date4year('19980909'); + + // + + cb.errOff = 1 ; + // don't display msgbox + + cb.throwError( -60, 90210 ) ; + cb.errorCode = 0 ; + + cb.error( -60, 90210, "This is a test", "", "" ) ; + cb.errorCode = 0 ; + + cb.exitTest() ; + + cb.errorFile( "t4all.err", 1 ) ; + + cb.errorSet( 0 ) ; + + cb.errorText( -60 ) ; + + cb.initUndo() ; + cb.init() ; + + // + cb.errOff = 1 ; + cb.connect( "localhost", "23165", "", "", "" ) ; + cb.errOff = 0 ; + cb.errorCode = 0 ; + + cb.compatibility = 30; + cb.safety = 0 ; + data.create( ref cb, "t4all", ref fields, ref tags ) ; + + expr = new Expr4() ; + expr.parse( data, "STR" ) ; + + expr.data() ; + + expr.len() ; + + expr.isNull() ; + + expr.source() ; + + expr.str() ; + + expr.free() ; + + expr.parse( data, "NUM" ) ; + + newDouble = (double)expr ; + + expr.free() ; + + expr.parse( data, "LOG" ) ; + + expr.isTrue() ; + + expr.free() ; + + // + + cb.closeAll() ; + cb.compatibility = 30 ; + cb.safety = 0 ; + data.create( ref cb, "t4all", ref fields, ref tags ) ; + + fStr = new Field4( data, "STR" ) ; + fNum = new Field4( data, "NUM" ) ; + fLog = new Field4( data, "LOG" ) ; + if ( cb.indexExtension().ToUpper() == "CDX" ) + { + fCur = new Field4( data, "CUR" ) ; + fDT = new Field4( data, "DT" ) ; + fDouble = new Field4( data, "DOUBLE" ) ; + } + else + { + fCur = new Field4( data, 1 ) ; + fDT = new Field4( data, 1 ) ; + fDouble = new Field4( data, 1 ) ; + } + fMem = new Field4memo( data, "MEM" ) ; + + fStr.assign( "A" ) ; + + //f4assignChar(fLog, 65); + + if ( cb.indexExtension().ToUpper() == "CDX" ) + { + fCur.assignCurrency( "8.75" ) ; + + fDT.assignDateTime( "1998090912:12:12" ) ; + + fDouble.assignDouble( 8.75 ) ; + } + + fStr.assignField( ref fNum ) ; + + fNum.assignInt( 5 ) ; + + // f4assignLong(fNum, 12345678); + + if ( cb.indexExtension().ToUpper() == "CDX" ) + fStr.assignNull() ; + + fStr.assign( "aaaaa", 2 ) ; + + // f4blank(fStr); + + fLog.getChar() ; + + if ( cb.indexExtension().ToUpper() == "CDX" ) + { + fCur.currency( 2 ) ; + + fDT.dateTime() ; + } + + fDT.data() ; + + fNum.decimals() ; + + fNum.getInt() ; + + if ( cb.indexExtension().ToUpper() == "CDX" ) + fDouble.getDouble() ; + + fStr.len() ; + + // f4long(fNum); + + fMem.assign( "AAA" ) ; + + fMem.assign( "AAA", 2 ) ; + + fMem.free() ; + + fMem.len() ; + + fMem.str() ; + + fLog.name() ; + + fStr.isNull() ; + + if ( cb.indexExtension().ToUpper() == "CDX" ) + fCur.number() ; + + // f4ptr(fStr); + + fStr.str() ; + + fLog.isTrue() ; + + if ( cb.indexExtension().ToUpper() == "CDX" ) + fDouble.type() ; + + // + + cb.closeAll() ; + + cb.compatibility = 30 ; + cb.safety = 0 ; + data.create( ref cb, "t4all", ref fields, ref tags ); + + // i4create(data, 't4all', @tags); + + data.close() ; + cb.compatibility = 30 ; + cb.autoOpen = 0 ; + data.open( ref cb, "t4all" ) ; + cb.autoOpen = 1 ; + index = new Index4( data, "t4all" ) ; + + // i4createCB: should be called by i4create(); + + index.fileName() ; + + index.reindex() ; + + index.tag( "STR" ) ; + + // i4tagAdd(index, @junkTags); + + // i4tagInfo(index); + + index.close() ; + // + + cb.closeAll() ; + cb.readOnly = 1 ; + cb.compatibility = 30 ; + if ( cb.indexExtension().ToUpper() == "NTX" ) + { + data.open( ref cb, "c:\\dbfs\\ntx\\student" ) ; + data2.open( ref cb, "c:\\dbfs\\ntx\\enroll" ) ; + } + else + { + data.open( ref cb, "h:\\savetest\\student" ) ; + data2.open( ref cb, "h:\\savetest\\enroll" ) ; + } + cb.readOnly = 0 ; + rel = new Relate4set() ; + rel.init( data ) ; + + relS = new Relate4( rel, data2, "ID", new Tag4( data2, "STU_ID_TAG") ); + + rel.querySet( "AGE < 30" ) ; + + rel.sortSet( "ID" ) ; + + rel.bottom() ; + + rel.changed() ; + + rel.data() ; + + rel.dataTag() ; + + rel.doAll() ; + + relS.doOne() ; + + rel.eof() ; + + rel.errorAction( Code4.relate4blank ) ; + + rel.lockAdd() ; + + rel.master() ; + + rel.masterExpr() ; + + relS.matchLen( 10 ) ; + + rel.optimizeable() ; + + rel.top() ; + + rel.skip( 1 ) ; + + rel.skipEnable( 1 ) ; + + relS.type( Code4.relate4scan ) ; + + Relate4iterator relIt = new Relate4iterator( rel ) ; + relIt.next() ; + + // + + cb.closeAll() ; + cb.readOnly = 1 ; + cb.errOff = 0 ; + cb.errOpen = 1 ; + cb.compatibility = 30 ; + +// report := report4retrieve(cb, 'q:\cb64\cb64\coderep\examples\tut1', 1, 'q:\cb64\cb64\coderep\examples'); +// report4caption(report, 'T4ALL'); +// report4currency(report, '$'); +// report4dateFormat(report, 'CCYYMMDD'); +// report4decimal(report, '.'); +// report4margins(report, 10, 10, 10, 10, 1); +// report4pageSize(report, 10, 10, 1); +// report4parent(report, 0); +// report4printerSelect(report); +// report4querySet(report, 'T4ALL'); +// report4relate(report); +// report4separator(report, ','); +// report4sortSet(report, 'T4ALL'); +// report4toScreen(report, 1); +// report4do(report); +// report4save(report, 'c:\temp\tut1', 0); +// report4free(report, 1, 1); + + // + + cb.closeAll() ; + + cb.compatibility = 30 ; + cb.safety = 0 ; + data.create( ref cb, "t4all", ref fields, ref tags ) ; + + tag.init( data, "STR" ) ; + + tag.alias() ; + + if ( cb.indexExtension().ToUpper() == "NTX" ) + { + tag.close() ; + tag.open( data, "STR" ) ; + } + + tag.expr() ; + + tag.filter() ; + + tag.init( data, "NUM" ) ; + short newShrt = tag.unique ; + + tag.unique = Code4.r4unique ; + + cb.initUndo() ; + cb.init() ; + Console.WriteLine( "Application is about to exit. That is good." ) ; + //cb.exit() ; + cb.initUndo() ; + } + } +}