I use Octave 5.2.0 in GUI.
After using Octave for 2 weeks I'm suddenly confronted with errors I didn't
have before with the same code.
Also today I suddenly received a message not finding the 'close' in this
code :
clear ; close all; clc;
error: 'strcat' undefined near line 44 column 25
error: called from
handleSto at line 44 column 24
testinvoer03 at line 69 column 1
>> EXEC_PATH
ans =
C:\Octave\OCTAVE~1.0\mingw64\bin;C:\Octave\OCTAVE~1.0\mingw64\notepad++;C:\Octave\OCTAVE~1.0\mingw64\libexec\octave\5.2.0\site\exec\x86_64-w64-mingw32;C:\Octave\OCTAVE~1.0\mingw64\libexec\octave\api-v53\site\exec\x86_64-w64-mingw32;C:\Octave\OCTAVE~1.0\mingw64\libexec\octave\site\exec\x86_64-w64-mingw32;C:\Octave\OCTAVE~1.0\mingw64\libexec\octave\5.2.0\exec\x86_64-w64-mingw32;C:\Octave\OCTAVE~1.0\mingw64\bin
>> strcat("ddd" ,"fff")
error: 'strcat' undefined near line 1 column 1
I found the strcat file strcat.m in
C:\Octave\Octave-5.2.0\mingw64\share\octave\5.2.0\m\strings.
Obviously the not in the exec_path.
I also checked path which gave me a point only.
I have added addpath("C:\\Octave\\Octave-5.2.0\\mingw64\\share\\octave\\5.2.0\\m")
now the Octave command windows tells me:
error: 'close' undefined near line 63 column 1
error: called from
testinvoer03 at line 63 column 1
The code was:
% &nd=1986-01-02 ??
% &revision_date=2020-02-21&nd= ??
…
%
clear;
close all;
clc;
land={'world'}; %{'world','us','jp'};
%
…
line number 63 was correct.
Anybody had this problem. Some advise please.
Hi am working on the Star TSP100 futurePRNT, have got a sample example to print data which is working fine. They use the code "\x1b\x1d\x61\x1" to allign to center. Need to know which coding it is? And how to print Code - 39 barcode in using the code?
It's a hexadecimal code specified by the below lined document.
As an example I'll deconstruct this command:
1B = Ascii Escape Character. This denotes the beginning of the command.
1D = Ascii Group Separator Character. This is part of the command.
61 = Ascii numeral '1'. This is part of the command.
1 = Value. This is the only parameter of the command.
Consulting the linked specification, 1B 1D 61 a is the command to specify position alignment. The a is the parameter. This command specifically sets center horizontal alignment (page 3-32).
The command to specify a barcode can be found on pages 3-43 through 3-46. It follows a similar format, there will be a code specifying the task, then a number of variable parameters to select the correct format, and finally you'll send your data.
Latest Line Mode Specification: http://www.starasia.com/%5CDownload%5CManual%5Cstarline_cm_en.pdf
I'm having an enforced introduction to idl trying to debug some old code.
I have a binary image file that has an ascii header (It's a THEMIS IR BTR image of Mars, if that is of interest). The code opens the file as unit 1 using OPENR, then reads the first 256 bytes of it using ASSOC(1,BYTARR(256)). The return from that is 256 ascii character dex values, but they are mostly high or low numbers that do not correspond to alpha-numeric characters, and are not related to the header that I know is on the file.
One thing that may help with diagnostics: the original file is a g-zipped version of the file. If I try to open it directly (using less, for example) it allows me to read the header. But if I unzip it first (gzip -c filename.IMG.gz > filename.IMG) and then try to read it again I get binary gobbledegook. (less gives me a warning before opening: "filename.IMG may be a binary file. See it anyway?").
Any suggestions?
Here's the IDL code:
CLOSE,1
OPEN,1,FILENAME
A = ASSOC(1,BYTARR(256))
B = A[0]
print,'B - ',B
H = STRING(B)
print,'H - ',H
And this is what it gives me:
B - 31 139 8 8 7 17 238 79 0 3 ... (and on for 256 characters)
H - [Some weird symbol]
I've tried it on a purely ascii test file and it works as expected.
31 139 8 is the beginning of a GZIP header for a "deflated" file.
http://www.gzip.org/zlib/rfc-gzip.html#file-format
So yes, the file looks like it needs to be decompressed first.
Try decompressing the file with gunzip, and check the header again. If it is 31 139 08... again, it looks like it has been compressed twice.
Otherwise, whatever it is, it is likely that it's been finally decompressed. It remains to be seen why the uncompressed file isn't being decoded.
Try the COMPRESS keyword to OPEN:
openr, 1, filename, /compress
The COMPRESS keyword refers to a compressed file, so it is both for reading and writing compressed files.
I am writing a data clean up script (MS Smart Quotes, etc.) that will operate on mySQL tables encoded in Latin1. While scanning the data I noticed a ton of 0D 0A where the line breaks are.
Since I am cleaning the data, should I also address all of the 0D, too, by removing them? Is there ever a good reason to keep 0D (carriage return) anymore?
Thanks!
0D0A (\r\n), and 0A (\n) are line terminators; \r\n is mostly used in OS Windows, \n in unix systems.
Is there ever a good reason to keep 0D anymore?
I think you should answer this question yourself.
You could remove '\r' from the data, but make sure that the programs that will use this data understand that '\n' means the end of line very well. In most cases it is taken into account, but check just in case.
The CR/LF combination is a Windows thing. *NIX operating systems just use LF. So based on the application that uses your data, you'll need to make the decision on whether you want/need to filter out CR's. See the Wikipedia entry on newline for more info.
Python's readline() returns a line followed with a \O12. \O means Octal. 12 is octal for decimal 10. You can see on the ASCII table that Dec 10 is NL or LF. Newline or line feed.
Standard for end-of-line in a unix text or script file.
http://www.asciitable.com/
So be aware that the len() will include the NL unless you try to read past the EOF the len() will never be zero.
Therefore if you INSERT any line of text obtained by the Python readline() into a mysql table it will include the NL character by default, at the end.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
Challenge:
Take a sentence of input of any length and convert all the words in that sentence to pig latin. If you do not know what pig latin is please read Wikipedia: Pig Latin.
Specifications:
Assume all words are separated by spaces and all sentences either end with a exclamation, question mark or period.
Do not use the variant for vowels mentioned in Wikipedia.
For words such as bread and quiz it is perfectly acceptable for them to be readbay, uizqay instead of and eadbray and izquay.
Functions or methods are perfectly acceptable. In other words you do not need to take in user input, but you must display user output.
Assume no input contains a compound word.
Example:
Input: I am a happy man.
Output: Iway amway away appyhay anmay.
How to win:
The winner is the person who can write a program that will do the challenge with the least amount of characters.
sed - 53/55 45/47 chars
With the -r option (2+43):
s/\b[aeiou]\w*/w&/gi;s/\b(\w)(\w*)/\2\1ay/g
Without the -r option (47):
s/\b[aeiou]\w*/w&/gi;s/\b\(\w\)\(\w*\)/\2\1ay/g
C# 257 96 characters
Readable Version:
string.Join(" ",
args.Select(y =>
("aeiouAEIOU".Contains(y[0])
? y + "way"
: y.Substring(1) + y[0] + "ay")
)
);
Condensed
string.Join(" ",args.Select(y=>("aeiouAEIOU".Contains(y[0])?y+"way":y.Substring(1)+y[0]+"ay")));
Input:
LINQ helps me write good golf answers
Output:
INQLay elpshay emay riteway oodgay olfgay answersway
GolfScript - 60 53 52 51 49 46 chars
)](' '/{1/(."AEIOUaeiou"-!{\119}*"ay "}%));+\+
Ruby 1.9+: 63 62 chars
Just a quick answer, probably can be shortened more
p gets.gsub(/\w+/){|e|"#{e=~/^(qu|[^aeiou]+)/i?$'+$&:e+?w}ay"}
it handles the case of the qu (question => estionquay), and prints with double qoutes. 3 more bytes for getting rid of them (I say no specification about this)
Edit 1: If using Ruby 1.9 saves a character (?w), let's use it.
Perl 87, 56, 47 chars
works with punctuation.
Thanks to mobrule.
s/\b[aeiou]\w*/w$&/gi;s/\b(\w)(\w*)/\2\1ay/g
Usage :
echo 'I, am; a: happy! man.' | perl -p piglatin.pl
Output :
Iway, amway; away: appyhay! anmay.
Groovy, 117 100 91 85 83 79 chars
print args[0].replaceAll(/(?i)\b(\w*?)([aeiou]\w*)/,{a,b,c->c+(b?b:'w')+"ay"})
Readable version:
print args[0]
.replaceAll(
/(?i)\b(\w*?)([aeiou]\w*)/ ,
{
a, b, c ->
c + ( b ? b : 'w' ) + "ay"
})
Haskell: 244 199 222 214 chars
Solution gives reasonable capitalization to transformed words based on original capitalization. Now properly handles leading consonant clusters. Note: no newline included at end of last line.
import Data.Char
import Data.List
q(x:y,z)|w x=x%(z++toLower x:y++"ay")|0<1=x:y++z
q(_,z)=z++"way"
x%(y:z)|isUpper x=toUpper y:z|0<1=y:z
w=isAlpha
main=interact$(>>=q.break(`elem`"aeiouAEIOU")).groupBy((.w).(==).w)
Test Input:
Did the strapping man say: "I am Doctor X!"?
Test Output:
Idday ethay appingstray anmay aysay: "Iway amway Octorday Xay!"?
VB.NET: 106 chars
Assumes "s" is the input, and also Imports System.Text.RegularExpressions. (Interestingly, due to the need for the # string literal prefix and the trailing semi-colon, this VB.NET version beats the C# equivalent by 3 chars.)
Return Regex.Replace(Regex.Replace(s, "(?i)\b([aeiou]\S*)", "$1way"), "(?i)\b([^aeiou\s])(\S*)", "$2$1ay")
Python 3 — 107 106 chars
Not preserving capitalization, as allowed in the comment. But punctuations are preserved. Whitespaces and linebreaks are added for readability only (hence the ; after import re).
import re;
print(re.sub('(?i)\\b(qu|[^aeiou\W]*)(\w*)',
lambda m:m.group(2)+(m.group(1)or'w')+'ay',
input()))
3 chars can be removed (qu|) if we don't handle the "qu" words.
Example usage:
$ python3.1 x.py
The "quick brown fox" jumps over: the lazy dog.
eThay "ickquay ownbray oxfay" umpsjay overway: ethay azylay ogday.
Python 3 - 100 103 106 chars
(similar to KennyTM's; the regex makes the difference here.)
import re;print(re.sub('(?i)(y|qu|\w*?)([aeiouy]\w*)',lambda m:m.group(2)+(m.group(1)or'w')+'ay',input()))
Note: went from 100 to 103 characters because of modification of the regex to account for "qu".
Note 2: Turns out the 103-char version fails when "y" is used for a vowel sound. Bleh. (On the other hand, KennyTM's 106-char version also fails when "y" is used for a vowel sound, so whatever.)
Boo (.NET): 91 chars
Same concept as VB.NET answer, only using Boo to save a few keystrokes.
print /(?i)\b([^aeiou\s])(\S*)/.Replace(/(?i)\b([aeiou]\S*)/.Replace(s, "$1way"), "$2$1ay")
Oops... I just noticed that this doesn't handle the ending punctuation. Or really any punctuation. Oh well - neither do many of the other solutions.
Lua, 109 characters
print((io.read():gsub("(%A*)([^AEIOUaeiou]*)(%a+)",function(a,b,c)return a..c..b..(#b<1 and"way"or"ay")end)))
Input:
To be honest, I would say "No!" to that question.
Output:
oTay ebay onesthay, Iway ouldway aysay "oNay!" otay atthay uestionqay.
Perl, 70 characters
To get the ball rolling:
while(<>){for(split){s/^([^aeiou]+)(.*)/$2$1ay / or $_.='way ';print}}
I'm sure it can be improved somewhere.
Python - 107 chars
i=raw_input()
print" ".join(w+"way"if w[0]in"aeiouyAEIOUY"else w[1:]+w[0]+"ay"for w in i[:-1].split())+i[-1]
PHP 102 bytes
<?foreach(split(~ß,SENTENCE)as$a)echo($b++?~ß:'').(strpos(' aeuio',$a[0])?$a.w:substr($a,1).$a[0]).ay;
PHP with use of preg 80 bytes
<?=preg_filter('#\b(([aioue]\w*)|(\w)(\w*))\b#ie','"$2"?$2way:$4$3ay',SENTENCE);