Jump to content
You are about to reply to a thread that has been inactive for 1528 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted

I am including a script file in another file like this

#include "utilities"

utilities is a script file in my inventory in the same folder as the file which includes it. (also, note, I am using an external editor, Sublime Text)

When I make a chance to the utilities script and save it I get a compile error. Always the same always the last line of utilities. Simple syntax error at line position 0.

When I save the file that includes utilities it compiles fine.

Is this a known bug? Is there a workaround?

Or, is there a way to save a file w/o invoking the compiler?

 

Thanks,
G

 

Posted

I could be wrong, but I seem to remember that the included file needs at least one empty line at the end. Perhaps see if that makes a difference?

If not, then I must be confusing this issue with another.

Posted (edited)
12 hours ago, GManB said:

utilities is a script file in my inventory

You can only #include files from your local hard drive, not other Scripts.

12 hours ago, Fritigern Gothly said:

the included file needs at least one empty line at the end

This is also true.

Edited by Wulfie Reanimator
  • Like 2
Posted
10 hours ago, Fritigern Gothly said:

I could be wrong, but I seem to remember that the included file needs at least one empty line at the end. Perhaps see if that makes a difference?

If not, then I must be confusing this issue with another.

There is something about that in the docs. They say if the last line of the file is a #endif you need the extra line. But, the last content line in the utilities file is '}' and I do put empty lines after, tried one, two, lots... always the same error and always on the last line whether it is empty or not.

G

Posted
59 minutes ago, Wulfie Reanimator said:

You can only #include files from your local hard drive, not other Scripts.

This is also true.

The docs say the pre-processor *will* look both in your hard drive using the path in the config, relative paths in the #include are ok AND will also look in the folder in your inventory in which the file having the #include is in. I have found that both work just as described in the doc. The only observation I made not in the doc is if you are including a script from inventory do not add '.lsl' at the end. Just the displayed name of the script.

G

  • Thanks 1
Posted
1 hour ago, GManB said:

The docs say the pre-processor *will* look both in your hard drive using the path in the config, relative paths in the #include are ok AND will also look in the folder in your inventory in which the file having the #include is in. I have found that both work just as described in the doc. The only observation I made not in the doc is if you are including a script from inventory do not add '.lsl' at the end. Just the displayed name of the script.

G

Oh, you're right! That's neat, I've been using the preprocessor for years and didn't even think it could work.

a92aa58ddc.png

Works fine, and it turns out in-world scripts don't need an extra newline at the end, probably because it's implicit.

  • Thanks 1
Posted
1 hour ago, Wulfie Reanimator said:

Oh, you're right! That's neat, I've been using the preprocessor for years and didn't even think it could work.

a92aa58ddc.png

Works fine, and it turns out in-world scripts don't need an extra newline at the end, probably because it's implicit.

A couple things.

1. You are editing from Contents. I had not thought of that since I moved to an external editor. That will save a couple steps in the modify/save-compile/test cycle. I just have to remember to copy the scripts back to Inventory when done. Just to mentally keep track of things. Right now I am editing from Inventory, saving, the deleting from Contents and dragging the new version from Inventory to Contents for each test cycle.

2. You probably already know this but you need 'utilities' in the same folder only so the preprocessor can find it. Once main is compiled the bytecode includes that from utilities and the entry in Contents is only a reference. So, you can remove utilities when the code is complete.

 

G

Posted (edited)
32 minutes ago, GManB said:

A couple things.

1. You are editing from Contents. I had not thought of that since I moved to an external editor. That will save a couple steps in the modify/save-compile/test cycle. I just have to remember to copy the scripts back to Inventory when done. Just to mentally keep track of things. Right now I am editing from Inventory, saving, the deleting from Contents and dragging the new version from Inventory to Contents for each test cycle.

2. You probably already know this but you need 'utilities' in the same folder only so the preprocessor can find it. Once main is compiled the bytecode includes that from utilities and the entry in Contents is only a reference. So, you can remove utilities when the code is complete.

 

G

1. I also use an external editor, I can't stand the in-viewer one. I can also tell from experience that what you're doing is awfully fiddly.

2. I know, which is why I never even though about including another Script directly. Only using local files means that you don't have to keep another Script in the same folder and clean it up after compiling. And if you ever want to recompile the main script, you'd have to find the utility script, put it into the same folder, recompile, and clean it up again. Awfully fiddly.

(P.S. I capitalize "Script" to differentiate between an in-world inventory item, and scripts that live on local drive.)

Edited by Wulfie Reanimator
Posted
4 hours ago, Wulfie Reanimator said:

Only using local files means......

