Jump to content
Sign in to follow this  
Daniel Eiszele

Nodejs.Path Unit

Recommended Posts

I'm not sure if there is an incompatibility between Javascript and Pascal in this instance but the function prototype for the Join function doesn't seem compatible with what javascript is expecting.

The SMS definition is shown in point 1 below, but Javascript is looking for a comma delimited list of strings, not an array of string. I have been able to work around this with the function at point 2 but I'm not sure if I'm misinterpreting or using the function incorrectly. Ideas?

image.png.ed7e99f0a91d85c5a183a1e34aa3e5c1.png

Share this post


Link to post
Share on other sites

That needs fix from dev team, but as a workaround try to write class helper (untested) and hopefully it will take precedence over default declaration.

JPathExportHelper = class helper for JPath_Exports

   function Join(Paths: string): string;

end;

and implementation as:

asm @Result = join(@Paths); end

or

Result := Variant(Self).join(Paths);

Share this post


Link to post
Share on other sites

Thanks @IgorSavkic, your second suggestion led me to realise that casting the NodePathAPI global variable to variant lets me use the function as intended without having to concatenate the parts into a string to begin with ie

filePath:= variant(NodePathAPI).join(filePart1, filePart2, filePart3)

Admittedly it foregoes type checking, but in this case that is an acceptable result for what I need it for.

Your answer also reminds me that I should look into Class Helpers more, so I don't unintentionally hack the RTL to pieces :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...