Jump to content

FredS

Members
  • Content Count

    399
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by FredS


  1. 15 hours ago, pyscripter said:

    It turns out that the causes of LSP failure were more complex than I originally thought.

    Little has changed since Godzilla, or maybe some of that is back again.

     

    I still use a clean bat when switching between 'Build Configurations', that limits the problem even today. What it does is delete all DCUs which exist from all but the current 'Build Configuration'.

     


  2. 4 hours ago, PawelPepe said:

    But, this can not send mail with default client... so the best is to run any app with normal user privileges.

    Not so simple then, I've not seen running code that executes with identical integrity, tokens and access..
    A few posts on SO claim to have solved it but the Scheduler works so I've found no need to retest all for that..

     

    ShellRun('Open', 'Schtasks', '/Create /F /SC ONCE /TN taskname /TR "<cmd>" /ST 00:00', swHide);
    ShellRun('Open', 'Schtasks', '/Run /TN taskname', swHide);
    ShellRun('Open', 'Schtasks', '/Delete /F /TN taskname', swHide);

    Add some error checking and it works..

     

    • Thanks 1

  3. 11 minutes ago, Fr0sT.Brutal said:

    MSBuild doesn't expand $(..)-

     

    This is how I compile with older versions of controls.. might help you get started.
    The CMD file is in the project root and changes directory to Source:

    @ECHO OFF
    ::
    :: How to Redirect to an older Version of VCL
    :: Since no IDE is required this will work for NON installed versions of any VCL controls
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    ::
    :: Redirect DX, to compile with source we need to update all these
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    REM @SET DXVCL=%VCL%\DevExpress VCL\20.2.8 (26-May-2021) for PA2-R12
    REM IF NOT Exist "%DXVCL%" (
            REM echo."%DXVCL%", Directory does not exist
            REM Pause )
    REM CALL :SetEnvVar "DXLibs"
    REM CALL :SetEnvVar "DXSources"
    REM SET DX
    REM pause
    
    ::
    :: Redirect UNI, to compile with source we need to update all these
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    REM @SET UNIVCL=%VCL%\UniDAC\9.0.1 (14-Sep-2021)
    REM IF NOT Exist "%UNIVCL%" (
            REM echo."%UNIVCL%", Directory does not exist
            REM Pause )
    REM CALL :SetEnvVar "UNILIB"
    REM CALL :SetEnvVar "UniSources"
    REM SET Uni
    REM pause
    
    ::
    :: Environmental Vars declared in the IDE must be redeclared 
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @SET CompilerV=28
    @SET ProductVersion=22.0
    @SET IDEVER=11.0.2
    ::
    :: Now expand those with rsVars.bat
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    call "C:\Program Files (x86)\Embarcadero\Studio\22.0\bin\rsvars.bat"
    ::
    :: Reset the rsVars.bat defaults
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @SET BDSCOMMONDIR=D:\Embarcadero Studio\22.0
    ::
    ::  Add the location of cmd.exe
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    @SET PATH=%WINDIR%\System32;%PATH%
    
    cd source
    :: Recomended in 10.4 Release Notes..
    MSBuild APP.dproj /t:clean
    
    REM TIMEOUT /T 10
    MSBuild APP.dproj /t:build /v:q /p:Config=Release /p:platform=Win64
    cd ..
    
    ::  View any output notices
    pause
    
     :: ========== FUNCTIONS ==========
    EXIT /B
    
    :: Read a Value from Environment
    :: Param 1: Name of output variable.
    :: Param 2: SubKey.
    :RegQueryEnv 
    @ECHO OFF
    SET KEY="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
    :: Remove the double quotes
    Set SUBKEY=%~2
    FOR /F "skip=2 tokens=2,*" %%A IN ('reg.exe query %KEY% /v "%SUBKEY%"') DO (
        set %1=%%B )
    EXIT /B
    
    :: Expand any EnvVars in the Text
    :: Param 1: Name of output variable.
    :: Param 2: Text to Expand (%UNIVCL%\Lib\Delphi$(CompilerV))
    :ExpandEnvVar
    @ECHO OFF
    set %1=%~2
    REM echo.ExpandEnvVar=%Text% 
    EXIT /B
    
    :: Combines RegQuery and ExpandEnvVar then uses @SET
    :: Param 1: SubKey.
    :SetEnvVar
    @ECHO OFF
    CALL :RegQueryEnv Value %1
    CALL :ExpandEnvVar Value "%Value%"
    @SET %~1=%Value%
    

     

    • Thanks 1

  4. 57 minutes ago, dkprojektai said:

    Can you share ?

    I can show you an example but most of my code uses internal stuff.
    But let me make one thing clearer; the action after Beyond Compare is manual NOT automatic..

     

    In short, after comparing the prior db creation script with the new one methods within the Patching unit are called manually..

     

    This example increase the Size of a [N]Varchar Column using UniDAC, FB3/4 and SqlServer dbs:

    /// <summary>
    ///   Increase the Size of a [N]Varchar Column
    /// </summary>
    /// <param name="NullKind">
    ///   Must be given else some dbs default to allowing nulls when you make changes
    /// </param>
    class procedure TExecSqlPatch.IncVarChar(const Con: TUniConnection; const ATable, AColumn: string; const NewSize: Word; const NullKind: TNullKind);
    {$REGION 'History'}
    //  29-Aug-2018 - ExecuteSQL does not return any usefull count for these Block calls
    {$ENDREGION}
    var sql: string;
    begin
      case Con.DbProvider of
        dbFirebird: begin
            sql := 'EXECUTE block as BEGIN ' +
                   ' if (exists(select 1 from RDB$RELATION_FIELDS rf where rf.RDB$RELATION_NAME = :TableName and rf.RDB$FIELD_NAME = :ColumnName))' + CRLF +
                   ' then execute statement ' + 'ALTER TABLE :TableRaw ALTER COLUMN :ColumnRaw Type VARCHAR(:NewSize)'.ToQuoted + SEMICOLON + CRLF +
                   'END';
            sql.ReplaceParams([ATable.ToUpper, AColumn.ToUpper, ParamRaw + ATable.ToUpper, ParamRaw + AColumn.ToUpper, NewSize]).Error.Assert;
            Con.ExecuteSQL(sql);
            sql := 'EXECUTE block as BEGIN ' +
                   ' if (exists(select 1 from RDB$RELATION_FIELDS rf where rf.RDB$RELATION_NAME = :TableName and rf.RDB$FIELD_NAME = :ColumnName))' + CRLF +
                   ' then execute statement ' + 'ALTER TABLE :TableRaw ALTER :ColumnRaw :NullKind NOT NULL'.ToQuoted + SEMICOLON + CRLF +
                   'END';
            sql.ReplaceParams([ATable.ToUpper, AColumn.ToUpper, ParamRaw + ATable.ToUpper, ParamRaw + AColumn.ToUpper,  ParamRaw + cFB3NullKind[NullKind]]).Error.Assert;
            Con.ExecuteSQL(sql);
        end;
        dbSQLServer: begin
            sql := 'IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE [TABLE_NAME] = :Table AND [COLUMN_NAME] = :Column) ' + CRLF +
                   'BEGIN ' + CRLF +
                   '  ALTER TABLE :TableRaw ALTER COLUMN :ColumnRaw NVARCHAR(:NewSize) :NullKind  ' + CRLF +
                   'END ';
            sql.ReplaceParams([ATable.ToUpper, AColumn.ToUpper, ParamRaw + ATable.ToUpper, ParamRaw + AColumn.ToUpper, NewSize, ParamRaw + cMSSQLNullKind[NullKind]]).Error.Assert;
            Con.ExecuteSQL(sql);
        end;
        else raise ENotImplemented.Create('Not Implemented');
      end;
    end;

     

    • Like 1

  5. 7 hours ago, dkprojektai said:

    Asking for advice quicker solution.

    I wrapped most Alter statements into a 'SQL.Patching.pas' unit which fires what is needed depending on a version field at startup.

    Found the simplest way was to make all changes and then use Beyond Compare on the db creation script to generate an output which is used to call the methods in the Patching unit.

×