Using the Open() function to run Javascript scripts

Hi,

I feel a bit stupid asking this question but it’s been driving me mad so here goes!

I’m trying to link a javascript file to the advanced settings area of the Task Parameters section (Tips On task) using the open() function like so:

open(‘C:\VWorks Workspace\RNASeq\Javascript\RNASeq4.txt’)

However I keep getting the following error message:

script:1:can’t open C:VWorks WorkspaceRNASeqJavascriptRNASeq4.txt: No such file or directory

I’ve tried the following fixes:

  1. Changing the file type from .txt to .js
  2. Unchecking ‘read only’ for all the folders in the file path
  3. Checking the file path is correct numerous times!
  4. Using the relative file path instead of the absolute file path
  5. Using a different folder location to run the script
  6. Using " " instead of ’ ’ to encapsulate the string file path
  7. Using double \ instead of single \ in the file path

I can’t believe this should be this difficult, I must be overlooking something simple! Any help with this problem would be much appreciated.
Many thanks,
Thomas

Hi! Replace \ with double \ and it should work :slight_smile:

Hi @dReekb, thanks for your message. Sorry I’ve already tried that and it didn’t help. I should have included that in my list of failed fixes above.

You need to use double quotes with the double slash

open(“C:\\VWorks Workspace\\RNASeq\\Javascript\\RNASeq4.txt”)

alternatively this works:

open(‘C:/VWorks Workspace/RNASeq/Javascript/RNASeq4.txt’)

I got it to work eventually. I just had to remove .txt from the end of the file name (the actual file rather than file name in the file path) :roll_eyes: