Prompting and Inserting Values

I would like to create a function that prompts for the specific values of the instrument (like 0.2, 0.5, 0.8 etc.) and then be able to have it insert those prompt values

I want to do this so when I prompt for the values it will put in the 0.2, 0.5, and 0.8, that I type into the prompt, into this code:
Function RawGraphing(CCNNumberAll, TimeAll, CurrentSSAll)
    wave CCNNumberAll, TimeAll, CurrentSSAll
   
    Extract CCNNumberAll, ccnss1, CurrentSSAll == 0.2
    Extract TimeAll, timess1, CurrentSSAll == 0.2

    Extract CCNNumberAll, ccnss2, CurrentSSAll == 0.5
    Extract TimeAll, timess25, CurrentSSAll == 0.5

    Extract CCNNumberAll, ccnss3, CurrentSSAll == 0.8
    Extract TimeAll, timess3, CurrentSSAll == 0.8
End


and it will put in the values when I run
Legend/C/N=text0/J/H={0,5,10}/E=2 "\\s(ccnss1) SS=0.2%\r\\s(ccnss2) SS=0.5%\r\\s(ccnss3) SS=0.8%"



Do I prompt for a couple of values, and then assign them to seperate symbols or something so that I then type in SS="ASSIGNMENT"% or CurrentSSAll == "ASSIGNMENT" when writing procedures?
So far I have
Menu "Macros"
    "CCN Setting Values", CCNSettingValues()
End

Function CCNSettingValues()
    Variable u=0.2,v=0.5,x=0.8,y=1.1,z=1.4, a=500,b=500,c=250      
    Prompt u, "Enter the First SS Setting Value (%): "     
    Prompt v, "Enter the Second SS Setting Value (%): "    
    Prompt x, "Enter the Third SS Setting Value (%): "     
    Prompt y, "Enter the Fourth SS Setting Value (%): "    
    Prompt z, "Enter the FifthSS Setting Value (%): "
    Prompt a, "Enter in the Flow Rate (ccm): "             
    Prompt b, "Time removed at cycle repeat (seconds): "       
    Prompt c, "Time removed between SS steps (s): "    
    DoPrompt "Enter CCN Setting Values", u, v, x, y, z, a, b, c
    if (V_Flag)
        return -1       // User canceled
    endif

    Make/N=8 CCNSettings
    CCNSettings[0]=u
    CCNSettings[1]=v
    CCNSettings[2]=x
    CCNSettings[3]=y
    CCNSettings[4]=z
    CCNSettings[5]=a
    CCNSettings[6]=b
    CCNSettings[7]=c


End


Now to figure out how to put it places when I need it like in the textbox so SS="u"%, or CurrentSSAll == "v"
When you use a Prompt in Igor (in connection with a later call to DoPrompt), the variable given in the Prompt statement is where the value the user enters will be stored. So, in this code you gave earlier:
    Variable u=0.2,v=0.5,x=0.8,y=1.1,z=1.4, a=500,b=500,c=250      
    Prompt u, "Enter the First SS Setting Value (%): " 

the default value of variable u that the user will see when the prompt is displayed will be 0.2. After DoPrompt is called, if the user changes that value then the new value will be reflected in variable u.

In later code you can just use the variables in statements as you would use any other variables. If you want the values to be placed into a text box, I'd recommend that you use the sprintf operation to build the string you'll then place in a text box or legend. So, as an example, you might do something like this:
String tbString
sprintf tbString, "\\s(ccnss1) SS=%f%\r\\s(ccnss2) SS=%f%\r\\s(ccnss3) SS=%f%", u, v, x
Legend/C/N=text0/J/H={0,5,10}/E=2 tbString

You should read the command help for the sprintf and printf operations for information on what the various replacement codes (such as %f which is used in my example) mean.
aclight wrote:

In later code you can just use the variables in statements as you would use any other variables.



When I try and enter in the variable to this code
Function AvgGraphing(DataMean, CurrentSSAll)
    wave DataMean, CurrentSSAll
    variable x

   
    Extract DataMean, ccnss1, CurrentSSAll == x


