Advertisement
ASP_Volume2 Data Structures #30103

Check if dynamic array dimensioned already

Tells if a dynamic array has been dimensioned or not. Lu

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Upload
Function Member(ary$(), text$)
  On Local Error GoTo MemberExit
  For i = 1 To UBound(ary$)
    If text$ = ary$(i) Then
      subscript = i
      Exit For
    End If
  Next
MemberExit:
  Member = subscript  
End Function
;========================================
another possibility;
Function ArrayElements(ary$())
  elements = 0    
  On Local Error GoTo MemberExit
  elements = UBound(ary$)
MemberExit:
  ArrayElements = elements
End Function

So here it is then, a 3 step process.
[1] Put the following function declaration in the INTERFACE section of any unit of your project,
immediately prior to the IMPLEMENTATION section header;
Function AlreadyRunning: Boolean;
[2] and the following function in the IMPLEMENTATION section of that same unit;
Function AlreadyRunning: Boolean;
Var
  MutexHandle: THandle;
Begin
   Result:=False; 
   MutexHandle:=CreateMutex(nil,TRUE,'NameofMyProgram-version1.2.3'); 
   // 'NameofMyProgram-version1.2.3' can be any text string, it just needs to be unique to each program. 
   If MutexHandle<>0 then
     If GetLastError=ERROR_ALREADY_EXISTS then
      Result:=True; // Yes, this Mutex does already exist, this program is already running!
end; 
[3] Finally, in your Project source file (the .DPR) in the main "Begin ... End." clause do this;
Begin // existing line
 If not AlreadyRunning then
 begin
  // inside here will be ALL the existing code that already was in the main "Begin ... End." clause.
 end;
End. // existing line

Dim myGridTableStyle As DataGridTableStyle = New DataGridTableStyle()
    'Map the style to the dataset table. In this case I only use one table 
    ' in my query.
    myGridTableStyle.MappingName = "Insured"
    grdQuotes.TableStyles.Add(myGridTableStyle)
    myGridTableStyle.GridColumnStyles(0).Width = 0
    myGridTableStyle.GridColumnStyles(1).Width = 250
    myGridTableStyle.GridColumnStyles(2).Width = 250
Original Comments (3)
Recovered from Wayback Machine