octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #60453] Input function on windows fails to tri


From: anonymous
Subject: [Octave-bug-tracker] [bug #60453] Input function on windows fails to trim carriage return character when running in batch mode
Date: Sun, 25 Apr 2021 21:31:32 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36

Follow-up Comment #1, bug #60453 (project octave):

Tasos helped me on Stack Overflow. I use a batch file:

@echo off
C:\Octave\Octave-4.4.1\octave.vbs --force-gui --eval batchTest('%~dp0')
cmd /c

to execute the Octave function:

%%%%
s1 = "abcd";
double(s1)

s2 = input('Input:  ',"s");
double(s2)
%%%%

on a Windows 10 machine. When this is run,

double(s1) = 97 98 99 100 (as it should)

but

double(s2) = 97 98 99 100 13

when typing "abcd" and hitting "enter" for the input function. This only
occurs when executing from the batch file, where it seems that the carriage
return (Tasos pointed out that the 13 is the ASCII number for the "\r"
carriage return character) is also being errantly placed into the string.
Alternatively, using Octave directly with this function correctly results in 

double(s1) = double(s2) = 97 98 99 100

As Tasos also pointed out, this can be overcome with the use of the "strtrim"
function, i.e.

double(s1) = double(strtrim(s2)) = 97 98 99 100,

but the behaviors are different when using Octave directly vs. execution via
the batch file.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60453>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]