Multiple Strings' Names production

The basics of how to develop, test, and use models.
Post Reply
makrseke
Posts: 16
Joined: Mon Apr 03, 2017 6:43 am

Multiple Strings' Names production

Post by makrseke »

Dear all,

SITUATION:
I would like to store in one single file several data that I am obtaining from my .hoc model (a myelinated neuron-cell). And for this I need to have the titles of the data-to-be-stored in the first line of my file. However, since it is a myelinated cell, the number of myelin compartments may be changed during the different tests I perform (in one test may be one, in an other 5, etc). Hence, the number of data-titles will have to change accordingly (if number_of_Myelin_sections = 1 then the number_of_titles_for_Myelin should be 1 ; or if number_of_Myelin_sections = 5 then the number_of_titles_for_Myelin should also be 5 ; etc ).

QUESTION:
I want to find a way to produce each time via a for-loop the amount of names that refer to these myelin-sections. But strdef cannot make string-matrices...

EXAMPLE: For one test I have 2 Myelin-Sections. So I want two strdef: Myelin1_CV and Myelin2_CV as title-handlers for the final file.
But then, I wanna run a test for 20 Myelin-Sections. They are too many to create each time by code and hand the strdef : Myelin1_CV , Myelin2_CV , ... , Myelin20_CV .

Is it possible to produce separate names per myelin section via a for-loop (automatically)? Is there any way?

Any ideas of approach would be really appreciated cause I am quite stuck.

Thank you very much in advance,
Best,
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Multiple Strings' Names production

Post by ted »

sprint. Read about it in the Programmer's Reference.

Code: Select all

strdef tmpstr
for i = 0,3 {
  sprint(tmpstr, "run%d_20170614", i)
  print tmpstr
}
makrseke
Posts: 16
Joined: Mon Apr 03, 2017 6:43 am

Re: Multiple Strings' Names production

Post by makrseke »

Dear Ted,
Thank you for your reply! I was using this command for generating different-file names and did not see it used also for creating different strdef names. Very helpful!
Thanks again!

Best,
Post Reply