Author |
Topic  |
|
AKazak
Russia
1205 Posts |
Posted - 06/10/2022 : 03:32:23 AM
|
OriginPro 2022b (64-bit) SR1 9.9.5.167 Windows 7 Pro SP1 x64
Greetings!
I use Dec2Bin to generate a binary string. However the resulting string length is variable depending on the input decimal number.
What is the easiest way to do left padding the resulting string with "0" to make all the results strings to have a fixed length, say 8 or 16?
Thank you.
--- Andrey |
Edited by - AKazak on 06/10/2022 03:32:38 AM |
|
YimingChen
1664 Posts |
Posted - 06/10/2022 : 08:55:05 AM
|
What about using Python?

James |
 |
|
AKazak
Russia
1205 Posts |
Posted - 06/10/2022 : 11:25:43 AM
|
quote: Originally posted by YimingChen
What about using Python?
James
Dear James,
Cool! Thank you.
--- Andrey |
Edited by - AKazak on 06/10/2022 11:31:09 AM |
 |
|
AKazak
Russia
1205 Posts |
Posted - 06/10/2022 : 11:36:44 AM
|
How do I pad with a character other than "0"? Hod do I pad from right?
--- Andrey |
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/10/2022 : 12:25:16 PM
|

PS. The substitution $(%(Dec2bin(A)$), #8) works in scripts only and fails if used as column formula. Why?
PPS. Parsing of column formula is buggy - it interprets comma erroneously as delimiter in many cases and automatically replaces it with points! |
Edited by - aplotnikov on 06/10/2022 12:34:18 PM |
 |
|
YimingChen
1664 Posts |
Posted - 06/10/2022 : 3:42:12 PM
|
Substitution notation may not work in the Set Column Formula. Maybe just use LT function like: text(value(Dec2bin(A)), "#8")
James
quote: Originally posted by aplotnikov

PS. The substitution $(%(Dec2bin(A)$), #8) works in scripts only and fails if used as column formula. Why?
PPS. Parsing of column formula is buggy - it interprets comma erroneously as delimiter in many cases and automatically replaces it with points!
|
 |
|
YimingChen
1664 Posts |
Posted - 06/10/2022 : 3:45:20 PM
|
quote: Originally posted by AKazak
How do I pad with a character other than "0"? Hod do I pad from right?
--- Andrey
This is just one thought.

James |
 |
|
cpyang
USA
1406 Posts |
Posted - 06/10/2022 : 5:51:26 PM
|
quote: Originally posted by aplotnikov
PPS. Parsing of column formula is buggy - it interprets comma erroneously as delimiter in many cases and automatically replaces it with points!
This might be the same bug we noticed in https://my.originlab.com/forum/topic.asp?TOPIC_ID=47488
It was fixed with ORG-25334 for next version. Would you like to get beta version which will be releasing very soon?
CP
|
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/10/2022 : 6:19:32 PM
|
quote: Substitution notation may not work in the Set Column Formula.
Dear James,
the question was "why?".
Alexei |
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/10/2022 : 6:35:29 PM
|
Dear cpyang,
seems it is the same bug.
I would appreciate if you provide the improved version. Is it a new service release of 2022b?
Alexei |
 |
|
cpyang
USA
1406 Posts |
Posted - 06/10/2022 : 7:50:41 PM
|
I was thinking about beta 2023, but I think you are right, we should make SR1 to fix a few things including this one.
CP
|
 |
|
minimax
357 Posts |
Posted - 06/12/2022 : 11:24:59 PM
|
Hi aplotnikov,
quote:
The substitution $(%(Dec2bin(A)$), #8) works in scripts only and fails if used as column formula. Why?
1. As far as we try, it fails in both LT script and column formula. 2. The argument in substitution will be parsed immediately when execute in the 1st time, and thus fails in the subsequent loop. i.e. in your sample data, it is interpreted as 100 for every cell. |
 |
|
AKazak
Russia
1205 Posts |
Posted - 06/16/2022 : 03:36:38 AM
|
Seems to be that fixing the software is required.
--- Andrey |
 |
|
snowli
USA
1426 Posts |
|
AKazak
Russia
1205 Posts |
Posted - 06/24/2022 : 02:08:12 AM
|
quote: Originally posted by snowli
Hello,
We just released Origin 2022b sr1 which includes this fix. comma , will auto convert to ; when decimal separator is , in your Origin.
Please feel free to download the sr1 installer and choose repair to upgrade if u already have 2022b on your PC.
https://www.originlab.com/restricted/demo_download/DLRequest.aspx?rq=dl&d=1&s=E
Thanks, Snow
Dear Snow,
Can you share an example of the fix, please?
--- Andrey |
 |
|
cpyang
USA
1406 Posts |
Posted - 06/24/2022 : 05:52:29 AM
|
Hi Andrey,
This is related mostly to German users, so may not apply to you. It has to do with comma. Origin will auto convert comma to "." for German users when entering column formula, and this bug has to do with that auto conversion.
Basically if comma is a decimal separator in your computer, and you type "f(a,b)" in Fx cell, Origin will convert it into "f(a.b)", or "f(a;b)" depending on computer separator settings, and this bug fix has to do with situation where this auto-conversion took place when it should not.
CP
|
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/27/2022 : 04:32:45 AM
|
Hi CP,
there is no difference between Russia and Germany by decimal separator - the most European countries (except 5.5 ones :) ) use comma as standard symbol for this purpose.
Regards,
Alexei |
 |
|
aplotnikov
Germany
169 Posts |
Posted - 06/27/2022 : 04:57:42 AM
|
Hi minimax,
1. It fails if you try to use vector as argument. I meant, it works if used with single value as argument. 2. And the main "why" is: why not to implement vectorization for each operation in LT? It may be very useful providing a consistent and clear (at least for LT beginners) approach.
PS. Still I do not understand, why I can access values in numerical arrays by simple indexing and cannot do the same with string arrays, being forced to use GetAt() method instead. |
 |
|
minimax
357 Posts |
Posted - 06/28/2022 : 03:53:50 AM
|
Hi aplotnikov,
1. yes, single value works. 2. % is very old and complicate syntax in LT and is hard to expand to support vectorization; 3. only dataset supports indexing access, string arrays in LT does have limited functionality only. |
 |
|
|
Topic  |
|