It does not work properly and returns empty tables
astrotool wrote:
When I try and enter in the variable to this code
Function AvgGraphing(DataMean, CurrentSSAll)
    wave DataMean, CurrentSSAll
    variable x

    Extract DataMean, ccnss1, CurrentSSAll == x


It does not work properly and returns empty tables


Either pass x into the function ...

Function AvgGraphing(DataMean,CurrentSSAll,x)
...


... or get x within the function ...

Function AvgGraphing(DataMean,CurrentSSAll)
  wave DataMean, CurrentSSAll
  variable x

  [... prompt for x ... ]
  ...

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
Thanks, I ended up splitting my prompt in two and inserting it into each appropriate function, I just didn't want to have two prompts, but at least it works
I am (again) confused by your question. Before I go further, out of curiousity, could I ask how much programming experience you have outside of programming in Igor? Have you written routines in languages such as FORTRAN, C, Pascal, or even Basic? Have you taken a college course in programming? It might help me to better direct my answers, or at least find a way to help you rephrase your questions in a way that is easier (for me) to understand.

In the meantime, in response to your question about using something such as ...

 Extract source, dest, testwave == valuewave[0]


... this should work as long as all the waves (source, dest, testwave, valuewave) exist before this line of code is reached.

As for setting variables to be permanent, you want to declare them to be global using the /G flag ...

Function mytest(xv)
   variable xv

   print xv
   return 0
end


Use this function. Then, on the command line, execute the following:

variable/G xv = 10
mytest(5)
mytest(xv)


Check the data browser to see where xv is located.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
I have never programmed anything before, other than extensive HTML.

I just didn't want to make two prompts, but it really doesn't matter.

I wanted to have it so I could have a function prompt for values at the beginning, then store them, then later on use them in expressions as values. I tried tons of ways of calling them but to no avail. Thanks for the global variable, I will give that a try

I appreciate all your help, I know I have been a pain :-)
astrotool wrote:
I have never programmed anything before, other than extensive HTML.


This helps me understand better why your questions seem to be ... jumbled.

astrotool wrote:

I wanted to have it so I could have a function prompt for values at the beginning, then store them, then later on use them in expressions as values. I tried tons of ways of calling them but to no avail. Thanks for the global variable, I will give that a try


You have two tasks, GET+STORE values and USE values. Write two functions (using globally defined and accessed variables):

Function GetMyValues()

    // create global variables in a specific place

    NewDataFolder/O/S root:MyGlobals
    variable/G a, b, c, d
    <... prompt to input variables ...>

   // return to the root data folder

    SetDataFolder root:
    return 0
end

Function UseMyValues()

    // this is an EXAMPLE of how globals are accessed

    // variables

    NVAR a = root:MyGlobals:a
    NVAR b = root:MyGlobals:b
    NVAR c = root:MyGlobals:c
    NVAR d = root:MyGlobals:d

    // waves

    wave mydata = root:data:datawave1

   // use the above values

    mydata = a+ b*p^2 + c*p^3 - d*p^4

    return 0
end


Once you have each of these functions working properly by themselves, then you can use them together ...

Function DoItAll()
   GetMyValues()
   UseMyValues()
   return 0
end


astrotool wrote:
I appreciate all your help, I know I have been a pain :-)


Rather a bit confusing ... certainly not a pain. I suggest, as time permits, you might want to read a book on the basics of programming in a language such as C, javascript (not java), or basic (not visual basic).

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
jjweimer wrote:

Rather a bit confusing ... certainly not a pain. I suggest, as time permits, you might want to read a book on the basics of programming in a language such as C, javascript (not java), or basic (not visual basic).


Also, I'd recommend that you take a look at the well written Programming.ihf file that comes with Igor. I'd execute:
DisplayHelpTopic "Programming Overview"

from the Igor command line and start from there.
String tbString
sprintf tbString, "\\s(ccnss1) SS=%f%\r\\s(ccnss2) SS=%f%\r\\s(ccnss3) SS=%f%", u, v, x
Legend/C/N=text0/J/H={0,5,10}/E=2 tbString

Can someone explain to me how the '\\s' is this code works and what it does, why its needed? Thanks.

ssmith
DisplayHelpTopic "Backslashes in Annotation Escape Sequences"

That double backslash is required to make a single backslash in the final textbox text.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com