Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with Javascript
#4
You first need to build a resource file. A JS file won't be linked as a resource and you will get this compiler error.

This is how you do it:

1) Create a text file and add this line to it:

IW_JS_SCROLLLESSON RCDATA DISCARDABLE "IW_JS_ScrollLesson.js"

the format of each line is this:

NAME_OF_THE_RESOURCE TYPE_OF_RESOURCE DISCARDABLE (the OS can discard it from memory if needed) FILE_NAME_WHERE_THE_RESOURCE_IS


2) Save this file in the same folder where the JS file is and name it like ScrollLesson.rc

3) You can build this file now with the resource compiler, or BRCC32.EXE which is deployed with your Delphi version. To build it just call

brcc32 ScrollLesson.rc

(you may need to use the full path name to BRCC32.exe, or just copy it to your project folder - it works independently of everything else)

The ScrollLesson.RES file will be created in the same folder.

4) Now you can link with your executable like this:

{$R ScrollLesson.res}

5) In order to reference the resource from your code to add it to the internal files, you need to use the name of the resource, not the name of the file, like this:

gInternalFiles.Add('IW_JS_SCROLLLESSON', '/js/ScrollLesson.js');

The resource name is case sensitive. As a convention we use it everything UPPERCASE.

All the rest will just work.

Please have in mind that you can obviously automate all these steps (using the pre-compile steps, for instance, or a .BAT file, etc), it is up to you. I just want to give you a direct and fail proof way of doing it, independently of any IDE services.
Reply


Messages In This Thread
Working with Javascript - by StephB - 03-22-2023, 10:21 AM
RE: Working with Javascript - by StephB - 03-23-2023, 08:53 AM
RE: Working with Javascript - by valmeras - 03-23-2023, 07:17 PM
RE: Working with Javascript - by Alexandre Machado - 03-23-2023, 10:20 PM
RE: Working with Javascript - by valmeras - 03-23-2023, 11:27 PM
RE: Working with Javascript - by jeroen.rottink - 03-24-2023, 10:18 AM
RE: Working with Javascript - by StephB - 03-28-2023, 04:56 PM
RE: Working with Javascript - by valmeras - 06-28-2024, 08:29 AM
RE: Working with Javascript - by Comograma - 06-28-2024, 01:55 PM

Forum Jump:


Users browsing this thread: 8 Guest(s)