How to call external JS script? lazarus / 76-Pas2JS ---------------------------------------------------------------------- zendrael · 2023-10-16 12:43 Hello! I need to call an external JS script, but I don't want to declare all of the external script functions and don't know all of them... Can I do something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i window.ExternalLibName.function()inside my Pascal code? Thanks in advance, any help is appreciated. ---------------------------------------------------------------------- PascalDragon · 2023-10-16 20:26 Quote from: zendrael on October 16, 2023, 02:43:45 pmI need to call an external JS script, but I don't want to declare all of the external script functions and don't know all of them... The point of Pascal is to declare first. So you must to declare them. ---------------------------------------------------------------------- marcov · 2023-10-17 09:55 Does pas2js support idispatch ? :-) ---------------------------------------------------------------------- PascalDragon · 2023-10-18 20:02 Quote from: marcov on October 17, 2023, 11:55:29 amDoes pas2js support idispatch ? :-) From what I can see it doesn't. ---------------------------------------------------------------------- ps · 2023-11-08 06:09 Quote from: zendrael on October 16, 2023, 02:43:45 pmI need to call an external JS script, but I don't want to declare all of the external script functions and don't know all of them... You can declare only function you need. For example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TJSSignaturePad = class external name 'SignaturePad' (TJSObject)     constructor new (aTarget : TJSElement; const aOptions : TJSObject);  procedure fromData(Value: JSValue);  end; ---------------------------------------------------------------------- d-_-b · 2024-02-21 21:11 Why not use a asm block? But read "Why are asm blocks bad". Below is a fully working pas2js example, note Result is case-sensitive in the asm block! Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  val: jsvalue;function movementQueryWorld: jsvalue;begin  asm     Result = window.movementQuery(world) // https://github.com/NateTheGreatt/bitECS /blob/master/docs/INTRO.md#-query  end;end;begin  val:= movementQueryWorld();  writeln('From Pascal', val);end. ---------------------------------------------------------------------- zendrael · 2024-03-04 11:45 Thank you all! Solved by creating a wrapper in JS and on Pascal with calls for external wrapper functions. This way I can change whatever is needed in the wrapper and keep the calls in Pascal. Thank you for all the help!