Specifying a default for graph cursor default

I would like to use the cursor axis info copy feature to copy date and time with date format YYYYMMDD followed by time format HH:MM:SS.SSS - for example 20260725 05:04:40.562.  However, graphs use a date format DD/MM/YYYY.  This is not a particular problem.  However, the cursor displays the position uses the same format - for example 25/07/2026 05:04:40.562.  I have the cursor info Date format set to readable with seconds and fractional seconds digits to three. Tables display the date/time in the desired format 20260725 05:04:40.562 which is my working format.

Any thoughts on how I can change the cursor copy format ?

chozo

I have a bit difficulty to follow what you are trying to achieve. The Copy Value menu of the Info bar copies the date value exactly as it is displayed in the format you have set. This date / time format is the same as for your system settings (on Windows), i.e., the short date with the long time. If you want to change this, go to the Windows settings dialog and change the date format. If you want a specific date format without changing any settings you can use the raw time in seconds instead and use Secs2Date() and Secs2Time(). For example to get the date in your format YYYYMMDD, you could use:

Print ReplaceString("-",Secs2Date(RawTime,-2),"")

 

Mike German

A picture is worth a thousand words ... the screen shot shows a part of a table  with date and time displayed in the format I want. The part of a graph shows the date format for axis and for cursor copying.  They are both for the same double precision  wave of date/time.  The graph format, I learn, uses the default Windows format.  I do not particularly want to change  Windows.

So, in one instance (the table) Igor displays it in the desired format and in another (copy graph cursor) it does not.  Just hoping for a format for copy from cursor that was consistent with table display.

2026-07-26_115659.png (37.52 KB)
chozo

OK, I see. I assume you have the table set to a custom format which shows YYYYMMDD without separators, or how did you get the table to display this way? You can set up the graph axis in the same way if you want. But I am not aware of any way to set a custom format for the Info bar, so I am afraid there is no way to achieve exactly what you want (maybe someone else has an idea). However, you could set up a simple script which copies the date/time from the current cursor position any specific format you might desire by using the raw time and then pass Secs2Date() and Secs2Time() through a formatting function. Is this a useful alternative or do you have to use Copy Value?

Mike German

I have a number of places in my experiments where I need to paste the cursor copy: to search a table; to find a specific date-time on a different database; etc.   I do paste it and translate to desired format or edit it,  but the I do this so many times  I thought there may be a better way.  Maybe someone else has some ideas.

jjweimer

Consider using a function. Grab the x position of the cursor. Translate it to the desired format. Output it. Once the function works by manual invocation, give it a Macro menu with a command/option keystroke call and put the procedure as a general utility in Igor Procedures. Subsequently, set the cursor on the graph where you want, switch to activate your blank table cell, and invoke the copy->translate->paste function via its keystroke command.

tony

Edit - I misunderstood the original request. Here is chozo's suggestion in code form, and a function to find a value in a table:

Menu "GraphPopup"
	"copy cursor value", /Q, ShowCursorValue()
	"find cursor x in first column of top table", /Q, FindCursorValueInTable()
End

Function ShowCursorValue()
	wave xwave = CsrXWaveRef(A)
	variable secs = xwave(pcsr(A))
	
	string str = replacestring("-", Secs2Date(secs, -2), "") + " " + Secs2Time(secs, 3, 3)
	PutScrapText str
	doalert 0, "copied string is " + str
End

Function FindCursorValueInTable()
	string strInfo = TableInfo("", 0)
	wave wTime = $stringbykey("WAVE", strInfo)
	wave xwave = CsrXWaveRef(A)
	
	FindLevel/P wTime, xwave(pcsr(A))
	ModifyTable topLeftCell=(V_LevelX , 0 ), selection=(V_LevelX , 0 , V_LevelX , 0 , V_LevelX , 0 )
End

 

This was not what was requested :

 

Menu "TablePopup"
	"set cursor", /Q, SetCursor()
End

Function SetCursor()
	GetLastUserMenuInfo
	WAVE/Z selWave = $S_firstColumnPath
	GetSelection table, $S_tableName, 1
	
	// if the wave in table is also the xwave
	// cursor/P A, $CsrWave(A), V_startRow

	variable secs = selWave[V_startRow]
	wave xwave = CsrXWaveRef(A)
	FindLevel/P xwave, secs
	cursor/P A, $CsrWave(A), V_LevelX
End
johnweeks

The format choices in the Info bar were driven by need for compact formatting, and an attempt to avoid making it too complicated to use. It wasn't envisioned to be a general-purpose format, but rather, an aid to understanding the graph.

KZarzana

It would be useful if we could programmatically change the date/time format in the infobar, or even just capture it as a graph preference.  Changing the format to Readable with Seconds (with or without the date) is something I do pretty much every time I have a graph with time on the X axis.  

In reply to by KZarzana

johnweeks

KZarzana wrote:

It would be useful if we could programmatically change the date/time format in the infobar, or even just capture it as a graph preference.  Changing the format to Readable with Seconds (with or without the date) is something I do pretty much every time I have a graph with time on the X axis.  

I just tried the info cursors on a graph with a date/time axis. At first, I thought it wasn't even setting the format to date/time, then realized that that is the "compact" format (which is identified in the source code as "unreadable" :).

Yeah, I hear you, and agree that is a pretty much essential upgrade.