Kategoriearchive: Clarion

options for regular expressions

The following should be escaped if you are trying to match that character

\ ^ . $ | ( ) [ ]
* + ? { } ,

Special Character Definitions

\ Quote the next metacharacter
^ Match the beginning of the line
. Match any character (except newline)
$ Match the end of the line (or before newline at the end)
| Alternation
() Grouping
[] Character class
* Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times

More Special Character Stuff

\t tab (HT, TAB)
\n newline (LF, NL)
\r return (CR)
\f form feed (FF)
\a alarm (bell) (BEL)
\e escape (think troff) (ESC)
\033 octal char (think of a PDP-11)
\x1B hex char
\c[ control char
\l lowercase next char (think vi)
\u uppercase next char (think vi)
\L lowercase till \E (think vi)
\U uppercase till \E (think vi)
\E end case modification (think vi)
\Q quote (disable) pattern metacharacters till \E

Even More Special Characters

\w Match a "word" character (alphanumeric plus "_")
\W Match a non-word character
\s Match a whitespace character
\S Match a non-whitespace character
\d Match a digit character
\D Match a non-digit character
\b Match a word boundary
\B Match a non-(word boundary)
\A Match only at beginning of string
\Z Match only at end of string, or before newline at the end
\z Match only at end of string
\G Match only where previous m//g left off (works only with /g)

list and label – set paperbin

VAR
...
l:DevMod             BYTE,DIM(1024)
l:DevModString       STRING(1024), over(l:DevMod)
...

CODE
...
PRINTER{PROPPRINT:Device}   = 'MyPrinter'
PRINTER{PROPPRINT:PaperBin} = 2
l:DevModString = PRINTER{PROPPRINT:DEVMODE}
ret# = LlSetPrinterInPrinterFile(l:Job, l:LL_Project, l:Report, -1, l:Drucker, address(l:DevMod))
...

Regards
Ralf

get environment variables

In „Global Map“ einfügen:
————————-

MODULE('Windows.DLL')
  GetEnvironmentVariableA (*CSTRING, *CSTRING, ULONG),ULONG,PASCAL,RAW
END
GetEnv (STRING),STRING

In „Programm Precedures“ einfügen:
———————————-

GetEnv PROCEDURE(str)
cres CSTRING(201)
cstr CSTRING(201)
len LONG
  CODE
  cstr = clip(str)
  len = GetEnvironmentVariableA (cstr, cres, size(cres)-1)
  return clip(cres)

Dann kann man bequem so einiges auslesen. Z.Bp. GetEnv(„OS“) oder „COMPUTERNAME“, „USERNAME“, „TEMP“.
Ich benutze dies vor allen Dingen im den „Global Properties“ in INI-File in use = „Other“ und dann !GetEnv(‚USERPROFILE‘) & ‚\Anwendungsdaten\xxx.ini‘
(xxx für den Programm-Namen) Damit hat jeder User am Rechner seine eigene Settings für das Programm.

Viel Erfolg
Michael Ziegler

get application icon

Module('WINAPI')
  FindExecutable(LONG,LONG,LONG),LONG,PASCAL,RAW,Name('FindExecutableA')
END
....

DATA
l:Executable         CSTRING(255)
l:FileName           CSTRING(255)

CODE
  ...
  l:FileName = 'test.txt'
  ret# = FindExecutable(address(l:FileName),0 , address(l:Executable))
  if l:Executable then
    ?Image1{Prop:Text} = l:Executable & '[]'
  else
    ?Image1{Prop:Text} = ICON:Hand  ! no icon found
  end
 ...

time since last reboot

Try GetTickCount: – You can use this to tell how long the computer has been running – From there you can calculate when the last reboot happened.

http://msdn.microsoft.com/library/en-us/sysinfo/base/gettickcount.asp

GetTickCount(),Long,PASCAL,proc,NAME('GetTickCount'),Dll(dll_mode)

local               group, pre(loc)
UpTime                long
UpDays                long
UpHours               long
UpMins                long
                    end


    loc:UpTime = GetTickCount()
    loc:UpDays = (((loc:UpTime / 1000) / 60) / 60) / 24
    loc:UpHours = (((loc:UpTime / 1000) / 60) / 60) % 24
    loc:UpMins = (((loc:UpTime / 1000) / 60) % 60)

Can display something like this:

 ' Up_Time = ' & loc:UpDays & 'd ' & loc:UpHours & 'h ' & format(loc:UpMins, @N02) & 'm'

Cheers
Jono Woodhouse

enumerate menu items

You have to use PROP:NextField, here’s a small example. In it I’m enumerating the menu and storing the structure and properties in a queue.

  ThisField   LONG,AUTO
  CODE
  FREE(mQ)
  ThisField = 0
  LOOP
    ThisField = SELF.W{PROP:NextField, ThisField}  !Get the next feq out of the array
    IF ThisField = 0 THEN BREAK.                    !done when the feq is zero again

    CASE SELF.W $ThisField{PROP:Type}
    OF CREATE:MenuBar OROF CREATE:Menu OROF CREATE:Item
      SELF.GetMenuItemProperties(mQ, ThisField)
      IF mQ.pType = CREATE:MenuBar
        SELF.MenuBarFeq = mQ.Feq
      END
      ADD(mQ, -mQ.ParentFeq, -mQ.Feq)
      ...
    END
  END

Cheers,
Larry Sand

app for russian language

Tanya Lumkis:

I have an app that supports some multi-langual capabilities on certain fields. I allow the user to dynamically change to a number of
languages (Russian, Greek, English, Vietnamese).

Depending up what business functions the your app will undertake you will need to change the charater set at the appilcation or window level. Or you can change it for individual fields as required.

      SetFont(0,,,,,Charset:Cyrillic)
      SetFont(?Some:FieldName,,,,,Charset:Cyrillic)

If you are using the email templates i’ve found using a variable to
define the language allows the user to dynamically change the language
setting.

 Local:Language = '/plain;charset="iso-8859-5"'
 charset="iso-8859-1=5' will need to be inserted 
 Message.AddBody(Some:Field,Content:text,clip(Local:Language,QuotedPrintable.IEncoder)

You will find that the Cyrillic character set should still support the latin based alphabet as well.

I also have found that choosing a unicode font (like Lucinda Unicode) will help.

If you are using Win2000 or XP you can add Russian as one of the languages and switch to the Russian to check that display and entry etc. works. (To input Russian characters use the On-Screen Keyboard if you don’t have a dual mode keyboard)

Of course if your Russian clients are running the Russian version of Windows they won’t have too many problems. You will find that using the dictionary to scan any files will not display the correct character set unless you have Russian Windows. However, when you display the records with the character set = cyrillic they will display correctly.

The clarion help does have an explanation of character sets under Fonts.
Also you can check out http://www.iso.org (International Standards Org) and http://www.ietf.org/ for info on character sets and the Internet.

Hope this is of some help.
Tanya

get logical drives

!------------------------------------------------------------------------------------------
! inside the global map
!------------------------------------------------------------------------------------------
Module('WINAPI')
   GetLogicalDrives(),ULONG,PASCAL
   GetLogicalDriveStrings(LONG,*CSTRING),LONG,PASCAL,RAW,NAME('GetLogicalDriveStringsA')
   GetDriveType(*CSTRING),UNSIGNED,PASCAL,RAW,NAME('GetDriveTypeA')
END

!------------------------------------------------------------------------------------------
! DATA
!------------------------------------------------------------------------------------------
qDrive               QUEUE,PRE(qDrive)
Drive                CSTRING(5)
qDrive:Desciption    CSTRING(40)
Type                 BYTE
                     END
l:DrivesCString      CSTRING(200)
l:DrivesLen          LONG

!------------------------------------------------------------------------------------------
! CODE
!------------------------------------------------------------------------------------------
   l:DrivesDWORD   = GetLogicalDrives()
   l:DrivesLen     = 200
   l:DrivesCString = '<0>{200}'
   l:DrivesString  = ''
   clear(qDrive)
   free(qDrive)
   ret# = GetLogicalDriveStrings(l:DrivesLen,l:DrivesCString)
   loop i# = 1 to 200
     if val(l:DrivesCString[i#]) > 20 then
       qDrive:Drive = qDrive:Drive & l:DrivesCString[i#]
     else
       if qDrive:Drive then
         qDrive:Type = GetDriveType(qDrive:Drive)
         case qDrive:Type
           of 0;  qDrive:Desciption = 'The drive type cannot be determined.'
           of 1;  qDrive:Desciption = 'The root directory does not exist.'
           of 2;  qDrive:Desciption = 'removable drive'
           of 3;  qDrive:Desciption = 'fixed drive'
           of 4;  qDrive:Desciption = 'network drive'
           of 5;  qDrive:Desciption = 'CDROM drive'
           of 6;  qDrive:Desciption = 'ramdisk'
         end
         add(qDrive)
         clear(qDrive)
       end
     end
   end

play wav file

! inside the global map
Module('WINAPI')
   SndPlaySound(*LPCSTR,UNSIGNED),BOOL,PROC,PASCAL,RAW,NAME('SndPlaySoundA')
END

! data
l:SoundFile cstring(255)

! code
  l:SoundFile = 'test.wav'
  SndPlaySound(l:SoundFile,1)  ! play sound and return
  SndPlaySound(l:SoundFile,0)  ! play sound and wait

get computername and user

! inside the global Map
Module('WINAPI')
   GetComputerName(*CSTRING,*ULONG),SIGNED,RAW,PASCAL,NAME('GetComputerNameA')
   WNetGetUser(ULONG,*CSTRING,*ULONG),LONG,RAW,PASCAL,NAME('WNetGetUserA')
END

! data
WIN:Computername CSTRING(32)
WIN:Computerlen  ULONG
WIN:User         CSTRING(32)
WIN:Userlen      ULONG
WIN:Net          ULONG

! code
  WIN:Computerlen = 32
  WIN:Userlen     = 32
  ret# = GetComputerName(WIN:ComputerName,WIN:Computerlen)  ! get the computername
  ret# = WNetGetUser(WIN:Net,WIN:User,WIN:Userlen)          ! get the current user