Autorarchive: ralf

play mp3 file

This is what i do :
—–

After global includes:
Include('Winequ.clw')

In Global Map:
Module('Window's API')

MciGetErrorString(ULONG,*CSTRING,USHORT),SHORT,PASCAL,RAW,PROC,NAME('MciGetErrorStringA')

MciSendString(*CSTRING,*CSTRING,USHORT,USHORT),ULONG,PASCAL,RAW,PROC,NAME('MciSendStringA')
End

In Global Datas :
MciChaineRequise   Cstring(128)
MciValeurRetourne  Cstring(128)
MciNumeroErreur    Long
MciChaineErreur    Cstring(128)
FichierJoue        String(255)

Embed Accepted 'Play':
FichierJoue = 'C:\TestMp3\MyFile.Mp3'
MciChaineRequise = 'open mpegvideo!' & Clip(FichierJoue) &' alias Mp3' ; Do JouerMci
MciChaineRequise = 'play Mp3' ; Do JouerMci

Embed Accepted 'Stop' :
MciChaineRequise = 'stop Mp3'  ; Do JouerMci
MciChaineRequise = 'close Mp3' ; Do JouerMci

Procedure Routine:
JouerMci Routine
  Clear(MciValeurRetourne)
  Clear(MciNumeroErreur)
  Clear(MciChaineErreur)
  MciSendString(MciChaineRequise,MciValeurRetourne,128,0)
  MciGetErrorString(MciNumeroErreur,MciChaineErreur,128)

—-
For info, use this before play another file :
MciChaineRequise = ‘status Mp3 mode’ ; Do JouerMci

HTH. Eric

get windows version – 2

  MAP
    ReFlex__OS(BYTE Extended=0),BYTE
    MODULE('')
      GetVersionEx(LONG),SIGNED,PASCAL,NAME('GetVersionExA'),PROC
    END
  END
  
ReFlex__OS FUNCTION(BYTE Extended=0)
!
! If NOT "Extended"   return 0 = Win9x/ME, 1 = NT, 2 = W2K/Whistler(XP)
! If "Extended"       return 1 = Win95, 2 = Win98, 3 = NT3.51, 4 = NT4, 5 = W2K, 6 = ME, 7 = Whistler(XP)
! Returns 255 on error
!

OSVersionInfo       GROUP,PRE()
InfoSize              ULONG
MajorVersion          ULONG
MinorVersion          ULONG
BuildNumber           ULONG
PlatformID            ULONG
CSDVersion            STRING(128)
                    END

  !   OS          MajorVersion  MinorVersion  PlatformID
  ! =====================================================
  !  Win95             4             0            1
  !  Win98             4            >0            1
  !  ME                4            90            1
  !  NT3.51            3            51            2
  !  NT4               4             0            2
  !  W2K               5             0            2
  !  Whistler(XP)      5             1            2

  CODE
  CLEAR(OSVersionInfo)
  InfoSize = SIZE(OSVersionInfo)
  IF NOT GetVersionEx(ADDRESS(OSVersionInfo)) THEN RETURN(255).

  IF NOT Extended
    RETURN( CHOOSE(PlatformID = 1, 0, CHOOSE(PlatformID = 2, CHOOSE(MajorVersion < 5, 1, 2), 255)) )
  ELSE
    IF MajorVersion = 4 AND MinorVersion = 90
      RETURN(6)
    ELSIF MajorVersion = 5 AND MinorVersion = 1
      RETURN(7)
    END
    RETURN( CHOOSE(PlatformID = 1, CHOOSE(MinorVersion = 0, 1, 2), CHOOSE(PlatformID = 2, MajorVersion, 255)) )
  END

outlook ole control

Program
  map
  end

window WINDOW('Caption'),AT(,,260,100),FONT('MS Sans Serif',8,,FONT:regular),GRAY
       OLE,AT(31,20,133,78),USE(?Ole1),CREATE('outlook.application')
       END
     END

ItemObj cstring(20)

  Code
  Open(window)
  display
  ItemObj=?ole1{'createitem(0)'}
  ?Ole1{citem & '.Display'}

mkdir – create directory

Add to your global map:

  module('clib')
  MkDir(*cstring),short,raw,name('_mkdir')
  end

Then in your code call it!

If you have an existing directory called c:\L1 and want to make c:\L1\L2\L3 then

newdir='c:\L1\L2'
If mkdir(NewDir) then Message('error');return.
NewDir='c:\L1\L2\L3'
If Mkdir(newDir)then Message('error');return.
Message('done')

map network drive

!global equates
NETRESOURCE GROUP
dwScope       ULONG
dwType        ULONG
dwDisplayType ULONG
dwUsage       ULONG
lpLocalName   ULONG
lpRemoteName  ULONG
lpComment     ULONG
lpProvider    ULONG
            END
CONNECT_UPDATE_PROFILE  EQUATE(01h)
RESOURCETYPE_DISK       EQUATE(01h)
RESOURCETYPE_PRINT      EQUATE(02h)
RESOURCETYPE_ANY        EQUATE(00h)


!global prototypes
MODULE('WNET API')
  WNetAddConnection(*NETRESOURCE,*CSTRING,*CSTRING,ULONG),SIGNED,PASCAL,RAW,NAME('WNetAddConnection2A')
END


!local data
LOC:NetRes           LIKE(NETRESOURCE)
LOC:lpPassword       CSTRING(20)
LOC:lpUserName       CSTRING(20)
LOC:dwFlags          ULONG
LOC:lpLocalName   CSTRING(10)
LOC:lpRemoteName  CSTRING(260)
LOC:lpComment     CSTRING(10)
LOC:lpProvider    CSTRING(10)

!map network drive
CLEAR(LOC:NetRes)
LOC:NetRes.dwType = RESOURCETYPE_DISK
LOC:lpLocalName = 'F:'
LOC:lpRemoteName = '\\III-NTServer\C'
LOC:NetRes.lpLocalName = ADDRESS(LOC:lpLocalName)
LOC:NetRes.lpRemoteName = ADDRESS(LOC:lpRemoteName)
CLEAR(LOC:lpPassword)
CLEAR(LOC:lpUserName)
LOC:dwFlags = CONNECT_UPDATE_PROFILE
Erc# = WNetAddConnection(LOC:NetRes,LOC:lpPassword,LOC:lpUserName,LOC:dwFlags)

last weekday of a month

!---------------------------------------------------------
! Last Weekday of a Month
!---------------------------------------------------------

!Text Equates
SundayText Equate('Sunday')
MondayText Equate('Monday')
TuesdayText Equate('Tuesday')
WednesdayText Equate('Wednesday')
ThursdayText Equate('Thursday')
FridayText Equate('Friday')
SaturdayText Equate('Saturday')


! Numeric Equates
Sunday Equate(1)
Monday Equate(2)
Tuesday Equate(3)
Wednesday Equate(4)
Thursday Equate(5)
Friday Equate(6)
Saturday Equate(7)
LastDayOfMonth Long
AnyDate Long

AnyDate = any given Clarion standard date


LastDayOfMonth = date(month(AnyDate) + 1,1,year(AnyDate)) -1


!Execute some code depening on day of week
Execute (LastDayOfMonth % 7) + 1
 Do SundayRoutine
 Do MondayRoutine
 Do TuesdayRoutine
 Do WednesdayRoutine
 Do ThursdayRoutine
 Do FridayRoutine
 Do SaturdayRoutine
End

! or return a value to a variable
Execute (LastDayOfMonth % 7) + 1
 ?DayText = SundayText
 ?DayText = MondayText
 ?DayText = TuesdayText
 ?DayText = WednesdayText
 ?DayText = ThursdayText
 ?DayText = FridayText
 ?DayText = SaturdayText
End
 

Install ODBC DSN

> c) we are using the Install Builder, how exactly can we make our
> installer to create the .dsn?
>

