Home  
Cars Clarion Concerts Attended Dokken Elvis Book Music My Apps ROIO Software Picks Surname WinDev Contact Me Website Updates  
 

I've used Clarion for Windows since version 1.0 was released. Along the way I've picked up (or learnt the hard way) some useful tricks that may benefit some one else:


CPCS Reports Tip #1

When printing labels sometimes you experience "label creep" - this is due to some printers not supporting PAPER:USER equate properly. To circumvent the problem try this code:

! Code to not set paper size if specified as 8.5x11 because certain printers

! can't do this (example: HP600 Inkjet printer)

IF Lab:Paperwidth <> 8500 OR Lab:PaperHeight <> 11000

REPORT{PROPPRINT:Paper} = PAPER:User

REPORT{PROPPRINT:PaperHeight} = Lab:PaperHeight*254/1000

REPORT{PROPRINT:PaperWidth} = :ab:PaperWidth*254/1000 + 250

END


CPCS Reports Tip #2

To force the printer to skip "x" number of labels on a sheet use this code:

! Before Printing Detail embed

IF~Done#

LOOP FirstLabel# -1 Times

  PRINT(RPT:Detail) !or whatever the report detail band is named

END

Done# = True

END


Date Conversion #1

To convert a 5 position julian date (ex: 97240) to a mm/dd/yy format:

JulianStr = '97240'                  ! example variable/field value

YY = JulianStr[ 1:2 ]                 ! YY = short data type

Days = JulianStr[ 3:5 ]               ! Days = short data type

Gregorian = DATE(1,1,YY) + Days - 1    ! Gregorian = long data type  

StringDate = FORMAT( Gregorian, @D01 ) ! Yields mm/dd/yy value


Date Conversion #2

To figure out the number of a day:

nDOW = StandardDate % 7       ! Note the percentage sign

 

Date Conversion #3

To figure out the number of the week:

Execute(YourDate % 7) + 1

DayOfWeek = 'Sunday'

DayOfWeek = 'Monday'

DayOfWeek = 'Tuesday'

DayOfWeek = 'Wednesday'

DayOfWeek = 'Thursday'

DayOfWeek = 'Friday'

DayOfWeek = 'Saturday'

End


Forms #1

To highlight an entry field (ex: all required fields will be colored yellow) you can add the following type of code in the Before Opening Window embed:

?entryfieldname{PROP:BACKGROUND} = COLOR:YELLOW


Forms #2

Scenario: if a field contains a value you want to skip to a field other then the next field on the form. To perform this trick:

1. Right click on the beneath the "owner" field, then select this embed:

    Control Event Handling, After Generated Code, Accepted

2. Click on SOURCE and type in the following:

    IF(MasterFieldName) = 0

      select(?NextFieldUseName)

    END


Handy Tools

To modify records that are tagged from a file-loaded listbox (using the CwHandy tagging template) you can use this psuedo-code:

LOOP Ndx = 1 TO RECORDS(BRW1.Q)

! Get the current queue record

GET(BRW1.Q, Ndx)

IF BRW1.Q.MARK = True THEN

  ! Fetch the corresponding file record from the queue information

  PEO:ID = BRW1.Q.PEO:ID

  IF Access:People.Fetch(PEO:KeyID) = LEVEL:Benign THEN

    ! Do whatever action you need to the tagged record here

  END

END

END


Language #1

To use the Windows API to remove a file from a drive:

In the GLOBAL Embed - Inside MAP type in this:

MODULE('CLA')

   API_Remove(*CString),Short,Raw,Name('_remove')

END


In the local or global declarations declare a FileName variable and a variable to hold the function return value:


Glo:Filename CString(80)

Glo:RemoveRet Short


In the code type in this:


Glo:Filename = 'invoice.bak' ! or whatever the file is you wish to kill

Glo:RemoveRet = API_Remove(Glo:Filename)


Language #2

To use the Windows API to check for a files existence:

MODULE('cwapi')

  notexist(*CSTRING,SHORT),SHORT,RAW,NAME('_access')

END


This definition puts in the Global Properties Embed 'inside global MAP' as sourcecode. It returns a value of zero if the file wasn't found:


if ~ notexist('command.com',0)  ! means the file existed


Language #3

To execute a DOS command (remember those?) you have to first load COMMAND.COM when using the RUN command. Your code would resemble:

RUN('c:\command.com /c COPY file1 file2)


The /c parameter tells the command interpreter to exit after completing the command


Listbox #1

To display an icon in a listbox column:

1. Open the browse procedure, right click on the listbox and select 'Properties'

2. For the desired column on it's properties ensure the option for Icons is checked

3. Change the data picture to @P_PB, then click the OK button to accept


The @P_PB picture is crucial - otherwise the field value will be displayed in the column.


Listbox #2

To conditionally disable the right click popup menu:

!Embed this in BrwX.TakeNewSelection before the parent call

IF (PopupCondition = True)

  IF keycode() = MouseRightUp

   setkeycode(0)

  END

END


Query Wizard #1

If you are getting an error when a query is executed stating "Invalid Query' you need to manually bind field(s). Stick this code in this embed insert:

Beginning of Procedure, Before Opening Files


BIND(xxx:Record)           ! xxx = the data file prefix


Note(s): You have to insert this line for EACH data file used in the procedure! For example, if you have three files (CUStomer, ORDers and CREdit) you would insert the following:


BIND(CUS:Record)

BIND(ORD:Record)

BIND(CRE:Record)


Query Wizard #2

For a report procedure if the user pressed the ESC key when the query picklist is displayed and you want the report to still process - add this code in this embed:

File: Preparing to Process the Window


IF TCQW:Reponse = TCQW:RequestCancelled

IF MESSAGE('Do you wish to continue the report without a query?', |

           'Query Cancelled', ICON:Question, |

           BUTTON:Yes+BUTTON:No, |

           BUTTON:Yes) = Button:No

   GlobalResponse = RequestCancelled

   DO ProcedureReturn

END

END 


Query Wizard #3

To display a popup window if the query returned no records place this code in this embed:

File: End of Procedure, After Closing Files


IF NOT RecordsProcessed AND NOT GlobalResponse = RequestCancelled

  MESSAGE('No records meeting the query criteria were found', |

           'Report not printed', ICON:Exclamation,BUTTON:Ok, 0)

END


Query Wizard #4

To create a context sensitive help file for QW you can obtain the HelpID equate names from inside the TCQW.CLW file.


ReportDAT!

To skip the Win.Ini file to look for the ReportDAT! CT*.TPS files use this variable:

Glo:CT_PathName = 'E:\Somepath'


Make sure this code is embedded PRIOR to running the crosstab report!


Strings

To place carriage returns with string characters:

cAddress = clip(name) & '<<13><<10>' & clip(address1) & '<<13><<10>'


Notice that the '<' symbol has to be duplicated due to the Clarion compiler.


Windows #1

To retrieve the tab number (on a multi-tabbed screen; example is a browse procedure):

CHOICE(?CurrentTab) = X  ! where X is the # of the tab currently used


Windows #2

To refresh a window:

ForceRefresh = True

DO RefreshWindow


To refresh a listbox window:

post(event:ScrollTop,?list)