# Snippets

**URL:** https://clarionhub.com/c/code/snippets/14.md

[Latest](https://clarionhub.com/latest.md) · [Categories](https://clarionhub.com/categories.md) · [Tags](https://clarionhub.com/tags.md)

---

## [About the Snippets category](https://clarionhub.com/t/about-the-snippets-category/34)

<div class="topic-metadata">

**Author:** [@brahn](https://clarionhub.com/u/brahn)\
**Replies:** 3\
**Last updated:** [August 1, 2014, 10:14pm UTC](https://clarionhub.com/t/about-the-snippets-category/34 "2014-08-01T22:14:41Z")

</div>

Share and discuss code snippets.

---

## [Template for generating Column and Group equates for ABC browse](https://clarionhub.com/t/template-for-generating-column-and-group-equates-for-abc-browse/3930)

<div class="topic-metadata">

**Author:** [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Replies:** 1\
**Last updated:** [April 23, 2024, 2:39pm UTC](https://clarionhub.com/t/template-for-generating-column-and-group-equates-for-abc-browse/3930 "2024-04-23T14:39:37Z")

</div>

I took Rick's template for Generating Column Equates and added Equates for LIST Groups. Everything Rick said applies to Groups also. Instead of using hard-coded numeric constants for column numbers in code for manipula…

---

## [Convert Clarion Standard Time to SQL Time or SQL Time to Clarion Time](https://clarionhub.com/t/convert-clarion-standard-time-to-sql-time-or-sql-time-to-clarion-time/1281)

<div class="topic-metadata">

**Author:** [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Replies:** 2\
**Last updated:** [April 1, 2024, 4:43pm UTC](https://clarionhub.com/t/convert-clarion-standard-time-to-sql-time-or-sql-time-to-clarion-time/1281 "2024-04-01T16:43:45Z")

</div>

If you have an INT data type in your SQL database that hold a Clarion Time value you can convert it to SQL Time using this snippet: select convert(time, dateadd(ms, (ClarionTimeField-1)\*10,0)) or to get a text format t…

---

## [Using WriteConsoleA from a Clarion application](https://clarionhub.com/t/using-writeconsolea-from-a-clarion-application/1734)

<div class="topic-metadata">

**Author:** [@brahn](https://clarionhub.com/u/brahn)\
**Replies:** 9\
**Last updated:** [February 1, 2024, 11:12pm UTC](https://clarionhub.com/t/using-writeconsolea-from-a-clarion-application/1734 "2024-02-01T23:12:19Z")

</div>

Today I was inspired to respond to a StackOverflow question and pulled this example together from pieces I found on the newsgroup :slight\_smile: Compile the program, run it from a command line and mash the button! …

---

## [Find blocked and blocking sessions in MSSQL](https://clarionhub.com/t/find-blocked-and-blocking-sessions-in-mssql/6741)

<div class="topic-metadata">

**Author:** [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Replies:** 2\
**Last updated:** [November 2, 2023, 6:44pm UTC](https://clarionhub.com/t/find-blocked-and-blocking-sessions-in-mssql/6741 "2023-11-02T18:44:36Z")

</div>

Here are a couple of queries i use extensively while tracking down blocking issues in SQL server. This query shows all the lead blockers. A lead blocker is a session that is blocking other sessions but is not being bloc…

---

## [Function to create a GUID](https://clarionhub.com/t/function-to-create-a-guid/6580)

<div class="topic-metadata">

**Author:** [@JonW](https://clarionhub.com/u/JonW)\
**Replies:** 6\
**Last updated:** [September 11, 2023, 11:39am UTC](https://clarionhub.com/t/function-to-create-a-guid/6580 "2023-09-11T11:39:15Z")

</div>

With Acknowledgements to Randy Rogers and Graham Dawson, here's how to add a function to create GUIDs to your app. Use LibMaker to create a .lib file for rpcrt4.lib, which you will find in Windows\\SYSWOW64 Add rpcr…

---

## [Creating custom-limited droplists: an example](https://clarionhub.com/t/creating-custom-limited-droplists-an-example/6339)

<div class="topic-metadata">

**Author:** [@JonW](https://clarionhub.com/u/JonW)\
**Replies:** 0\
**Last updated:** [June 21, 2023, 4:25pm UTC](https://clarionhub.com/t/creating-custom-limited-droplists-an-example/6339 "2023-06-21T16:25:09Z")

</div>

Attached to this post is a little demonstration of how to provide customized dropdown lists. A common requirement is that a dropdown list needs to be limited based on a previous choice on a form. Sometimes that previous…

---

## [Example App - Using a CLASS - Clarion 8](https://clarionhub.com/t/example-app-using-a-class-clarion-8/5633)

<div class="topic-metadata">

**Author:** [@donridley](https://clarionhub.com/u/donridley)\
**Replies:** 0\
**Last updated:** [November 11, 2022, 3:18pm UTC](https://clarionhub.com/t/example-app-using-a-class-clarion-8/5633 "2022-11-11T15:18:38Z")

</div>

One of the members of our community reached out to me for help with understanding CLASSes. I quickly put together an example app demonstrating a few techniques. I am no expert and feel free to modify. Compiled in C8. …

---

## [Qr Code Printing in C11](https://clarionhub.com/t/qr-code-printing-in-c11/5519)

<div class="topic-metadata">

**Author:** [@J\_B](https://clarionhub.com/u/J_B)\
**Replies:** 1\
**Last updated:** [October 12, 2022, 5:09pm UTC](https://clarionhub.com/t/qr-code-printing-in-c11/5519 "2022-10-12T17:09:08Z")

</div>

Using External program

---

## [PostgreSQL Tip to see if a database exists before continuing](https://clarionhub.com/t/postgresql-tip-to-see-if-a-database-exists-before-continuing/5490)

<div class="topic-metadata">

**Author:** [@KevinErskine](https://clarionhub.com/u/KevinErskine)\
**Replies:** 6\
**Last updated:** [October 9, 2022, 2:25pm UTC](https://clarionhub.com/t/postgresql-tip-to-see-if-a-database-exists-before-continuing/5490 "2022-10-09T14:25:17Z")

</div>

Just sharing some PSQL tip I came up with to solve an issue I did not have to worry about in TPS land. So I am in the process of changing a TPS system to PSQL. One of our applications cycles through all our databases (…

---

## [Send emails from GMail](https://clarionhub.com/t/send-emails-from-gmail/3703)

<div class="topic-metadata">

**Author:** [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Replies:** 6\
**Last updated:** [March 24, 2022, 5:07pm UTC](https://clarionhub.com/t/send-emails-from-gmail/3703 "2022-03-24T17:07:35Z")

</div>

Sending emails from gmail using smtp protocol requires “Less secure apps” to be enabled in Google account. Otherwise you must use Google REST API. Suppose you have a project in Google developer console which enables GMa…

---

## [Limit number of running threads with NewNamedSemaphore and GetSemaphore example](https://clarionhub.com/t/limit-number-of-running-threads-with-newnamedsemaphore-and-getsemaphore-example/4618)

<div class="topic-metadata">

**Author:** [@elankreijer](https://clarionhub.com/u/elankreijer)\
**Replies:** 4\
**Last updated:** [December 13, 2021, 11:20pm UTC](https://clarionhub.com/t/limit-number-of-running-threads-with-newnamedsemaphore-and-getsemaphore-example/4618 "2021-12-13T23:20:31Z")

</div>

To limit the number of running threads in a application, this code can be used. Please not that some templates and derived WindowManager classes don’t like being terminated by RETURN LEVEL:Notify from the Init() method.…

---

## [Limit number of running applications with NewNamedSemaphore example](https://clarionhub.com/t/limit-number-of-running-applications-with-newnamedsemaphore-example/4617)

<div class="topic-metadata">

**Author:** [@elankreijer](https://clarionhub.com/u/elankreijer)\
**Replies:** 2\
**Last updated:** [November 17, 2021, 5:02pm UTC](https://clarionhub.com/t/limit-number-of-running-applications-with-newnamedsemaphore-example/4617 "2021-11-17T17:02:02Z")

</div>

To limit the number of running application, this code can be used. In this example the limit will by set by a value set in the database, the limiting has to be done after open files. Please not that some templates and d…

---

## [ButtonTiles Class](https://clarionhub.com/t/buttontiles-class/474)

<div class="topic-metadata">

**Author:** [@brahn](https://clarionhub.com/u/brahn)\
**Replies:** 36\
**Last updated:** [September 4, 2021, 8:00am UTC](https://clarionhub.com/t/buttontiles-class/474 "2021-09-04T08:00:54Z")

</div>

Here is something I created the other day that seems quite nicely self contained and fairly straight forward. It turns a button into a tile. Inspiration from DevExpress Tile Navigation Control but not even trying to …

---

## [Progress Bar API Tricks - Marquee, State Color, Reverse](https://clarionhub.com/t/progress-bar-api-tricks-marquee-state-color-reverse/4315)

<div class="topic-metadata">

**Author:** [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Replies:** 4\
**Last updated:** [July 16, 2021, 7:01pm UTC](https://clarionhub.com/t/progress-bar-api-tricks-marquee-state-color-reverse/4315 "2021-07-16T19:01:17Z")

</div>

I uploaded an example to GitHub of how to change a Clarion Progress Bar to use some API features. You cannot chnage the Prop:Color of a Progress if a Visual Styles Manifest is used. What you can do is change via the API…

---

## [BlobToBlob - code to copy a Blob directly to another Blob](https://clarionhub.com/t/blobtoblob-code-to-copy-a-blob-directly-to-another-blob/4279)

<div class="topic-metadata">

**Author:** [@MarkGoldberg](https://clarionhub.com/u/MarkGoldberg)\
**Replies:** 1\
**Last updated:** [July 1, 2021, 2:41pm UTC](https://clarionhub.com/t/blobtoblob-code-to-copy-a-blob-directly-to-another-blob/4279 "2021-07-01T14:41:04Z")

</div>

There was a conversation on Skype CW-Talk about a loop to copy one table to another, where the tables included a blob. It was pointed out that StringTheory has code that does this fairly cleanly However that approach h…

---

## [Full screen mode](https://clarionhub.com/t/full-screen-mode/4116)

<div class="topic-metadata">

**Author:** [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Replies:** 0\
**Last updated:** [May 10, 2021, 2:43pm UTC](https://clarionhub.com/t/full-screen-mode/4116 "2021-05-10T14:43:44Z")

</div>

Here is an example of Full screen mode (exe and all sources). “Full screen mode” is real full screen mode - the window occupies all available space on a monitor including system taskbar. It should work also in tablet mo…

---

## [OPTION and RADIO conversion to Drop LIST FROM()](https://clarionhub.com/t/option-and-radio-conversion-to-drop-list-from/4081)

<div class="topic-metadata">

**Author:** [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Replies:** 6\
**Last updated:** [May 1, 2021, 2:52am UTC](https://clarionhub.com/t/option-and-radio-conversion-to-drop-list-from/4081 "2021-05-01T02:52:24Z")

</div>

I had a window with 7 OPTION controls where we needed to make it smaller so decided to change those to Drop Lists. Instead of the tedious hand conversion I created a small procedure to read the PROPs and generate the LIS…

---

## [Event when Menu is Opened - Is a Menu Dropped?](https://clarionhub.com/t/event-when-menu-is-opened-is-a-menu-dropped/4037)

<div class="topic-metadata">

**Author:** [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Replies:** 1\
**Last updated:** [April 13, 2021, 3:10am UTC](https://clarionhub.com/t/event-when-menu-is-opened-is-a-menu-dropped/4037 "2021-04-13T03:10:03Z")

</div>

The recent discussion of knowing when a Combo is dropped reminded me of the question of getting an Event before the Menus open so they can be modified based on the current state. There are Windows Messages for this so S…

---

## [Menu Items in 2 Columns with Prop:Max=1](https://clarionhub.com/t/menu-items-in-2-columns-with-prop-max-1/3935)

<div class="topic-metadata">

**Author:** [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Replies:** 9\
**Last updated:** [March 13, 2021, 1:46am UTC](https://clarionhub.com/t/menu-items-in-2-columns-with-prop-max-1/3935 "2021-03-13T01:46:29Z")

</div>

I just noticed at the bottom of the help on MENUBAR its possible to force 2 columns of ITEMs. That's not mentioned in ITEM or MENU or PROP:Max. A two-column drop menu can be achieved by assigning PROP:Max = 1 to the IT…

---

## [My PhoneMaskHandler class](https://clarionhub.com/t/my-phonemaskhandler-class/3543)

<div class="topic-metadata">

**Author:** [@brahn](https://clarionhub.com/u/brahn)\
**Replies:** 12\
**Last updated:** [September 16, 2020, 11:49pm UTC](https://clarionhub.com/t/my-phonemaskhandler-class/3543 "2020-09-16T23:49:09Z")

</div>

Thanks to the folks on Skype chat last night who helped resolve my un-brain moment I was able to resolve my "find the next control" issue and complete this handy little class. If you have a prompt with the text phone, f…

---

## [Move a clarion window from clicking on a region](https://clarionhub.com/t/move-a-clarion-window-from-clicking-on-a-region/37)

<div class="topic-metadata">

**Author:** [@brahn](https://clarionhub.com/u/brahn)\
**Replies:** 11\
**Last updated:** [August 21, 2020, 5:56am UTC](https://clarionhub.com/t/move-a-clarion-window-from-clicking-on-a-region/37 "2020-08-21T05:56:35Z")

</div>

This is something I have used in the ClarionMetroWizard project to move allow you to move a window that doesn’t have a title bar. NOTE: Look here for a more correct implementation - http://support.microsoft.com/kb/11459…

---

## [Clarion LIST horizontal scroll events](https://clarionhub.com/t/clarion-list-horizontal-scroll-events/3355)

<div class="topic-metadata">

**Author:** [@brahn](https://clarionhub.com/u/brahn)\
**Replies:** 1\
**Last updated:** [June 9, 2020, 2:36pm UTC](https://clarionhub.com/t/clarion-list-horizontal-scroll-events/3355 "2020-06-09T14:36:00Z")

</div>

Thanks @Rick\_UpperPark for the example. Using some other examples found on the newsgroups I have made a working demo. Full source in the ClarionClasses github project: Specifically, this!

---

## [Template for generating column equates for ABC browse](https://clarionhub.com/t/template-for-generating-column-equates-for-abc-browse/2763)

<div class="topic-metadata">

**Author:** [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Replies:** 13\
**Last updated:** [June 5, 2020, 5:27pm UTC](https://clarionhub.com/t/template-for-generating-column-equates-for-abc-browse/2763 "2020-06-05T17:27:42Z")

</div>

Instead of using hard-coded numeric constants for column numbers in code for manipulating your list control columns, it is better to use an equate for the column number. Hard-coded column numbers can become incorrect wh…

---

## [Enumerating Fields in a GROUP or QUEUE - How do you know you've reached the end?](https://clarionhub.com/t/enumerating-fields-in-a-group-or-queue-how-do-you-know-youve-reached-the-end/2340)

<div class="topic-metadata">

**Author:** [@jslarve](https://clarionhub.com/u/jslarve)\
**Replies:** 37\
**Last updated:** [May 6, 2020, 12:15am UTC](https://clarionhub.com/t/enumerating-fields-in-a-group-or-queue-how-do-you-know-youve-reached-the-end/2340 "2020-05-06T00:15:36Z")

</div>

I think I figured out a pretty decent way to know when you've reached the end of a GROUP/QUEUE when processing for WHO/WHAT. If you use WHO(), you can't rely on a label existing. If you test for MyANY &= NULL, you don'…

---

## [This code is useful to Audit all SQL tables for Insert, Update & Delete](https://clarionhub.com/t/this-code-is-useful-to-audit-all-sql-tables-for-insert-update-delete/1607)

<div class="topic-metadata">

**Author:** [@SerhatSatir](https://clarionhub.com/u/SerhatSatir)\
**Replies:** 3\
**Last updated:** [April 3, 2020, 4:51pm UTC](https://clarionhub.com/t/this-code-is-useful-to-audit-all-sql-tables-for-insert-update-delete/1607 "2020-04-03T16:51:22Z")

</div>

Also, this code is useful to audit all SQL tables for Insert, Update & Delete… /\* -- Delete all audit triggers (for regeneration only) DECLARE @sql varchar(8000), @TABLE\_NAME sysname SET NOCOUNT ON SELECT @TABLE\_NAME=…

---

## [Overriding standard clarion errors with your own mesage or adding additional errors](https://clarionhub.com/t/overriding-standard-clarion-errors-with-your-own-mesage-or-adding-additional-errors/3087)

<div class="topic-metadata">

**Author:** [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Replies:** 1\
**Last updated:** [February 5, 2020, 5:36pm UTC](https://clarionhub.com/t/overriding-standard-clarion-errors-with-your-own-mesage-or-adding-additional-errors/3087 "2020-02-05T17:36:14Z")

</div>

The GlobalErrors class has support for providing your own messages instead of the standard one. You can also add your own errors that can be displayed using GlobalErrors.Throw(CustomErrorNumber) First declare your erro…

---

## [How to change a checkbox control value if you only have the FEQ?](https://clarionhub.com/t/how-to-change-a-checkbox-control-value-if-you-only-have-the-feq/185)

<div class="topic-metadata">

**Author:** [@brahn](https://clarionhub.com/u/brahn)\
**Replies:** 1\
**Last updated:** [January 30, 2020, 3:26am UTC](https://clarionhub.com/t/how-to-change-a-checkbox-control-value-if-you-only-have-the-feq/185 "2020-01-30T03:26:02Z")

</div>

For some reason I always forget this one and have to figure it out each time so I thought I would note it here for future reference! This is for the situation where you know the FEQ of a CHECK control and want to change…

---

## [Get Compiler Version & Build Config for use in a PostCompile Build action](https://clarionhub.com/t/get-compiler-version-build-config-for-use-in-a-postcompile-build-action/169)

<div class="topic-metadata">

**Author:** [@MarkGoldberg](https://clarionhub.com/u/MarkGoldberg)\
**Replies:** 3\
**Last updated:** [May 24, 2019, 7:56pm UTC](https://clarionhub.com/t/get-compiler-version-build-config-for-use-in-a-postcompile-build-action/169 "2019-05-24T19:56:09Z")

</div>

The following .cmd (.bat) file looks at the TASKLIST and gets the WindowTitle and parses that @for /F "skip=9 tokens=2,3 delims=\[\]" %%I in ('tasklist /FI "IMAGENAME eq CLARION.EXE" -v /FO LIST') do @SET CompilerVer=%%I &…

---

## [References can be flexible](https://clarionhub.com/t/references-can-be-flexible/2343)

<div class="topic-metadata">

**Author:** [@jslarve](https://clarionhub.com/u/jslarve)\
**Replies:** 2\
**Last updated:** [January 7, 2019, 8:28pm UTC](https://clarionhub.com/t/references-can-be-flexible/2343 "2019-01-07T20:28:56Z")

</div>

From SV Support today, I learn't this: "ANY reference can receive a reference to any data type.". Although that doesn't seem to be the case for everything that I've tried, this compiles and works. PROGRAM Q &QUEUE …

[Next page](https://clarionhub.com/c/code/snippets/14.md?page=1)
