Downloaded a package file from internet (fictitious name: packagename.m)
Installed the package and verified that a file with the same package name has been created under (Windows O.S.) directory “C:\ProgramData\Mathematica\Applications”
If I call Needs["packagename"] I get the message ....Needs::nocont: Context qulib was not created when Needs was evaluated.
If I call Needs["packagename.m"] I get the message ...Needs::cxt: Invalid context specified at position 1 in Needs[qulib.m]. A context must consist of valid symbol names separated by and ending with `.
An Internet search did not help with this apparently stupid problem…thank you very much.
Try using “Get” instead of “Needs”. Also, add a backtick to the end of the filename, or use the .m extension explicitly.
As the messages suggests, Needs expects the package file to do a little more than just contain code. Needs expects the package file to contain a BeginPackage/EndPackage construct that adds a context like MyPackage` to the context path. Apparently the package file you downloaded doesn’t do that.
Get will just expect to find syntactically-correct Wolfram Language code and evaluate it and return the last expression, nothing more.
The advantage of having a package add to the context path is that multiple calls to Needs will result in the file being loaded only once. It does that by checking whether the requested context has been added to the context path.