Wrong number format when opening ASCII with labtalk origin9.1 - ascii

I have a problem reading ASCII-Files into Origin9.1. My ASCII-File looks like below: (note that I have 1 space before , 2 spaces between and 1 space after the numbers)
C:\amiX_TimeHist_P1.dat:
0,19325E-02 0,10000E+00
0,97679E-11 0,99997E-11
0,19769E+10 0,10025E+00
0,39169E+00 0,11636E+00
0,47918E+00 0,13156E+00
later I want to do the following with a scr-File but for now I write the following in Origin2015 in the Script-LabTalk-window:
open -w C:\amiX_TimeHist_P1.dat;
That command works but the numbers I get are in a wrong format:
When I read the file with the Import-wizzard or with ASCII-Import I can choose several options to fit the numbers correctly in the my columns. But this has to be done automatically.
Is there a way to read an ASCII-File uncluding setting parameters when using a script?

Instead of open you should use impASC to import ASCII data. Then you can specify some options to the command. In your case the following should work:
impASC fname:=C:\amiX_TimeHist_P1.dat options.FileStruct.DataStruct:=2 options.FileStruct.MultipleDelimiters:=" " options.FileStruct.NumericSeparator:=1;
If you just type impASC in your script window, in the following dialog box you can edit the import options and display the corresponding skript command.

Related

Command line options to jump to search term in .txt file searched from within Xbench (and opened in EmEditor)

I am using a glossary search program called Xbench, and it allows you to use command line parameters to automatically jump to the relevant line in the file where your search term is. The developer told me to look for tips on how to achieve this with EmEditor # https://docs.xbench.net/user-guide/xbench-settings/
There, it is explained how to achieve this with Textpad and Notepad++.
See:
For example, to configure TextPad 4 for line positioning, you must
select there the Textpad executable and specify the following in
Command-Line Parameters: $filename($line,$column). Similarly, to
configure Notepad++, you must select its executable and specify the
following in Command-Line Parameters: $filename -n$line. Other text
editors will require different values for this field. Please check
your text editor’s documentation for the suitable values.
I had a look at EmEditors command line options # http://www.emeditor.org/en/howto_file_file_commandline.html, but can't figure out how to do this. Can someone help me?
Michael Beijer (technical/patent translator)
Please try this:
$filename /l $line /cl $column
If a file name contains a space, you might need to use this:
"$filename" /l $line /cl $column

how to export a variable values from TRACE32

My question is how to export a variable value which I have seen in watch window? I need to append the values of that variable in Excel format, I'm using the TRACE32 software.
You can export variables to a CSV file as displayed in the Var.WATCH window with command Var.EXPORT. Each variable will get its own line in the CSV. To ensure that only the data and not also the command Var.EXPORT gets part of the result use the command WinPOS ,,,,,0 before Var.EXPORT.
E.g. to export the scalar variables x and y to a CSV file including the type information you can use the commands:
WinPOS ,,,,,0
Var.EXPORT myfile.csv %Hex %Type x y
You can write / append to a file using OPEN, WRITE and CLOSE. Every Spreadsheet program can read CSV and it's easy to write:
OPEN #1 <file name> /Create
WRITE #1 "," Var.VALUE(<variable name>)
CLOSE #1
Writing to a Microsoft Excel file, e.g. XLSX is much more complicated, there are libraries for this in other languages, but I don't think there's anything in TRACE32.
If you want to write it manually you can look into adding a custom button (MENU.AddTool), otherwise you'll need to specify your condition(s).

How to edit file content using zsh terminal?