You mean you create, modify, save all script files on your system's hard drive? If that's what you mean, how (and I know I'm probably missing something obvious here) do you get the scripts into SL? I cannot see any option in 'Upload' nor can I drag'n'drop the script to either Inventory or Contents. Also, does saving to your local hard drive also compile? Where is the compiler then? (I am using Sublime Text and I do not think its lsl support includes a compiler). Finally, how to you test using only local hard drive files? Seems there is some upload step.

With Sublime Text and the ExternalEditor in debug settings set correctly when I click Edit in-world on the script I get it in ST and when I save in ST it's compiled and the bytecode goes to the asset store in-world.

G

Posted
19 minutes ago, GManB said:

You mean you create, modify, save all script files on your system's hard drive? If that's what you mean, how (and I know I'm probably missing something obvious here) do you get the scripts into SL? I cannot see any option in 'Upload' nor can I drag'n'drop the script to either Inventory or Contents. Also, does saving to your local hard drive also compile? Where is the compiler then? (I am using Sublime Text and I do not think its lsl support includes a compiler). Finally, how to you test using only local hard drive files? Seems there is some upload step.

With Sublime Text and the ExternalEditor in debug settings set correctly when I click Edit in-world on the script I get it in ST and when I save in ST it's compiled and the bytecode goes to the asset store in-world.

G

I've not used an external editor for LSL, but I have used editors that include preprocessors. #included files are produced in an output file created from the main input file. I imagine this is how it would work for SL. You'd have a "main" script file on your computer, along with all the files you intend to include. When ready to compile, you'd export the amalgamated file back to SL. If the external LSL editors works like the editor I've used, opening a script inside SL, using the SL editor, would reveal one large file containing all the #included files from the computer, and no #include statements (other than potentially as comments). If you made an edit to this file, it would NOT be reflected back to your computer. The golden source file for your script would always reside on your computer.

The constant uploading is not visible to you, it happens when "saving" the script. That saves the short, raw form of the file on your computer and the preprocessed version back to SL.

Posted (edited)
59 minutes ago, GManB said:

You mean you create, modify, save all script files on your system's hard drive? If that's what you mean, how (and I know I'm probably missing something obvious here) do you get the scripts into SL? I cannot see any option in 'Upload' nor can I drag'n'drop the script to either Inventory or Contents.

Like I showed you in a screenshot in another thread, here: "Preprocessor include path"

66b6d85f41.png

For example, a file full of utility functions: "D:\xyz\utilities"

You would #include "utilities" as normal, and the preprocessor would look at your local drive for a file with that name.

f432cbcec3.png

59 minutes ago, GManB said:

Also, does saving to your local hard drive also compile? Where is the compiler then? (I am using Sublime Text and I do not think its lsl support includes a compiler). Finally, how to you test using only local hard drive files? Seems there is some upload step.

You do need to be in-world to compile and test your scripts, but only the script you're going to run/test needs to be in-world. "wuff.lsl" is an old text file I used to use as my include.

 

I don't really like #includes though, it makes it impossible for another person to recompile the script (with the preprocessor) because they don't have your includes. But it doesn't work as a form of protection either, because the post-processed script (which has all of the included stuff) is always available. It's just messy and inconvenient, especially if someone makes edits to the post-processed script and then someone else tries recompiling the script with the preprocessor. All of the edits made by that person without a preprocessor will be lost.

I prefer to just use my own snippets to insert code as I type it, like "os" expands to "llOwnerSay((string)[  ]);" and "osl" expands to "llOwnerSay(llList2CSV([  ]));" for debugging purposes. I would similarly create snippets to insert entire functions to my code, if needed.

Edited by Wulfie Reanimator
Posted (edited)
1 hour ago, Wulfie Reanimator said:

 

You do need to be in-world to compile and test your scripts,

Ok. How do you get a script from your system to in-world? Do you have to copy and paste it into a new Script?

If I don't *start* with an in-world Script I cannot get Sublime to save to anything in-world. I would have to copy/paste.

G

Edited by GManB
Additional Details
Posted
1 hour ago, Wulfie Reanimator said:

I prefer to just use my own snippets to insert code as I type it, like "os" expands to "llOwnerSay((string)[  ]);" and "osl" expands to "llOwnerSay(llList2CSV([  ]));" for debugging purposes. I would similarly create snippets to insert entire functions to my code, if needed.

I don't know the lsl functions well yet so I like to let Sublime auto-complete for me. Especially the arguments to a function. Super helpful at this point.

 

Posted
6 hours ago, GManB said:

Ok. How do you get a script from your system to in-world? Do you have to copy and paste it into a new Script?

If I don't *start* with an in-world Script I cannot get Sublime to save to anything in-world. I would have to copy/paste.

You answered your own question there. There's no magic involved.

You are about to reply to a thread that has been inactive for 1528 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...