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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 date into label
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

goldrake_22

8 Posts

Posted - 01/16/2015 :  07:16:51 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi

I need to copy a row that is in a worksheet and it contains dates in format dd-mm-yyyy HH:mm. if I use the following command

wrow2label iw:=[r2l]Sheet1! comment:=1;


What i get is the numbers corresponding to the dates but not the date in the same format as before.

How can I solve the problem?

Thanks,

Best regards,

Matteo
Origin 8.5.1 SR!

lkb0221

China
497 Posts

Posted - 01/16/2015 :  09:31:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

There is no format for column label rows. All of them are pure text.
So as a workaround, you can loop through the columns, read the cell data as string and put it into the comment.

Zheng
OriginLab
Go to Top of Page

goldrake_22

8 Posts

Posted - 01/16/2015 :  10:16:00 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi!

How do I read them as string?

BR
Matteo

Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/16/2015 :  10:38:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
For example, assuming the row you want to set as comment is the 2nd one.

// Start
// With the worksheet activated
for (int ii = 1; ii <= wks.ncols; ii++) { // Loop through all columns
wks.col$(ii).comment$ = wcol(ii)[2]$; // Copy the cell value into comment as string
}
worksheet -s 0 2 0 2; // Select the 2nd row
DoMenu 36442; // Delete this row
// End
Go to Top of Page

goldrake_22

8 Posts

Posted - 01/19/2015 :  05:42:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks,
I have another question date-related. How do I make a script to change the format of all columns to a specific date format?

The problem arises from the fact that wks.colX.setformat does not accept as X a counter $(ii) coming from a for cycle. What command or workaround can I use?

Thanks again.
Matteo
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/19/2015 :  10:37:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Can you be a little specific about what counter of date are you looking for? If it's highly customized, you will need to loop through all the rows to calculate it.
Go to Top of Page

goldrake_22

8 Posts

Posted - 01/20/2015 :  03:13:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I would like all column to have this type of date:

dd-mm-yyyy HH:mm.

Br,

Matteo
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/20/2015 :  09:44:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try this:

for (int ii = 1; ii <= wks.ncols; ii++) {
wks.col$(ii).setformat(4, 22, dd'-'MM'-'yyyy HH:mm); // Set col(ii) to be this format
}

Edited by - lkb0221 on 01/20/2015 09:46:50 AM
Go to Top of Page

goldrake_22

8 Posts

Posted - 01/21/2015 :  06:10:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by lkb0221

Try this:

for (int ii = 1; ii <= wks.ncols; ii++) {
wks.col$(ii).setformat(4, 22, dd'-'MM'-'yyyy HH:mm); // Set col(ii) to be this format
}



Hi again,
that is exactly what i tried even on my own but it does not work. it seems that it doesn´t take $(ii).The command
wks.col1.setformat(4, 22, dd'-'MM'-'yyyy HH:mm); works and manually putting there whatever number works as well.
How can I solve this?

Thanks,

BR
Matteo


wks.col$(ii).setformat(4, 22, dd'-'MM'-'yyyy HH:mm);

is not accepted as command. it does not
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/21/2015 :  09:29:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Then try using a range variable, for example:

for (int ii = 1; ii <= wks.ncols; ii++) {
range rr = $(ii);
rr.setformat(4, 22, dd'-'MM'-'yyyy HH:mm);
}
Go to Top of Page

goldrake_22

8 Posts

Posted - 01/22/2015 :  04:33:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by lkb0221

Then try using a range variable, for example:

for (int ii = 1; ii <= wks.ncols; ii++) {
range rr = $(ii);
rr.setformat(4, 22, dd'-'MM'-'yyyy HH:mm);
}




Hi

it does not work still.
I have noticed though that the first solution you gave, which I had tried before,
for (int ii = 1; ii <= wks.ncols; ii++) {
wks.col$(ii).setformat(4, 22, dd'-'MM'-'yyyy HH:mm); // Set col(ii) to be this format
}

works if w
wks.col$(ii).setformat(4, 22, dd'-'MM'-'yyyy HH:mm);
so removing the customization. however I still want to be able to see the HH:mm which is not in the default date format.

Thanks,

BR
Matteo
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/22/2015 :  10:51:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I tried in 8.5.1SR2 again and cannot see any problems.
Sorry... I don't not quite understand what the error you've running into. Please make sure the worksheet you want to operate on is the current activated one.
Would you mind share a little more details?

Zheng
OriginLab
Go to Top of Page

goldrake_22

8 Posts

Posted - 01/23/2015 :  11:50:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by lkb0221

Hi,

I tried in 8.5.1SR2 again and cannot see any problems.
Sorry... I don't not quite understand what the error you've running into. Please make sure the worksheet you want to operate on is the current activated one.
Would you mind share a little more details?

Zheng
OriginLab



Hi

I used this commands:

newbook name:="r2l" option:=lsname;


wrcopy iw:=[Book17]Sheet1! r1:=1 c1:=1 c2:=1 ow:=[r2l]Sheet1! transpose:=1;
win -a r2l;

loop(var, 1, wks.ncols){
wks.col$(var).setformat(4);
/};

This solution works but the date is in the format "dd-mm-yyyy".

If I use

newbook name:="r2l" option:=lsname;


wrcopy iw:=[Book17]Sheet1! r1:=1 c1:=1 c2:=1 ow:=[r2l]Sheet1! transpose:=1;
win -a r2l;

loop(var, 1, wks.ncols){
wks.col$(var).setformat(4,22, dd'-'MM'-'yyyy HH:mm);
/};


Then it does not transform the columns into date at all. It just copy the book17 c1 to the first row in r2l but in number format. I am using origin 8.5.1 SR1.


Thanks,

BR
Matteo
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/23/2015 :  1:26:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Would you mind update to latest SR version of 851 and try again?
Your script works fine in my SR2, at least.
Go to Top of Page

aprilmitchell

USA
1 Posts

Posted - 02/10/2015 :  11:19:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This is working:

for (int ii = 1; ii <= wks.ncols; ii++) {
wks.col$(ii).setformat(4, 22, dd'-'MM'-'yyyy HH:mm); // Set col(ii) to be this format
}

April
Go to Top of Page

MariaRichard

USA
1 Posts

Posted - 02/18/2015 :  08:00:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks all members for contributing in this forum. Keep it up.

[url=http://www.floridabusinessloans.net/bad-credit-business-loans.php]Bad Credit Business Loans[/url]|[url=http://www.floridabusinessloans.net/florida-bussines-loan.php]Florida Business Loans[/url]

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000