Skip to content

Instantly share code, notes, and snippets.

View CarlTBarnes's full-sized avatar

Carl T. Barnes CarlTBarnes

View GitHub Profile
@CarlTBarnes
CarlTBarnes / AbcPreview_RptTest_AndWindow.clw
Last active July 22, 2026 21:28
Report Test Scratch Program
!Report Test ABCPreview And Window Framework by Carl Barnes from https://gist.github.com/CarlTBarnes
!Using ABC Report Previewer instead of my simple previewer
!
!This includes a Window to have controls to configure the Report output, and set the Printer, etc.
!
!-----------------------------------------------------------------------------
!Try various REPORT specs and PROP Settings quicky in this little Win32 project that has its own simple Previewer.
!If you want to report a bug this can be used to create a small example
!
!1. Create a new Win32 Project and paste this code.
@CarlTBarnes
CarlTBarnes / Scratch.clw
Last active June 30, 2026 21:24
Scratch source I use when I want to write a quick test of some code
PROGRAM !Scratch program by Carl Barnes - Version 8/1/2020 - Download https://git.io/JtPKE
INCLUDE('TplEqu.CLW')
INCLUDE('KeyCodes.CLW')
MAP
main PROCEDURE()
DB PROCEDURE(STRING DebugMessage)
DBClear PROCEDURE() !Clear DebugView Buffer
Hex8 PROCEDURE(LONG LongInt),STRING
Carl's Class Template to make a Basic Class: _Class_Make_Basic_v5.inc.clw
Find and Replace _Token_ like _ClassFile_ _ClassName_
Find and Replace __Proc_# with the Procedure Name you prefer. Add any addional. Optional, I used do this as I code each method.
Save this as 2 files an .INC and .CLW
!Region Class Description -----------------------------------------------------
! _ClassFile_ by Carl Barnes created on // for
!
! This Class description
@CarlTBarnes
CarlTBarnes / LenFastClip.clw
Last active September 14, 2025 18:36
LenFastClip replaces LEN(CLIP()) in ClaRUN.DLL as NAME('Cla$FASTCLIP')
Do not use
In testing Cla$FASTCLIP has problems in Release builds. I cannot recall exacyly what. I will not use it any longer.
Note that StringTheory docs show it was added, then removed
Version 3.23 - 13 June 2020
Fix: The use of FastClip has been removed. The function seems to be unreliable, failing one test in release mode (but nor debug mode) leading to an off-by-one error. Worse the problem is fixed by adding unrelated TRACE calls nearby, suggesting some sort of internal memory issue in the function.
---------------------------
MODULE('RTL')
LenFastClip PROCEDURE(CONST *STRING Text2Measure),LONG,NAME('Cla$FASTCLIP'),DLL(dll_mode)
@CarlTBarnes
CarlTBarnes / ReportPrintWithDebugLogging.clw
Last active September 9, 2025 14:40
ReportPrint() procedure Prints Details while logging to OutputDebugString. Can also add STRING to printed BAND to Identify it.
!Add local ReportPrint()
!Define: DbgString BYTE
!
!Change PRINT(Rpt:Detail) to ReportPrint(?Detail,'Rpt:Detail')
!If desired set DbgString=1 and each Band gets a String Label 'Rpt:Detail'
MAP
ReportPrint PROCEDURE(LONG BandFEQ, STRING BandName)
END
@CarlTBarnes
CarlTBarnes / PopupUnder.clw
Last active July 15, 2025 14:07
Popup() Menu Under or Beside a Control so Menu appears to drop under a Button
!Use the POPUP('xxx', X, Y, 1=Relative) to position a POPUP() right under a Button so it appears to drop down
!The fourth parameter is not documented well. Pass 1 to indicate the X/Y are Relative so can use Clarion GetPosition()
!
!Replace existing Popup() placing the ?Control as the first parameter
!Example: OF ?MenuBtn ; CASE PopupUnder(?,'Copy|Delete')
!---------------------------------------
MAP
PopupBeside(LONG BesideCtrlFEQ, STRING PopMenu),LONG
PopupUnder(LONG UnderCtrlFEQ, STRING PopMenu),LONG
PopupBeside PROCEDURE(LONG BesideCtrlFEQ, STRING PopMenu),LONG
@CarlTBarnes
CarlTBarnes / DebugOutput.clw
Last active October 7, 2024 20:21
OutputDebugString wrapper for Clarion String
DB PROCEDURE(STRING xMsg)
Prfx EQUATE('Prefix: ')
sz CSTRING(SIZE(Prfx)+SIZE(xMsg)+3),AUTO
CODE
sz=Prfx & CLIP(xMsg) & '<13,10>'
OutputDebugString(sz)
!----------------------------------------
DB PROCEDURE(STRING xMessage)
Prfx EQUATE('PrefixText: ') !All output gets this
sz CSTRING(SIZE(Prfx)+SIZE(xMessage)+3),AUTO
@CarlTBarnes
CarlTBarnes / Resize_Window_RewsCode.clw
Last active August 15, 2024 22:10
Resize Window using the LibSrc Legacy WindowResizeType class in ResCode.clw
!!! 1. In Global Data / Program add thse 2 lines
PRAGMA('compile(ResCode.CLW)')
INCLUDE('ResDef.CLW'),ONCE
!!! 2. For each Window to Resize
!!! 2a. Add to Procedure DATA
WinResize WindowResizeType
@CarlTBarnes
CarlTBarnes / TimeSplitAndJoin.clw
Last active July 5, 2024 20:02
TimeHMSh (Hour,Min,Sec) like DATE(). Also TimeSplit() Faster than using Hoiur() Minute() Second()
TimeSplit PROCEDURE(LONG Time2Split, <*? OutHour>, <*? OutMinute>, <*? OutSecond>, <*? OutHundred>)
TimeHMS PROCEDURE(LONG Hours=0, LONG Mins=0, LONG Secs=0, LONG Hundredths=0),LONG !Time Join H:M:S.D
TimeHMS2 PROCEDURE(BYTE Hours=0, BYTE Mins=0, BYTE Secs=0, BYTE Hundredths=0),LONG !Must have valid H,M,S
DateSplit PROCEDURE(LONG Date2Split, <*? OutMonth>, <*? OutDay>, <*? OutYear>)
!==========================================================================================================
TimeHMS PROCEDURE(LONG H=0, LONG M=0, LONG S=0, LONG Hundredths=0)!,LONG
!This allows out of range HMS values, e.g. you can pass 90 minutes
CODE
RETURN (H * 60*60*100) + | !3600 Seconds in 1 Hour *100=360,000
(M * 60*100) + | ! 60 Seconds in 1 Minute *100= 6,000
@CarlTBarnes
CarlTBarnes / DateSplit.clw
Last active June 28, 2024 20:11
DateSplit(Date, Month, Day, Year) much faster than calling MONTH() DAY() YEAR() separately
DateSplit PROCEDURE(LONG Date2Split, <*? OutMonth>, <*? OutDay>, <*? OutYear>)
!==========================================================================================================
DateSplit PROCEDURE(LONG Date2Split, <*? OutMonth>, <*? OutDay>, <*? OutYear>)
!Use DateSplit(Today,M,D,Y) instead of M=MONTH(Today) ; D=DAY(Today) ; Y=YEAR(Today)
D1 DATE,AUTO
DG GROUP, OVER(D1)
D BYTE
M BYTE
Y USHORT
END