This page contains examples for the questions in the CodeBase Hints page.How can files be opened in different modes? (C Example ) #include "d4all.h" #ifdef __BORLANDC__ void main (void) code4init (&cb); /* Non-exclusive, with read access only */ /* Exclusive access with read/write */ /* Non-Exclusive, we can r/w, others can only read */ /* Non-Exclusive, we can r/w as can other users */ code4close(&cb); code4initUndo(&cb); } /* void main */ How can files be opened in different modes? (C++ Example)#include "d4all.hpp" #ifdef __BORLANDC__ void main (void) Code4 cb ; /* Non-exclusive, with read access only */ /* Exclusive access with read/write */ /* Non-Exclusive, we can r/w, others can only read */ /* Non-Exclusive, we can r/w as can other users */ cb.closeAll(); cb.initUndo(); } /* void main */ How can files be opened in different modes? (Visual Basic Example)Sub OpenTest() Dim cb as long cb = code4init() ' Non-exclusive, with read access only ' Exclusive access with read/write ' Non-Exclusive, we can r/w, others can only read ' Non-Exclusive, we can r/w as can other users rc = code4close ( cb ) rc = code4initUndo( cb ) End Sub How can files be opened in different modes? (Delphi Example)Procedure OpenTest; var begin cb := code4init ; { Non-exclusive, with read access only } { Exclusive access with read/write } { Non-Exclusive, we can r/w, others can only read } { Non-Exclusive, we can r/w as can other users } code4close( cb ) ; code4initUndo( cb ) ; end; Why do I have trouble with relations when I am using two files that have the same name, even if they are in different directories? (C Example)CODE4 cb; code4init (&cb); Why do I have trouble with relations when I am using two files that have the same name, even if they are in different directories? (C++ Example)Code4 cb; file1.open( cb, "c:\\dir1\\file" ) ; Why do I have trouble with relations when I am using two files that have the same name, even if they are in different directories? (Visual Basic Example)Dim cb as long file1 = d4open( cb, "c:\dir1\file" ) Why do I have trouble with relations when I am using two files that have the same name, even if they are in different directories? (Delphi Example)var begin file1 := d4open( cb, "c:\dir1\file" ) ; . How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (C Example) #include "d4all.h" #ifdef __BORLANDC__ void main (void) code4init (&cb); How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (C++ Example)#include "d4all.hpp" #ifdef __BORLANDC__ void main (void) file.create ( "datafile", fieldInfo, 0 ) ; How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (Visual Basic Example)Sub CreateTest() fldInfo(1).fname = "FIELD1" : fldInfo(1).ftype =
"C" tagInfo(1).name = "TAG1" : tagInfo(1).expr = "FIELD1" db = d4create( cb, "c:\datafile" ) call code4initUndo( cb ) How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (Delphi Example)Procedure CreateTest; const tagInfo : array[1..2] of TAG4INFO = var begin db = d4create( cb, "datafile", @fieldInfo, nil ) ; code4initUndo( cb ) ; How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (C Example)#include "d4all.h" #ifdef __BORLANDC__ void main (void) code4init(&codeBase); How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (C++ Example)#include "d4all.hpp" #ifdef __BORLANDC__ void main (void) codeBase.autoOpen = 0; How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (Visual Basic Example)Sub Test() cb = code4init() db = d4open( cb, "datafile" ) How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (Delphi Example)Procedure Test; var begin db = d4open( cb, "datafile" ) ; How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (C Example) #include "d4all.h" #ifdef __BORLANDC__ void main (void) code4init( &codeBase ); db = d4open ( &codeBase, "datafile") ) ; How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (C++ Example)#include "d4all.hpp" #ifdef __BORLANDC__ void main (void) db.open( codeBase, "datafile") ; tag1.open( db, "C:\\DIR1\\TAG1.ABC" ) ; How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (Visual Basic Example)Sub Test() cb = code4init() db = d4open( cb, "datafile" ) tag1 = t4open( db, "c:\dir1\tag1.abc" ) How are indexes in a non-default directory and indexes with non-standard name extensions used with CodeBase? (Delphi Example)Procedure Test; var begin db := d4open( cb, "datafile" ) ; tag1 := t4open( db, "c:\dir1\tag1.abc" ) ; Why are all unique tags set to r4uniqueContinue, even though they were created with the r4unique option? (C Example)CODE4 codeBase; /* The tags unique-error handling status is now set to */ Why are all unique tags set to r4uniqueContinue, even though they were created with the r4unique option? (C++ Example)Code4 codeBase; // tag-uniqueError is now set to r4uniqueContinue, so let's Why are all unique tags set to r4uniqueContinue, even though they were created with the r4unique option? (Visual Basic Example)Dim cb As Long, db As Long, tag As Long, rc As Integer ' The tags unique-error handling status is now set to Why are all unique tags set to r4uniqueContinue, even though they were created with the r4unique option? (Delphi Example)var ' The tags unique-error handling status is now set to When a query that uses Query Optimization technology (QO) is made, how is it possible to find out the number of records that are returned? (C Example)#include "d4all.h" void main (void) code4init(&cb); relation = relate4init(file); while (record == r4success) printf("Number of records returned by query = %d\n", count); code4initUndo(&cb); When a query that uses Query Optimization technology (QO) is made, how is it possible to find out the number of records that are returned? (C++ Example)#include "d4all.hpp" void main (void) file.open( "DATAFILE" ) ; relation.init( file ) ; record = relation.top() ; while ( record == r4success ) cout << "Number of records returned by query = " << count << endl; cb.initUndo(); When a query that uses Query Optimization technology (QO) is made, how is it possible to find out the number of records that are returned? (Visual Basic Example)Sub Test() cb = code4init() db = d4open( cb, "datafile" ) relation = relate4init( db ) call relate4querySet( relation, "FIELD1 = 10" ) record = relate4top( relateion ) Do While record <> r4success Form1.Print "Number of records in query = " + Str$(count) call code4initUndo( cb ) When a query that uses Query Optimization technology (QO) is made, how is it possible to find out the number of records that are returned? (Delphi Example)Procedure Test; var begin db := d4open( cb, "datafile" ) ; relation := relate4init( db ) ; relate4querySet( relation, "FIELD1 = 10" ) ; record := relate4top( relation ) ; while record <> r4success do writeln( 'Number of records in query = ', count ) ; code4initUndo( cb ) ; What is code4calcCreate() used for? (C Example) #include "d4all.h" void main (void) code4init (&cb); expr = expr4parse (file, "FIELD1 = 1 .OR. FIELD1 = 2");
relation = relate4init (file); What is code4calcCreate() used for? (C++ Example)#include "d4all.h" void main (void) file.open( "DATAFILE" ) ; cb.calcCreate( expr, "MYEXPR" ) ; relation.init( file ) ; What is code4calcCreate() used for? (Visual Basic Example)Sub Test cb = code4init() db = d4open( cb, "datafile" ) call code4calcCreate( expr, "MYEXPR" ) relation = relate4init( db ) What is code4calcCreate() used for? (Delphi Example)Procedure Test; var begin db := d4open( cb, "datafile" ) ; code4calcCreate( expr, "MYEXPR" ) ; relation := relate4init( db ) ; How can I make my report page size on screen identical to the sheets I use for my printer? (C Example) CODE4 cb; code4init(&cb); How can I make my report page size on screen identical to the sheets I use for my printer? (C++ Example)Code4 cb; report = report4retrieve( cb, "MY_REP", 1, NULL); How can I make my report page size on screen identical to the sheets I use for my printer? (Visual Basic Example)Dim cb As Long, report As Long cb = code4init() call report4pageSize( report, 11000, 8500, 0 ) How can I make my report page size on screen identical to the sheets I use for my printer? (Delphi Example)var begin report4pageSize( report, 11000, 8500, 0 ) ; Error Number: -1 or e4codeBase (C Example)#include "d4all.h" #ifdef __BORLANDC__ void main (void) code4init (&cb); file2 = d4open (&cb, "DATAFILE"); // Error
-910 is returned printf ("\nThe error code is now set to %d", cb.errorCode); cb.errorCode = 0; code4initUndo(&cb); Error Number: -1 or e4codeBase (C++ Example)#include "d4all.hpp" #ifdef __BORLANDC__ void main (void) file1.open( "DATAFILE" ) ; // assume file
exists file1.open( "DATAFILE" ) ; // Error -910
is returned cout << "The error code is now set to " << cb.errorCode << endl; cb.errorCode = 0; cb.initUndo() ; Error Number: -1 or e4codeBase (Visual Basic Example)Sub Test() 'Assume datafile.dbf exists 'Force a -910 error by attempting to open twice 'Display the existing error code, and reset to zero as well form1.print "Calling d4top returns: " + Str$(d4top(db)) call code4initUndo( cb ) Error Number: -1 or e4codeBase (Delphi Example)Procedure Test; var begin { Assume datafile.dbf exists } { Force a -910 error by attempting to open twice } { Display the existing error code, and reset to zero as well } writeln( 'Calling d4top returns: ', d4top( db1 ) ) ; code4initUndo( cb ) ;
|
Back to the Sequiter Technical Support Page