Started by Zlatko Vid, March 27, 2023, 10:34:11 AM
0 Members and 1 Guest are viewing this topic.
QuoteFrom Bob Zale himself (to the formal Beta Team)#RESOURCE metastatement <Improved>PurposeEmbed PowerBASIC Resource Data into a compiled application.Syntax#RESOURCE BITMAP, ResID, "filespec.BMP"#RESOURCE CURSOR, ResID, "filespec.CUR"#RESOURCE FILE, ResID, "filespec.DLL"#RESOURCE ICON, ResID, "filespec.ICO"#RESOURCE MANIFEST, 1, "filespec.XML"#RESOURCE RCDATA, ResID, "filespec.DAT"#RESOURCE STRING, ResID, "YourWideText"$$ [,LangID]#RESOURCE TYPELIB, 1, "filespec.TLB"#RESOURCE WAVE, ResID, "filespec.WAV"#RESOURCE VERSIONINFO <<block>>#RESOURCE RES, "filespec.RES"#RESOURCE PBR, "filespec.PBR"RemarksThis metastatement is used to include PowerBASIC Resource data intoyour program or DLL. Resource data may consist of Bitmaps, Icons,Strings, COM Type Libraries, Version Information, and more. You caneven embed custom binary data for your personal, specialized needs.Resource data can be a very valuable tool. While you can certainlyload bitmaps and icons from separate files, wouldn't it be better tojust embed them in your application? When you need the bitmap, it'salways right there for your use! You don't have to deal with scadsof files. Now it's all at your fingertips.The parameter ResID is a unique identifier which you create toreference this item. It can be a number or an alphanumeric label.If a number, it must be an integral value from 0 to 65535. If alabel, it must begin with a letter, and consist of letters andnumbers. Alphanumeric labels are not case sensitive. The filespecparameter must always be expressed as a string literal which tellsthe location of the resource data.With most programming languages, creation and embedding of resourcedata is a cumbersome process. First you create a resource script(an .RC file) with a text editor. Then you save the .RC file. Now,compile the .RC file with a resource compiler to get a .RES file.Next, you convert it to a linkable file using Microsoft's CVTRES.EXEor another converter program like PBRES.EXE. Finally, you link itinto your .EXE or .DLL with a compiler or linker program. What ifyou find you need to make a tiny change? Do it all over again, fromthe beginning. Even older versions of PowerBASIC suffered from thisproblem.Isn't there a better way? Yes, PowerBASIC now handles the entireprocess in a single line of code. Need an an embedded bitmap?#RESOURCE BITMAP, 123, "MyPicture.BMP"PowerBASIC finds your bitmap in the file MyPicture.BMP and embedsit in your executable. When you need to use it, you can referenceit by the ID you chose for it (123). The ID can be an integralnumeric value or a text name of your choice. So, to display thebitmap on a graphic window, it's as simple as:GRAPHIC RENDER "#123", (100,100)-(160,140)String Resources================The String resource contains string data which is always createdand stored as Wide Unicode characters. It is retrieved at run-timewith the RESOURCE$ function. Due to the manner in which Windowsstores string resources in a string table, the ResID must be numeric.The string data must be from 1 to 127 characters in length, and maynot contain any embedded nuls (CHR$(0)). The string data may bespecified as a quoted wide string literal ("MyText"$$), or as awide string literal expression. A string literal expression can beconstructed from combinations of wide string equates or wide quotedstring literals, the CHR$ function, SPACE$ function, and the STRING$function when used with numeric parameters.VersionInfo Resources=====================The VersionInfo resource contains information about the file, suchas its version number, its intended operating system, its originalfile name, and much more. This resource is intended to be used withthe Version Information API functions, so that Windows Explorer, andother programs, can display the relevant information about your EXEor DLL. The VERSIONINFO resource cannot be embedded in a StaticLink Library (SLL).The VersionInfo resource is unique in that it requires several#RESOURCE metastatements which are interpreted as a complete block.They must be placed consecutively in the correct sequence in orderbe processed correctly.1- The block begins with the VersionInfo metastatement whichmarks the beginning of the version block.#RESOURCE VersionInfo2- Next, you may choose to add one or more of the numericversion metastatements which embed numeric values.#RESOURCE FileFlags FlagValue&#RESOURCE FileVersion HiNum1&, LoNum1&, HiNum2&, LoNum2&#RESOURCE ProductVersion HiNum1&, LoNum1&, HiNum2&, LoNum2&3- Next, the mandatory StringInfo metastatement is added, toidentify the Language ID and CharSet to be used. Each of theseparameters must be passed as a 4-digit HEX value in a stringliteral. The parameter must not contain the "&H" prefix usedwith numeric hex numbers.#RESOURCE StringInfo "LangID", "CharSet"4- Finally, you will add one or more of the string versionmetastatements, to provide extensive information about the file.The first string literal parameter chooses one of the followingpredefined names. The second string literal parameter adds yourpersonal choice of information about the file.#RESOURCE Version$ "Comments", "Additional info"#RESOURCE Version$ "CompanyName", "PowerBASIC Inc."#RESOURCE Version$ "FileDescription", "Presented to users"#RESOURCE Version$ "FileVersion", "Readable VerNum 1.02"#RESOURCE Version$ "InternalName", "Private"#RESOURCE Version$ "LegalCopyright", "Copyright 2010 PB Inc"#RESOURCE Version$ "LegalTrademarks", "xx is a..."#RESOURCE Version$ "OriginalFilename", "Original name w/o path"#RESOURCE Version$ "PrivateBuild", "Private info"#RESOURCE Version$ "ProductName", "Product distributed with"#RESOURCE Version$ "ProductVersion", "Version distributed with"#RESOURCE Version$ "SpecialBuild", "Special info"FileFlags Flagvalue-------------------%VS_FF_DEBUG File contains debugging information or is compiledwith debugging features enabled.%VS_FF_PATCHED File has been modified and is not identical to theoriginal shipping file of the same version number.%VS_FF_PRERELEASE File is a development version, not a commerciallyreleased product.%VS_FF_PRIVATEBUILD File was not built using standard releaseprocedures. If this value is given, you mustinclude a PrivateBuild string item.%VS_FF_SPECIALBUILD File was built by the original company usingstandard release procedures, but is a variation ofthe standard file of the same version number. Ifthis value is given, uou must include aSpecialBuild string item.LangID (HEX values)-------------------0401 Arabic 0415 Polish0402 Bulgarian 0416 Portuguese (Brazil)0403 Catalan 0417 Rhaeto-Romanic0404 Traditional Chinese 0418 Romanian0405 Czech 0419 Russian0406 Danish 041A Croato-Serbian (Latin)0407 German 041B Slovak0408 Greek 041C Albanian0409 U.S. English 041D Swedish040A Castilian Spanish 041E Thai040B Finnish 041F Turkish040C French 0420 Urdu040D Hebrew 0421 Bahasa040E Hungarian 0804 Simplified Chinese040F Icelandic 0807 Swiss German0410 Italian 0809 U.K. English0411 Japanese 080A Spanish (Mexico)0412 Korean 080C Belgian French0413 Dutch 0816 Portuguese (Portugal)0414 Norwegian - Bokmal 081A Serbo-Croatian (Cyrillic)0810 Swiss Italian 0C0C Canadian French0813 Belgian Dutch 100C Swiss French0814 Norwegian - NynorskCharSet (HEX values)--------------------0000 7-bit ASCII 04E3 Cyrillic03A4 Japan (Shift JIS X-0208) 04E4 Multilingual03B5 Korea (Shift KSC 5601) 04E5 Greek03B6 Taiwan (Big5) 04E6 Turkish04B0 Unicode 04E7 Hebrew04E2 Latin-2 (Eastern Europe) 04E8 ArabicRES/PBR Resources=================The second group of syntax examples show how you can embed resourceswhich have been pre-compiled used a resource compiler. Standardresource compilers output a binary resource with a .RES extension.PowerBASIC will embed this resource just as it is given in the file.This form will always be supported to support resource forms whichare typically not needed for most PowerBASIC programs, or whichusually require the use of a resource editor.The final example, using a .PBR file, will only be supported for alimited period of time. This is the form created by the PowerBASICPBRES utility in older versions of the compiler. It is recommendedthat you change to the .RES version soon, as it is more efficient,and needs less effort from the programmer. It should be noted thatprior versions of PowerBASIC allowed the descriptor "PBR" to beomitted. While this option will be supported for a limited periodof time, we recommend that you always insert "PBR" for clarity.See alsoResource Files, RESOURCE, RESOURCE$Patrice Terrier
Page created in 0.271 seconds with 25 queries.