Jim Kane:

This code I wrote for someone else on the newsgroup makes a dsn and deletes it. You need to make lib files for the indicated dlls.

  program
_abcdllmode_ equate(0)
_abclinkmode_ equate(1)
  map
  module('api')
 sqlinstallererror(ushort ierror, *ulong pfErrorCode,|
 *cstring szErrorMsg, ushort cbErrorMsgMax,|
 *ushort pcbErrorMsg),short,pascal,raw,Name('SQLInstallerError')
!found in odbccp32.dll

     configdsn(unsigned,ushort,*cstring,*cstring)|
  ,bool,raw,pascal,Name('ConfigDsn')
!found in odbcjt32.dll
  end
  end
driverstring    cstring(256)
attrstring      cstring(256)             !attribute string to pass in configdsn
maindir         cstring('c:\maindir\')   !junk non-existant dir to produce an error
rv              bool                     !return value from configdsn 0=error
i               ushort                   !sqlinstallererror can return up to 8 error codes
szErrorstr      cstring(256)             !receives an error string
fErrorCode      ulong                    !receives and errorcode
cbErrorMsg      ushort                   !size of errorstr returned
!sql related equates for return value from SQLInstallerError
SQL_Success             equate(0)
Sql_Success_with_Info   equate(1)
SQL_STILL_EXECUTING     equate(2)
SQL_Error               equate(-1)
SQL_No_Data             equate(100)
eRet                    short
  code
  if message('Create DSN or Error','CreateDSN 
Demo',icon:question,'DSN|Error')=1
    driverstring='Access'&'<0><0>'
  else
    driverstring='<0><0>'
  end
  attrstring='DSN=temp;DriverID=25;DBQ=' & clip(maindir) & '\dacsdata.mdb'& '<0><0>'
  rv=ConfigDSN(0,1,driverstring,attrstring)  !create the DSN
  if ~rv then
    Message('Config DSN Failed - error messages to follow.')
    loop I=1 to 8
      eRet=SqlInstallerError(I,fErrorcode, szErrorStr, size(szErrorStr)-1, cbErrorMsg)
      if (eRet=Sql_Success or eRet=Sql_Success_With_Info) and cbErrormsg then
        message(szErrorstr,'ConfigDSN Error')
      else
        message('End of Error Messages')
        break
      end
    end
  else
    message('If you open ODBC in control panel before pressing ok, you''ll see your dsn','configdsn worked')
    rv=configDsn(0,3,driverstring,attrstring)
    if rv then
      message('the dsn was deleted')
    else
      Message('deleting the dsn failed')
    end
  end
  return

hand code print previewer

Some people have asked me to forward to them an example. I am putting the example here for all to see. I hope it can sassist in overcoming some of the reporting hassles! This is a hand coded multiple detail report, using ABC’s print previewer. Note the Module level include – do not put it at procedural level. This reports first on Customer file, then on OtherCustomer file.

   MEMBER('roadshow.clw')                             ! This is a MEMBER
module

                     MAP
                       INCLUDE('ROADS010.INC'),ONCE        !Local module prodecure declarations
                     END


Include('ABREPORT.INC')        !********MODULE LEVEL INCLUDE**********************
HandCodedReport      PROCEDURE                        ! Declare Procedure
LocalPreviewQueue   PreviewQueue
Previewer           PrintPreviewClass
Report
REPORT,AT(1000,1271,6000,7729),PRE(RPT),FONT('Arial',10,,),PREVIEW(LocalPreviewQueue),THOUS
       HEADER,AT(1000,1000,6000,281)
         STRING('Customer List'),AT(52,52,5906,208),USE(?String1),TRN,CENTER
       END
Detail DETAIL,AT(,,,271)
         STRING(@s100),AT(31,21),USE(CUS:CustomerName),TRN
       END
detail2 DETAIL,AT(,,,333)
         STRING(@s40),AT(73,83,2448,208),USE(Cus2:CustomerName),TRN
       END
     END
  CODE
Relate:Customers.Open
Open(Report)
Previewer.Init(LocalPreviewQueue)
Previewer.Maximize = True
Previewer.ZoomIndex = PageWidth
Previewer.AllowUserZoom = True
Previewer.UserPercentile = 120
Previewer.SetZoomPercentile(120)
Report{Prop:Text} = 'Currently Printing Hand Coded Report'
Set(Customers)
Loop
   Next(Customers)
   If Error() then
     Break
   End
   Print(RPT:Detail)                            !don't forget the reports' prefix when using the print verb
End

Set(OtherCustomers)
Loop
   Next(OtherCustomers)
   If Error() then
     Break
   End
   Print(RPT:Detail2)
End

EndPage(Report)    !do not forget this
Report{Prop:FlushPreview} = Previewer.Display()
Close(Report)
Relate:Customers.Close