The ChkFunc function just checks for the existence of the function name in the internal list that RBase keeps to Map the RBase Declaration of the function to the address of the function within the DLL that contains it. If the function is already declared, then ChkFunc returns TRUE or 1.
You can use the RBase LIST command to "LIST FUNC" to see the list of the currently declared functions (you can declare up to 200 of these) You use DelFunc to remove a function from the list, very helpful during development if you screw up the declaration, you need to remove and redeclare it properly. Well anyway, I didn't do much excepting provide the framework of an example with a tiny bit of explanation, so pat yourself on the back for getting it to work for you and let it be a testament to others to put aside their apprehension about using these powerful tools that RBTI has worked hard to provide for us. As to whether you need to clear the attributes before setting, I don't think so. The SetFileAttributes API clearly does NOT say so. As to a library of examples, I am guilty as sin for not having everything done that I am working toward that end. Fortunately for me, I am getting busier at the thing that puts meat on the table, but leaves me with less time to work on this stuff. You can be certain that there will be something to demonstrate a variety of useful stuff when I get finished. ----- Original Message ----- From: "Alastair Burr" <[EMAIL PROTECTED]> To: "RBASE-L Mailing List" <[email protected]> Sent: Thursday, August 07, 2008 1:39 PM Subject: [RBASE-L] - Re: Silent LAUNCH command. > This is a little bit of wizardry, Mike! > > I still don't _understand_ how CHKFUNC works but I _can_ see that it is > working which means I can use and adapt as I need. Indeed, I now have my own > version of what you have outlined into which I can feed a filename and an > action to reset the attributes as I want. > > What's more, I only have one question: is there any need to remove all the > attributes first (set to 128) before setting a new value, 3 for instance to > make +R +H, because it _seems_ to work quite nicely going straight from 3 to > 33 (+A +R)? > > My only other comment about these functions in general is that when they > were first introduced and I looked at the help files for them I was pretty > much terrified by what I saw. I've just looked again and I still feel > dyslexic looking at them. Yet, with a little, no a lot of, help I have been > able to make use of something that looked way beyond me. > > There must be a number of things that people do from the old DOS days that > could be much better handled using these functions - especially if/when DOS > finally disappears. One of R:Base's major uses for me is to do my backups > because it handles file copying as well as anything. The only drawback is > that I have to copy files that haven't changed which simply adds time to the > process without any other problems. Presumably XCOPY/RoboCopy can be > accessed and there must be other DOS-type commands that it's not cost > effective for RBTI to include in R:Base that developers can make use of. > > I'm more than happy to post my command file as an example if anybody wants > to see it - it's less than 80 lines including my comments. It would be nice, > though, > if a small library of samples/examples could be built up somewhere of the > likeliest/common processes that developers could use as the basis for their > own projects. There is clearly a lot of potential that many might miss - as I > did. > > Again, many thanks for your help, I've learned a lot, > Regards, > Alastair. > > > > > ----- Original Message ----- > From: "MikeB" <[EMAIL PROTECTED]> > To: "RBASE-L Mailing List" <[email protected]> > Sent: Wednesday, August 06, 2008 7:53 PM > Subject: [RBASE-L] - Re: Silent LAUNCH command. > > >> Alastair, >> I am sorry I was late to the dance and didn't see what you were trying to >> do. >> There are two APIs, both callable from RBase using The DLCALL function >> that >> will likely be less troublesome. So we should just do it directly using >> the >> following Win32 declarations as a guide: >> >> This one is going to return a BOOL, which will likely match up with an >> RBase >> INTEGER as zero (FALSE) or non zero (TRUE). >> >> *(BEGIN CODE) >> { >> >> http://msdn.microsoft.com/en-us/library/aa365535(VS.85).aspx >> >> BOOL WINAPI SetFileAttributes( >> __in LPCTSTR lpFileName, >> __in DWORD dwFileAttributes >> ); >> >> http://msdn.microsoft.com/en-us/library/aa364944(VS.85).aspx >> DWORD WINAPI GetFileAttributes( >> __in LPCTSTR lpFileName >> ); >> >> Attrib Values: >> FILE_ATTRIBUTE_ARCHIVE = 32 >> FILE_ATTRIBUTE_COMPRESSED = 2048 >> FILE_ATTRIBUTE_DEVICE = 64 >> FILE_ATTRIBUTE_DIRECTORY = 16 >> FILE_ATTRIBUTE_ENCRYPTED = 16384 >> FILE_ATTRIBUTE_HIDDEN = 2 >> FILE_ATTRIBUTE_NORMAL = 128 >> FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192 >> FILE_ATTRIBUTE_OFFLINE = 4096 >> FILE_ATTRIBUTE_READONLY = 1 >> FILE_ATTRIBUTE_REPARSE_POINT = 1024 >> FILE_ATTRIBUTE_SPARSE_FILE = 512 >> FILE_ATTRIBUTE_SYSTEM = 4 >> FILE_ATTRIBUTE_TEMPORARY = 256 >> FILE_ATTRIBUTE_VIRTUAL = 65536 >> } >> >> IF (chkfunc('SetFileAttributes')) = 0 THEN >> STDCALL function 'SetFileAttributesA' ALIAS 'SetFileAttributes' + >> (Integer, ptr TEXT (256)) : Integer >> ENDIF >> >> IF (chkfunc('GetFileAttributes')) = 0 THEN >> STDCALL function 'GetFileAttributesA' ALIAS 'GetFileAttributes' + >> (ptr TEXT (256)) : Integer >> ENDIF >> SET VAR v1 Integer = NULL >> SET VAR v2 Integer = NULL >> SET VAR sfilename TEXT = 'F:\Rb76\DLProj\hold.txt' >> >> -- Set To FILE_ATTRIBUTE_NORMAL to REMOVE AlL ATTRIBUTES >> SET VAR vattrib Integer = 128 >> -- After setting to FILE_ATTRIBUTE_NORMAL you then APPLY the Attribute >> -- Combination you desire using the combinations from the list above >> >> SET VAR v1 = (dlcall('Kernel32', 'GetFileAttributes', sfilename)) >> { >> example, if vi has a value of 35 this would mean the attributes are a >> combination of the values listed above that equal 35 total which would >> be: >> FILE_ATTRIBUTE_ARCHIVE + FILE_ATTRIBUTE_HIDDEN + FILE_ATTRIBUTE_READONLY >> } >> >> SET VAR v2 = (dlcall('Kernel32', 'SetFileAttributes', vattrib, sfilename)) >> >> SET VAR v1 = (dlcall('Kernel32', 'GetFileAttributes', sfilename)) >> RETURN >> >> >> *(END CODE) >> ----- Original Message ----- >> From: "Alastair Burr" <[EMAIL PROTECTED]> >> To: "RBASE-L Mailing List" <[email protected]> >> Sent: Wednesday, August 06, 2008 11:28 AM >> Subject: [RBASE-L] - Re: Silent LAUNCH command. >> >> >> ----------------------------Mike - success and failure! >> >> My RMD file runs fine in R:Base and with no errors in trace but nothing >> happens. >> >> I have copied and pasted my version of what you posted along with the BAT >> file >> that is supposed to be run. You'll notice some comments of mine which I >> added >> as I was working through. I've left them as they are since they seem as >> good a >> way of any of explaining where I've got to and gone wrong. >> >> Any further help will be muchly appreciated. >> >> *( FileName: AttribChange.RMD ... ... Date of last amendment: 06/08/2008 ) >> *( Run a batch file with parameters in silent mode ) >> { >> ShellExecute.rmd example by Mike Byerley >> The Windows API declaration of Shellexecute: >> HINSTANCE ShellExecute( HWND hwnd, >> LPCTSTR lpOperation, >> LPCTSTR lpFile, >> LPCTSTR lpParameters, >> LPCTSTR lpDirectory, >> INT nShowCmd >> ); >> Syntax located at: >> http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx >> } >> -- >> --------------------------------------------------------------------------- >> -- Pre-define all variable types to null: >> -- >> --------------------------------------------------------------------------- >> SET VAR nShowCmd INTEGER = NULL >> SET VAR lpDirectory TEXT = NULL >> SET VAR lpParameters TEXT = NULL >> SET VAR lpFile TEXT = NULL >> SET VAR lpOperation TEXT = NULL >> SET VAR HWND INTEGER = NULL >> SET VAR vRetVal INTEGER = NULL -- not used? >> -- SET VAR vi INTEGER = NULL ?? >> >> -- >> --------------------------------------------------------------------------- >> -- Set variable values: >> -- >> --------------------------------------------------------------------------- >> SET VAR vTestParams TEXT = 'D: -H -R' -- Variable parameters to be passed >> in >> later... >> SET VAR nShowCmd = 0 -- SW_HIDE >> SET VAR lpDirectory = NULL -- Full path in lpFile (Repeated - DELETE?) >> SET VAR lpFile = 'C:\DosPrograms\Attrib.BAT' >> SET VAR lpParameters = .vTestParams >> SET VAR lpOperation = 'open' >> SET VAR HWND = 0 -- since it runs hidden, pass HWND as null >> SET VAR vRetVal = NULL -- (Repeated - vi ??) >> >> -- >> --------------------------------------------------------------------------- >> -- Process: >> -- >> --------------------------------------------------------------------------- >> IF (chkfunc('ShellExecuteA')) = 0 THEN >> STDCALL function 'ShellExecuteA' ALIAS 'ShellExecute' + >> (Integer, ptr TEXT (256), ptr TEXT (128), + >> ptr TEXT (128), ptr TEXT (32), Integer) : Integer >> ENDIF >> >> -- STDCALL part of DLCALL (DLLCALL in help link from CHKFUNC!)?? >> SET VAR vi = (dlcall('shell32.dll', 'ShellExecuteA', + >> nShowCmd, lpDirectory, lpParameters, lpFile, lpOperation, HWND)) >> -- consistantly returns 42 - implying success (>32) Should this be >> vRetVal? >> >> -- >> --------------------------------------------------------------------------- >> -- Tidy-up and return/exit: >> -- >> --------------------------------------------------------------------------- >> LABEL lEnd >> CLEAR VAR nShowCmd, lpDirectory, lpParameters, lpFile, lpOperation, HWND, >> vRetVal, vi >> RETURN >> *( End of program ) >> >> >> Attrib.BAT: >> >> rem @ECHO OFF >> rem Parameters: >> rem First = DriveColon - C: D: etc >> rem Second = +H or -H >> rem Third = +R or -R >> rem >> rem eg: C:\DosPrograms\Attrib.BAT D: +H +R >> rem >> rem CLS >> rem ECHO. >> rem ECHO. >> rem ECHO Re-Setting attributes... >> rem the above are a bit pointless if it's invisible anyway! >> >> %1 >> CD \ALMANAC >> ATTRIB %2 *.* /S >> CD _VIEWER >> ATTRIB %3 *.* >> C: >> EXIT >> >> >> >> >> Regards, >> Alastair >> >> ---------------------------- >> Alastair Burr >> St. Albans, UK. >> [EMAIL PROTECTED] >> ----------------------------- >> >> >> >> No virus found in this incoming message. >> Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: >> 270.5.12/1594 - Release Date: 05/08/2008 21:49 >> >> >> > > >

