Problem using package strings

Hello all,

I received a script which I wanted to run, but I always get an error message:
“The ‘strings’ function is not yet implemented in Octave”.

I tried to load the strings package before with “pkg load strings” but then I get the following error message:

>> pkg load strings
warning: addpath: __OH__/share/octave/packages/strings-1.2.0: No such file or directory
warning: called from
    load_packages_and_dependencies at line 48 column 5
    load_packages at line 47 column 3
    pkg at line 461 column 7

With “pkg list” I get strings in the list:

strings | 1.2.0 | __OH__/share/octave/packages/strings-1.2.0

With pkg global_list I get the following path:

C:__Octave\OCTAVE~1.0\mingw64\share\octave\octave_packages

Is this OK?

I am using version 5.2 With both the same; operating system Win10.
I used the .exe installer.

I have only been using Octave for a short time. Can anyone help me?

Thank you!

Octave 5.2.0 is no longer supported.
Do you see the same error with Octave 6.2.0?

1 Like

Hello,

I have installed version 6.2 but I get another error right at the start of octave:
error: mfile_encoding: conversion from encoding ‘ibm01148’ not supported
The script is not displayed correctly either. It is not readable.

In 5.2. I did not get that error with the encoding.

When I try to call the script I get the error: error: ‘filename’ undefined near line 11, column 11

So I changed the encoding and I can open the script now.

But I still get the rror: error: ‘filename’ undefined near line 11, column 11

6 function file = data(filename)
[…]
11 filetext = fileread(filename);

If an .m file starts with the function keyword, it defines a functions (not a script).
Some functions need input parameters. In your case, it looks like the function data has one input parameter filename.
Without knowing anything about your function, I’d guess you’d need to call it with a function name, e.g. data('some_input_file_name_needed_by_the_function').

Those are the very basic concepts of the Octave language. It might help if you took the time to familiarize yourself with those (e.g. by reading the “A Brief Introduction to Octave” and “Getting Started” in the manual and/or watching some tutorials).

Ok, sorry, I start ist with
data(‘logfile.log’)

But I used the wrong filename, sorry.
Now I get the same error message:

"The ‘strings’ function is not yet implemented in Octave.

Please read https://www.octave.org/missing.html to learn how you can
contribute missing functionality."

I tried

pkg load strings
pkg list

=> strings is marked with a ‘*’
But same message.

Was the script you are trying to run written for Matlab?
In that case, it most likely intents to use functions that require the string class that was added in Matlab a few versions back. That class is currently not implemented in Octave.

The strings package provides other functions related to string (character array) manipulation. It does not provide an implementation of the string class.
The tablicious package has a basic implementation of the string class. But it doesn’t implement the strings function afaict.

As an alternative to the string class, it might be possible to use cell arrays of character vectors. That would need to re-write the respective parts of the function you received.

Was the script you are trying to run written for Matlab?

This could also be why you’re getting the “‘filename’ undefined” error: Matlab and Octave both support defining functions inside scripts, but their behavior for them is very different. In Matlab, a function inside a script is a “local function”, which can be called from anywhere in the script (even before it is defined), and is only visible inside that script. In Octave, a function defined in a script is a “command line function”, which creates a global function definition, and can only be called after the point where it is defined (at least the first time the script is run).

Hello,

Was the script you are trying to run written for Matlab?

Yes, I think it is written for Matlab. I do not have a Matlab license. I do not have a Matlab licence. That is why I wanted to use Octave.

As an alternative to the string class, it might be possible to use cell arrays of character vectors. That would need to re-write the respective parts of the function you received.

I’m going to see if I can get into it a little bit.
I have no experience with Octave or Matlab so far.

Thank you