Posted July 8th, 2009 by Andrew Popoff
Today I had find an annoying bug. I think that this bug exists elsewhere in my code.
I use a GROUP and OVER for defining the low and high-order words.
For example,
lParam LONG
lParamG GROUP,OVER(lParam)
low SHORT
high SHORT
END
I made a copy of this GROUP for ULONG-variable:
wParam ULONG
wParamG GROUP,OVER(wParam)
low SHORT
high SHORT
END
But it is wrong! I’ll need to define the each parameter of this group as UNSIGNED:
wParam ULONG
wParamG GROUP,OVER(wParam)
low USHORT
high USHORT
END
Tags: bug | No Comments »
Posted July 8th, 2009 by Andrew Popoff
I have not written here for a long time. This happened because I did not have interesting news. I was boring programming enterprise applications.
Tags: news.clarionlife.net | No Comments »
Posted June 12th, 2009 by Andrew Popoff

Today we are celebrate Russia Day. Actually I don’t know what is this day about. It is a just another holiday for me.
Tags: holiday | No Comments »
Posted June 9th, 2009 by Andrew Popoff
You can see a new community blog here.

I think that we can create a new forum at clarionlife.net. For example, en-forum.clarionlife.net
or sv-forum.clarionlife.net. We can
We have the popular forum for russian community at forum.clarionlife.net. You can see the our forum here (translated with Google).
Tags: Clarion 7, forum | No Comments »
Posted June 4th, 2009 by Andrew Popoff
I have a problem when using MS SQL 2008. The recovery model for my database is configured as a “Full“.
I do a full backup of the database every night. I do a transaction log backup every hour. The transaction log file for the two weeks of use has increased to 55Gb. The size of the database that is about 10Gb.
I have truncated the transaction log earlier using the following script:
MS SQL 2000
BACKUP LOG database_name WITH TRUNCATE_ONLY
DBCC SHRINKDATABASE (database_name, 10)
But this script does not work in MS SQL 2008. I found only one way to truncate the transaction log. The essence of the method is that it is necessary switch recovery model from FULL to SIMPLE, and make a truncation of the log.
I do a full backup of the database before performing this operation.
MS SQL 2008
ALTER DATABASE database_name SET RECOVERY SIMPLE
DBCC SHRINKFILE (log_name) WITH NO_INFOMSGS
ALTER DATABASE database_name SET RECOVERY FULL
It works
Tags: MS SQL Server | No Comments »
Posted June 1st, 2009 by Andrew Popoff
I was in a small vacation. Now I am ready to work
Tags: vacation | No Comments »
Posted May 19th, 2009 by Andrew Popoff
Today I tried to create a thread using Windows API. I always thought that there are no problems. But it turned out that I can not do anything. I can not even use the MESSAGE in the thread procedure. The application always crashes.
Below is the code that creates a new thread and simply increases the value of a variable. It works.
PROGRAM
MAP
MODULE('WinAPI')
CreateThread(LONG,LONG,LONG,LONG,LONG,LONG),ULONG,PASCAL,NAME('CreateThread')
memcpy(LONG,LONG,LONG),LONG,RAW,NAME('_memcpy'),PROC
END
TThreadProc(LONG lpParameter),PASCAL
END
Window WINDOW('Caption'),AT(,,129,115),FONT('MS Sans Serif',8,,FONT:regular),GRAY
BUTTON('Start thread'),AT(4,4,81,18),USE(?OkButton),DEFAULT
BUTTON('Show results'),AT(4,30,81,18),USE(?CancelButton)
END
ThreadID LONG
Param LONG
hThread ULONG
CODE
OPEN(Window)
DISPLAY
ACCEPT
CASE ACCEPTED()
OF ?OkButton
hThread = CreateThread(0,0,ADDRESS(TThreadProc),ADDRESS(Param),0,0)
MESSAGE('Thread handle: ' & hThread)
OF ?CancelButton
MESSAGE('Param: ' & Param)
END
END
TThreadProc PROCEDURE(LONG lpParameter)
loc:Var LONG
CODE
! MESSAGE('Enter TThreadProc') crashed
LOOP
loc:Var += 1
memcpy(lpParameter,ADDRESS(loc:Var),4)
END
Tags: Windows threads | No Comments »
Posted May 16th, 2009 by Andrew Popoff
SV Blog does not answer about a week. It is permissible for a single developer, but very strange for a stable company.
Tags: SV blog | No Comments »
Posted May 14th, 2009 by Andrew Popoff
Arcadia, Inc. is one of the leading Russian offshore software development companies, providing services to international clientele. Arcadia’s software development team is located in St. Petersburg, Russia.
Here you can see the Results of 2008 Year.
Tags: Arcadia | No Comments »
Posted May 13th, 2009 by Andrew Popoff
You can find my article Locating Records In Hand Coded List Boxes at Clarion Magazine.
Tags: Clarion Magazine | No Comments »
Posted May 12th, 2009 by Andrew Popoff
We use one table to create a tree normally. This table should contain at least two columns. One column is the identifier of the record. The second column is the identifier of the parent record.
Example:
Office
Lawyer department
Bob
John
Tech department
Dave
Michael
ID ParentID Desc
1 0 Office
2 1 Lawyer department
3 2 Bob
4 2 John
5 1 Tech department
6 5 Dave
7 5 Michael
If we want to climb up or down the tree, then typically we use a recursion. This works but not effective. This method becomes slow when the table becomes large.
To speed up the movement, you can add an additional field that will contain the path to the first parent. This is a string field. The format you can define yourself.
Example:
ID ParentID Path Desc
1 0 .1. Office
2 1 .1.2. Lawyer department
3 2 .1.2.3. Bob
4 2 .1.2.4. John
5 1 .1.5. Tech department
6 5 .1.5.6. Dave
7 5 .1.5.7. Michael
“Path”-field helps to easily and quickly identify all the children of the selected record. You should have the index for this field of course. You can create triggers that will automatically build the “Path”-field.
But it turned out that the definition of the parent of choosed record is too slow. So I found another way. The method is that you must add additional table, which contains all the parents’ IDs to the upper level for each record.
I have read about this method about two years ago and used it on a large SQL-tables.
Table Additional Table
ID ParentID Desc ID ParentID
1 0 Office 1 0
2 1 Lawyer department 2 1
3 2 Bob 2 0
4 2 John 3 2
5 1 Tech department 3 1
6 5 Dave 3 0
7 5 Michael 4 2
4 1
4 0
5 1
5 0
6 5
6 1
6 0
7 5
7 1
7 0
You can move up and down on the table more quickly. This method is suitable for tps-tables and for SQL. You must create an indexes of course. For SQL you can create triggers that will fill in the additional table. The additional table may also contain additional fields, for example, the “Level”-field.
Tags: trees | No Comments »
Posted May 12th, 2009 by Andrew Popoff
You can create a text file containing a one letter.
That means that the size of this file is 1 byte.
You can see the properties of this file in Explorer.
There are two properties:
- “Size” which displays the 1 byte
- “Size on disk” which displays the cluster size (for example 4096 bytes).
Tags: cluster size | No Comments »
Posted May 9th, 2009 by Andrew Popoff
Today we celebrate Victory Day. This is a special day for all people. Everyone in our country remembers that day, despite the fact that it has been for many years ago.

