Iris,
as I said, the posted macro works for me. The text file is written and
it contains the data.
Did you wait until the macro finishes?
Please try again with:
/////////////////////////////
waitForUser("set the threshold and press OK, or cancel to exit macro");
getThreshold( lower, upper );
txt_file = File.open( "Thresholds.txt" );
print( txt_file, "Minimum threshold: " + lower + "\n" );
print( txt_file, "Maximum threshold: " + upper );
File.close( txt_file );
exit();
/////////////////////////////
Best
Herbie
::::::::::::::::::::::::::::::::::::::
Am 25.10.16 um 13:02 schrieb Ihiertje:--> [hidden email]>:
> Hi Herbie,
>
> I used your code this time. Last time I did not now where the Threshold
> file would be saved.
> It still creates the text file, however, no data is saved in it. Also no
> error is given by ImageJ.
>
> Could it maybe be due to an update or something? It is strange that is does
> not work with me.
>
> Kind regards,
>
> Iris
>
> 2016-10-25 11:47 GMT+02:00 Herbie [via ImageJ] <>>> [hidden email] <http:///user/SendEmail.jtp?>
>> Good day Iris,
>>
>> if you look at
>> <https://imagej.nih.gov/ij/developer/macro/functions.html >
>> you will find the following:
>>
>> "File.open(path)
>> Creates a new text file and returns a file variable that refers to it.
>> To write to the file, pass the file variable to the print function.
>> Displays a file save dialog box if path is an empty string. The file is
>> closed when the macro exits. Currently, only one file can be open at a
>> time. For an example, refer to the SaveTextFileDemo macro."
>>
>> With this information you may either pass an empty string as path which
>> brings up a file dialog or you enter a correct path.
>>
>> I don't know whether Output+"Thresholds.txt" is a correct path because
>> you do not specify Output in your code snippet.
>>
>> I've simply used "Thresholds.txt" which means that the file is stored in
>> the ImageJ directory. The text file definitely contains:
>>
>> Minimum threshold: <min_val>
>> Maximum threshold: <max_val>
>>
>> I don't understand what goes wrong on your side. Please try to run the
>> code I've provided without any changes and perhaps use
>> txt_file = File.open( "" );
>> instead.
>>
>> Good luck
>>
>> Herbie
>>
>> ::::::::::::::::::::::::::::::::::::
>> Am 25.10.16 um 08:47 schrieb Ihiertje:
>>
>>> Hi Herbie,
>>>
>>> Thank you for your effert and time. Unfortunately my code is not working
>>> yet.
>>> The textfile thresholds is made, however in de debug screen it is stored
>> as
>>> follows: file ="~0~". So it won't recognizes where it is stored I think.
>>> This is also the reason I think that nothing gets printed in it. When
>>> running this part of the code no error is given.
>>>
>>> file=File.open(Output+"Thresholds.txt")
>>> print(file, "Minimum threshold: "+lower + "\n")
>>>
>>> Do you maybe have an idea how to solve this?
>>>
>>> Thanks a lot.
>>>
>>> Iris
>>>
>>> 2016-10-24 17:10 GMT+02:00 Herbie [via ImageJ] <type=node&node=5017470&i=0 >>:>> com/Save-values-Popup-window->>
>>>
>>>> Iris,
>>>>
>>>> this is part 2 of my answer.
>>>>
>>>> Here is the macro code:
>>>>
>>>> /////////////////////////////////
>>>> waitForUser("set the threshold and press OK, or cancel to exit macro");
>>>> getThreshold( lower, upper );
>>>> print("your thresholds are: " + lower + " to "+ upper );
>>>>
>>>> txt_file = File.open( "Thresholds.txt" );
>>>> print( txt_file, "Minimum threshold: " + lower + "\n" );
>>>> print( txt_file, "Maximum threshold: " + upper );
>>>> /////////////////////////////////
>>>>
>>>> getNumber( "Minimum", lower );
>>>>
>>>> Does the latter help with your last question?
>>>>
>>>> Best
>>>>
>>>> Herbie
>>>>
>>>> ::::::::::::::::::::::::::::::::::::::
>>>> Am 24.10.16 um 16:11 schrieb Ihiertje:
>>>>
>>>>> Hi,
>>>>>
>>>>> Last time I was helped very well, so I hope someone can help me again.
>>>>> I have an image which I threshold manually. Afterwards I want to save
>>>> the
>>>>> minimal and maximal value of this threshold to a textfile. This is
>> done
>>>> two
>>>>> times, so if the text file could be updated, that would be great.
>>>>>
>>>>> Underneath you find my code so far. First I want to create a textfile
>>>> where
>>>>> I can save my values. Then I want to print the text 'Minimal
>> threshold'
>>>> plus
>>>>> its value. However, it creates the text file, but does not print any
>>>> text in
>>>>> it. Is there a way to print the text in the textfile and update it
>> with
>>>> the
>>>>> maximal threshold?
>>>>>
>>>>> /run("Threshold...");
>>>>> waitForUser("set the threshold and press OK, or cancel to exit
>> macro");
>>>>> getThreshold(lower,upper)
>>>>> print("your thresholds are; "+lower, "to "+ upper);
>>>>>
>>>>> file=File.open(Output+threshold.txt)
>>>>> open(file)
>>>>> print(file, "Minimal threshold"+lower+"\n");/
>>>>>
>>>>> Next to that, I would like to have a pop-up screen where some can
>> select
>>>> a
>>>>> value that will be used in another calculation. I found that
>>>> Dialog.create
>>>>> could be used for this. However, normally codes like Dialog.create
>> will
>>>>> change from black to a yellow collor when there typed right. With
>>>>> Dialog.create this does not happen and also does not show any pop-up
>>>> screen
>>>>> when an option with Dialog.addChoice is included.
>>>>>
>>>>> Thank you already.
>>>>>
>>>>> Iris
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context: http://imagej.1557.x6.nabble.
>>>> com/Save-values-Popup-window-tp5017455.html
>>>>> Sent from the ImageJ mailing list archive at Nabble.com.
>>>>>
>>>>> --
>>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>>> ------------------------------
>>>> If you reply to this email, your message will be added to the
>> discussion
>>>> below:
>>>> http://imagej.1557.x6.nabble.com/Save-values-Popup-window-
>>>> tp5017455p5017459.html
>>>> To unsubscribe from Save values & Popup window, click here
>>>> <
>>>> .
>>>> NAML
>>>> <http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp ?
>> macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&
>> base=nabble.naml.namespaces.BasicNamespace-nabble.view.
>> web.template.NabbleNamespace-nabble.view.web.template.
>> NodeNamespace&breadcrumbs=notify_subscribers%21nabble%
>> 3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_
>> instant_email%21nabble%3Aemail.naml>
>>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context: http://imagej.1557.x6.nabble.tp5017455p5017467.html
>>> Sent from the ImageJ mailing list archive at Nabble.com.>> tp5017455p5017470.html
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://imagej.1557.x6.nabble.com/Save-values-Popup-window-
>> To unsubscribe from Save values & Popup window, click here
>> <
>> .
>> NAML
>> <http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp? >macro=macro_viewer&id=instant_ html%21nabble%3Aemail.naml& base=nabble.naml.namespaces. BasicNamespace-nabble.view. web.template.NabbleNamespace- nabble.view.web.template. NodeNamespace&breadcrumbs= notify_subscribers%21nabble% 3Aemail.naml-instant_emails% 21nabble%3Aemail.naml-send_ instant_email%21nabble% 3Aemail.naml
>>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Save-values-Popup-window- tp5017455p5017472.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
If you reply to this email, your message will be added to the discussion below:http://imagej.1557.x6.nabble.com/Save-values-Popup-window- tp5017455p5017474.html
Free forum by Nabble | Disable Popup Ads | Edit this page |