The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 Converting Hex to Dec and vice versa

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
MingliFu Posted - 02/08/2010 : 04:17:14 AM
Hello together,

could some1 of you tell me how to convert a normal decimal value in coloum A in a hex-value in coloum B and the other way?

For example:

A B
0 0
1 1
2 2
3 3
9 9
10 A
11 B
12 C

Have i to write a LabTalk function or is there a easier way to solve this problem!?!!

THX a lot!!!!
MINGLIFU
9   L A T E S T    R E P L I E S    (Newest First)
MingliFu Posted - 02/12/2010 : 08:31:56 AM
Hi Iris,

thx a lot to you!!!
It works!!

MingliFu
Iris_Bai Posted - 02/12/2010 : 01:33:37 AM
Hi,

Origin7.5 does not support the usage in Set Column Value dialog yet.

We suggest you upgrade to newest Origin version 81, which contains many other improvements.

As to O75, please use the following function to call Larry's Dec2Hex function. Run "ConvertHelper(1, 2)" in script window.


void ConvertHelper(int nSourceColIndex, int nDestColIndex) // this index is 1 offset
{
	// The index offset is 0 in Origin C
	nSourceColIndex--;
	nDestColIndex--;
	
	Worksheet wks = Project.ActiveLayer();
	if( !wks || !wks.Columns(nSourceColIndex) || !wks.Columns(nDestColIndex) )
	{
		out_str("No acitve worksheet or input column is invalid");
		return;
	}
		
	Column colSource(wks, nSourceColIndex), colDest(wks, nDestColIndex);	
	Dataset dsSource(colSource), dsDest(colDest);
	vector<string> vsHex;
	for(int nn = 0; nn < dsSource.GetSize(); nn++)
	{
		string strHex = Dec2Hex(dsSource[nn]);
		vsHex.Add(strHex);
	}
	dsDest.PutStringArray(vsHex);	
}




Iris
MingliFu Posted - 02/11/2010 : 2:34:37 PM
7.5G
larry_lan Posted - 02/11/2010 : 07:34:31 AM
What's your Origin version? If it's not the latest Origin, please download the demo version from our website and have a try. You can contact your local distributor to update your Origin.

Thanks
Larry
MingliFu Posted - 02/11/2010 : 06:10:19 AM
Hi larry_lan,

i wrote this func in "CodeBuilder".
Compiled and created it.
If i go now to col(b) and "Fill Coloum with Values" and i wrote
"Dec2Hex(col(a))$" but there are just "-" Symbols.
like this:
A B
0 -
1 -
2 -
3 -
4 -
5 -
6 -

Please help me!
And sorry for my bad english!

MingliFu
larry_lan Posted - 02/11/2010 : 05:12:10 AM
Hi:

For example, you can write an Origin C function to convert Dec to Hex:

string Dec2Hex(int a)
{
	string strHexA;
	strHexA.Format("%p", a);
	strHexA.TrimLeft('0');
	return strHexA;
}

Then in Set Column Values dialog, say col(a) is Dec and you want to convert to Hex in col(b), you can set:

col(b) = Dec2Hex(col(a))$

Please read more information from Origin Programming Guide, and you can also search the function Hex2Dec in Origin C help.

Thanks
Larry
OriginLab Technical Services
MingliFu Posted - 02/11/2010 : 03:24:19 AM
Please!
Help me!!

rlewis Posted - 02/08/2010 : 6:20:52 PM
It should be relatively easy to code such a function with OriginC ..
WHy not give it a try ...
MingliFu Posted - 02/08/2010 : 06:49:02 AM
noone?

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000