Tags: Victory Day | No Comments »
Posted May 6th, 2009 by Andrew Popoff
To transfer data, I made a backup of the database and just restored it to the new server. The speed of execution of queries has become much lower than on the old server.
I decided that it was necessary to rebuild all indexes in the database. You can do this using Management Studio. In this case, you will need to do this operation for each table. I have about 400 tables in the database. Therefore, it takes a long time.
I wrote a small script that performs these operations. I have updated statistics and clean the cache plans for queries at the end.
USE database_name
DECLARE @TableName varchar(255)
DECLARE @SqlQ char(260)
DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables WHERE table_type = 'base table'
OPEN TableCursor
FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SqlQ = 'ALTER INDEX ALL ON ' + @TableName +
' REBUILD WITH (FILLFACTOR = 90, SORT_IN_TEMPDB = ON,STATISTICS_NORECOMPUTE = ON);'
EXEC (@SqlQ)
SET @SqlQ = 'ALTER INDEX ALL ON ' + @TableName + ' REORGANIZE'
EXEC (@SqlQ)
FETCH NEXT FROM TableCursor INTO @TableName
END
CLOSE TableCursor
DEALLOCATE TableCursor
go
exec sp_msforeachtable 'update statistics ?'
go
dbcc freeproccache
go
Tags: MS SQL Server | No Comments »
Posted May 6th, 2009 by Andrew Popoff
I work for a large trading company. The company has about 10 shops selling home appliances in the city of Khabarovsk and two stores in other cities. The company has a division to develop software for their corporate needs. There are 5 programmers. I am engaged in the development and support programs for trade and services.
A week ago we got a new server. Now we transfer the program to a new MS SQL Server 2008. Previously, we have worked with MS SQL Server 2000. At first glance, the new server is running twice as fast:) But I think that there is still a lot of work.

Tags: work | No Comments »