I created an empty directory on zsh and added a file
called hello.rb by doing the following:
echo 'Hello, world.' >hello.rb
If I want to make changes in this file using the terminal
what's the proper way of doing it without opening the file
itself using let's say TextEditor?
I want to be able to make changes in the file hello.rb strictly
by using my zsh terminal, is this at all possible?
Zsh is not a terminal but a shell. The terminal is the window in which the shell executes. The shell is the text program prompting you commands and executing them.
If you want to edit the file within the terminal, then using vim, nano, emacs -nw or any other text-mode text editor will do it. They are not Zsh commands, but external commands that you can call from Zsh or from any other shell.
If you want to edit the file within Zsh, then use zed. You will need to run once (in ~/.zshrc)
autoload zed
and then you can edit hello.rb using:
zed hello.rb
(exit and save with Control-j)
You have already created and edited the file.
To edit it again, you can use the >> to append.
For example
echo "\nAnd you too!\n" >> hello.rb
This would edit the file by concatenating the additional string.
Edit, of course, by your use and definition of 'changing' a file, this is the simplest way to do so using the shell.
In a normal way, though you probably want to use a terminal editor.
Zed is a great answer, but to be even more stripped down - for a level of editing that even a script can do - zsh can hand all 256 characters/byte-values (including null) in variables. This means you can edit line by line or chunk by chunk almost any kind of file data directly from the command-line. This is approximately what zed/vared does. If you have a current version with all the standard modules included, it is a great benefit to have zsh/mapfile or zsh/system loaded so that you can capture any of the characters that are left out by command-expansion (zed uses $(<$file) to read a file to memory). Here is an example of a way you could use this variable manipulation method:
% typeset -T Buffer buffer $'\n'
% typeset -T Edit edit $'\n'
It is most common to use newline to divide a text file one wishes to edit.
This handy feature will make zsh give you full access to one line or a range of lines at a time without unintentionally messing with the data.
% zmodload zsh/mapfile
% Buffer=$mapfile[path/to/file]
Here, I use the handy mapfile module because I can load the contents of a file byte-for-byte. Alternately you can use % Buffer="$(<path/to/file)", like zed does, but you will always have the trailing newlines removed and other word splitting is possible with a typo or environment variation, so the simplicity of the module's method is best. When finished, you save the changes by simply assigning the $Buffer value back to the $mapfile[file] or use a more classic command like printf '%s' $Buffer >path/to/file (this is exact string writing, byte-for-byte, so any newlines or formatting you added back will be written).
You transfer the lines between Buffer and Edit using the mapped arrays as follows, however, remember that in its simplest form assigning one array to another drops elements that are completely empty (one \n \n two \n three becomes one \n two \n three). You can suppress this empty-element removal by quoting the input array and adding an '#' symbol to its index "$buffer[#]", if using the whole array; and adding the '#' symbol to the flags if using a range of the array "${(#)buffer[2,50]}". Preserving empty lines can be a bit troublesome for typing, but these multiple arrays should only be used in a script or function, since you can just edit one line at a time from the command line with buffer[54]="echo This is a newly written line."
% edit=($buffer[50,70])
...
% buffer[50,70]=($edit)
This is standard Zsh syntax, that means in the ... area you can edit and manipulate the $edit array of lines or the $Edit scalar block of text all you want, including adding more lines or taking some away. When you add the lines back into $buffer it will replace the specified block of lines (50-70) with the new lines, automatically expanding or reducing the other array elements to accommodate the reintegrated lines. -- Because of the dynamic array accommodations, you can also just insert whatever you need as a new line like this buffer[40]=("new string as new line" "$buffer[40]"). This inserts it before the index given, while swapping the order of the elements ("$buffer[40]" "new string as new line") inserts the new line after the index given. Either will adjust all following elements, including totally empty elements, to their current index plus one.
If you wanted to re-write the zed function to use this method in some complex way like: newzed /path/to/file [start-line] [end-line], that would be great and handy too.
Before I leave, I wanted to mention that using vared directly, once you have these commands typed on the interactive terminal, you may find it frustrating that you can't use "Enter" for inserting or appending new lines. I found that with my terminal and Zsh version using ESC-ENTER worked well, but I don't know about older versions (Mac usually comes stocked with a not-most-recent version, if my memory is right). If that doesn't work, you may have to do some documentation digging to learn how to set up your ZLE (Zsh Line Editor, a component of Zsh) or acquire a newer version of Zsh. Also, some other shells, when indexing a scalar variable may count by the byte because in ascii and C a byte is the same as a character, but Zsh supports UTF8 and will index a scalar string by the UTF8 character unless you turn off the shell option multibyte (on by default). This will help with manipulating each line if you need to use the old byte-character indexing. Also, if you have a version of Zsh that for whatever was not compiled with zsh/mapfile or zsh/system, then you can achieve a similar effect using number of options to the read builtin, like <path/to/file |read -u 0 -k $[5 * 2**20] -r -s Buffer ||(($#Buffer)). As you can see here, you have to make the read length big enough to accommodate the file's size or it will leave off part of the file, and the read return code will nearly always be an error because of not being able to read the full length of the string. We fix this with ||(($#Buffer)), but this builtin was simply not meant to handle large scale byte manipulation efficiently, so what you see is what you can get from it.

Shell script file takes partial path from parameter file

I have a parameter file(parameter.txt) which contain like below:
SASH=/home/ec2-user/installers
installer=/home/hadoop/path1
And My shell script(temp_pull.sh) is like below:
EPATH=`cat $1|grep 'SASH' -w| cut -d'=' -f2`
echo $EPATH
${EPATH}/data-integration/kitchen.sh -file="$KJBPATH/hadoop/temp/maxtem/temp_pull.kjb"
When I run my temp_pull.sh like below:
./temp_pull.sh parameter.txt
$EPATH gives me correct path, but 3rd line of code takes only partial path.
Error code pasted below:
/home/ec2-user/installers-->out put of 2nd line
/data-integration/kitchen.sh: No such file or directory**2-user/installer** -->out put of 3rd line
There is no need to manually parse the values of the file, because it already contains data in the format variables are defined: var=value.
Hence, if the file is safe enough, you can source the file so that SASH value will be available just by saying $SASH.
Then, you can use the following:
source "$1" # source the file given as first parameter
"$SASH"/data-integration/kitchen.sh -file="$KJBPATH/hadoop/temp/maxtem/temp_pull.kjb"
The problem is file which we were using was copied from windows to UNIX.So delimiter issue are the root cause.
By using dos2unix paramfile.txt we are able to fix the isue.
command:
dos2unix paramfile.txt
This will convert all the delemeter of windows to unix format.

How can I perform an action n-many times in TextMate ( both Emacs and Vim can do it easily! )?

Emacs: C-U (79) # » a pretty 79 character length divider
VIM: 79-i-# » see above
Textmate: ????
Or is it just assumed that we'll make a Ruby call or have a snippet somewhere?
I would create a bundle command to do this.
You can take editor selection as input to your script, then replace it with the result of execution. This command, for example, will take a selected number and print the character '#' that number of times.
python -c "print '#' * $TM_SELECTED_TEXT"
Of course this example doesn't allow you to specify the character, but it gives you an idea of what's possible.
By taking the
python -c "print '#' * $TM_SELECTED_TEXT"
a step further, you can duplicate the examples you gave in the question.
Just make a snippet, called divider or something, set the tab trigger field to something appropriate '--' for example, then enter something like:
`python -c "print '_' * $TM_COLUMNS"`
Then when you type --⇥ (dash dash tab), you should get a divider of the correct width.
True, you've lost some of the terseness that you get from vim, but this is far easier to reuse, and you only have to type it once. You can also use whatever language you like.
Inspired by the other answers. Make a snippet with the following:
`python -c "print ':'.join('$TM_SELECTED_TEXT'.split(':')[:-1]) * int('$TM_SELECTED_TEXT'.split(':')[-1])"`
and optionally assign a key sequence to it, e.g. CTRL-SHIFT-R
If you type -x:4, select it, and call the snippet (by it's shortcut for example), you'll get "-x-x-x-x".
You can also use ::4 to obtain "::::".
The string you repeat is enclosed in single quotes, so to repeat ', you have to use \'.

Resources