how can I add a command for my app to rerun - button
I'm trying to get the app to "rerun" when the "return to formula list" button is pushed.
I thought this would work since I basically have it going back to the main list, but once it gets back to the list and another selection is made, it exits the app. this obviously isn't the whole code, I just included the first two options.
--DIVE FORMULAS--
--RUN FORMULA LIST--
set x to item 1 of (choose from list {"Divers consumption at depth", "Free Gas Volume (FGV)", "Cylinder Duration", "Partial Pressure", "Initial Depth", "Cylinder Mixing"})
--DIVERS CONSUMPTION AT DEPTH--
if x is "Divers consumption at depth" then
--VARIABLES--
display dialog "What is divers breathing volume (L/min) (default 35 l/min?" default answer "35"
set varDvol to text returned of result
display dialog "What is divers absolute depth pressure (bar)" default answer ""
set varPbar to text returned of result
--FORMULA--
set answer to varDvol * varPbar
--ANSWER--
display dialog "A diver breathing " & varDvol & " l/min, at an absolute pressure of " & varPbar & " bar, will have a consumption of " & answer & " l/min" as text buttons {"See formula", "Return to formula list", "Exit"}
--OPTIONS--
set response to button returned of result
--SEE FORMULA--
if response = "See formula" then
display dialog "Divers Consumption = Divers Breathing Volume * Absolute pressure of depth (bar)" buttons ("Return to Formula List")
--RETURN TO FORMULA LIST--
set response to button returned of result
if response = "Return to Formula List" then
set x to item 1 of (choose from list {"Divers consumption at depth", "Free gas volume (FGV)", "Cylinder Duration", "Prartial Pressure", "Initial Depth", "Cylinder Mixing"})
end if
--RETURN TO FORMULA LIST--
else if response = "Return to formula list" then
set x to item 1 of (choose from list {"Divers consumption at depth", "Free gas volume (FGV)", "Cylinder Duration", "Prartial Pressure", "Initial Depth", "Cylinder Mixing"})
--EXIT APP--
else if response = "Exit" then
display dialog "Are you sure you wish to exit?" buttons {"Return to Formula List", "Exit"}
set response to button returned of result
if response = "Return to Formula List" then
set x to item 1 of (choose from list {"Divers consumption at depth", "Free gas volume (FGV)", "Cylinder Duration", "Prartial Pressure", "Initial Depth", "Cylinder Mixing"})
end if
else if response = "EXIT" then
quit
end if
--FREE GAS VOLUME--
else if x is "Free gas volume (FGV)" then
--VARIABLES--
display dialog "What is the floodable volume of the cylinder (L)?" default answer ""
set varFvol to text returned of result
display dialog "What is the pressure of the cylinder (bar)?" default answer ""
set varCylPress to text returned of result
--FORMULA--
set answer to varFvol * varCylPress
--ANSWER--
display dialog "The free gas volume is (L)" & answer as text buttons {"See formula", "Return to formula list", "Exit"}
--OPTIONS--
set response to button returned of result
--SEE FORMULA--
if response = "See formula" then
display dialog "FGV = Floodable volume of cylinder * Pressure of cylinder (bar)"
--RETURN TO FORMULA LIST--
else if response = "Return to formula list" then
set x to item 1 of (choose from list {"Divers consumption at depth", "Free gas volume (FGV)", "Cylinder Duration", "Partial Pressure", "Initial Depth", "Cylinder Mixing"})
--EXIT APP--
else if response = "Exit" then
#do a third thing
end if
like I said, the "return to formula list" button works, but when I make another choice from the main list, the app closes, it won't go on to the next chosen function, which is what I'm looking for
You should look into the use of handlers (subroutines), otherwise you are going to get lost fairly quickly as you implement the other options or expand features in the script.
One way you can do this is by restructuring the script, putting the main list into a repeat statement, and having each choice run in a separate handler. These handlers would only be concerned with their specific function (also handy for viewing and debugging), and could return the button of the last dialog for the main loop to use, for example:
on run -- main
repeat -- forever
set choice to (choose from list {"Divers consumption at depth", "Free Gas Volume (FGV)", "Cylinder Duration", "Partial Pressure", "Initial Depth", "Cylinder Mixing"} cancel button name "Exit") as text — just one item
if choice is "Divers consumption at depth" then
set theResult to consumption()
else if choice is "Free Gas Volume (FGV)" then
set theResult to volume()
else if choice is "Cylinder Duration" then
set theResult to duration()
else if choice is "Partial Pressure" then
set theResult to pressure()
else if choice is "Initial Depth" then
set theResult to depth()
else if choice is "Cylinder Mixing" then
set theResult to mixing()
end if
if choice is "false" or theResult is "Exit" then -- exit
set response to (display dialog "Are you sure you wish to exit?" buttons {"Return to Formula List", "Exit"})
if button returned of response is "Exit" then exit repeat
end if
end repeat
end run
on consumption() -- Divers consumption at depth
--VARIABLES--
set response to (display dialog "What is divers breathing volume (L/min) (default 35 l/min?" default answer "35" buttons {"Exit", "OK"} default button 2)
if button returned of response is "Exit" then return "Exit"
set varDvol to text returned of response
set response to (display dialog "What is divers absolute depth pressure (bar)" default answer "1" buttons {"Exit", "OK"} default button 2)
if button returned of response is "Exit" then return "Exit"
set varPbar to text returned of response
--FORMULA--
set answer to varDvol * varPbar
--ANSWER--
set response to (display dialog "A diver breathing " & varDvol & " l/min, at an absolute pressure of " & varPbar & " bar, will have a consumption of " & answer & " l/min" as text buttons {"See formula", "Return to formula list", "Exit"})
--SEE FORMULA--
if button returned of response = "See formula" then
set response to (display dialog "Divers Consumption = Divers Breathing Volume * Absolute pressure of depth (bar)" buttons {"Return to Formula List", "Exit"})
end if
return button returned of response
end consumption
on volume() -- Free Gas Volume (FGV)
set response to (display dialog "volume" buttons {"Exit", "OK"} default button 2)
return button returned of response
end volume
on duration() -- Cylinder Duration
set response to (display dialog "duration" buttons {"Exit", "OK"} default button 2)
return button returned of response
end duration
on pressure() -- Partial Pressure
set response to (display dialog "pressure" buttons {"Exit", "OK"} default button 2)
return button returned of response
end pressure
on depth() -- Initial Depth
set response to (display dialog "depth" buttons {"Exit", "OK"} default button 2)
return button returned of response
end depth
on mixing() -- Cylinder Mixing
set response to (display dialog "mixing" buttons {"Exit", "OK"} default button 2)
return button returned of response
end mixing
The simplest solution, I think, is to enclose your code in a repeat loop, and let the repeat loop handle all of the 'return to list' actions. Then you can delete all the duplicate choose from list lines, and all you need to do is call exit repeat when you want to get out.
--DIVE FORMULAS--
--RUN FORMULA LIST--
repeat
set x to item 1 of (choose from list {"Divers consumption at depth", "Free Gas Volume (FGV)", "Cylinder Duration", "Partial Pressure", "Initial Depth", "Cylinder Mixing"})
--DIVERS CONSUMPTION AT DEPTH--
if x is "Divers consumption at depth" then
--VARIABLES--
display dialog "What is divers breathing volume (L/min) (default 35 l/min?" default answer "35"
set varDvol to text returned of result
display dialog "What is divers absolute depth pressure (bar)" default answer ""
set varPbar to text returned of result
--FORMULA--
set answer to varDvol * varPbar
--ANSWER--
display dialog "A diver breathing " & varDvol & " l/min, at an absolute pressure of " & varPbar & " bar, will have a consumption of " & answer & " l/min" as text buttons {"See formula", "Return to formula list", "Exit"}
set response to button returned of result
--SEE FORMULA--
if response = "See formula" then
display dialog "Divers Consumption = Divers Breathing Volume * Absolute pressure of depth (bar)" buttons ("Return to Formula List")
else if response = "Exit" then
display dialog "Are you sure you wish to exit?" buttons {"Return to Formula List", "Exit"}
set response to button returned of result
if response = "exit" then
exit repeat
end if
end if
--FREE GAS VOLUME--
else if x is "Free gas volume (FGV)" then
--VARIABLES--
display dialog "What is the floodable volume of the cylinder (L)?" default answer ""
set varFvol to text returned of result
display dialog "What is the pressure of the cylinder (bar)?" default answer ""
set varCylPress to text returned of result
--FORMULA--
set answer to varFvol * varCylPress
--ANSWER--
display dialog "The free gas volume is (L)" & answer as text buttons {"See formula", "Return to formula list", "Exit"}
--OPTIONS--
set response to button returned of result
--SEE FORMULA--
if response = "See formula" then
display dialog "FGV = Floodable volume of cylinder * Pressure of cylinder (bar)"
--EXIT APP--
else if response = "Exit" then
#do a third thing
end if
end if
end repeat
You don't need to explicitly call 'quit' unless your app is designed as a stay-open app. Once you exit the repeat loop and hit the last line of code, the app will automatically terminate.
This should work for you…
Anywhere in your code you see this...
if response = "Return to Formula List" then
set x to item 1 of (choose from list {"Divers consumption at depth", "Free gas volume (FGV)", "Cylinder Duration", "Prartial Pressure", "Initial Depth", "Cylinder Mixing"})
end if
Try replacing it with this...
if response = "Return to Formula List" then
run me
end if
Related
I'm able to run the code with zero observation, although the dataset has information pertaining to the filter that am using
Eg: Date<-filter(storedata, "Order Date">= "6/9/2014" & "Order Date"<="11/8/2016") Shipmode<-filter(storedata, "Ship Mode" == "Standard Class")
How do I start an element hidden but then show it when I select it from dropdown, HTA?
A few questions in one post. I am making an HTA script that has a dropdown for a few examples but then has a 'custom' option. When I click custom I would like for a text box and some words telling the user to enter a number in miliseconds to show under it and then hide if I choose another option. My questions: 1. How do I start the textbox and the words above it hidden? 2. How do I make it appear/ disappear based on the users choice in the dropdown? I will post the relevant code that I have as of now that I tried but does not work. Please note this is my first time messing with hta so some things might be redundant or i might be missing some parts as i just pulled the relevant parts from my script. Also right now the text box and words are not hidden on start as i don't know how to do that. <BODY> <SCRIPT LANGUAGE="VBScript"> Set wshShell = CreateObject("WScript.Shell") Sub btn01_OnClick Dim strProduct Dim Timerdelay oElements = Window.Message.SelectedIndex strProduct = Window.Message.Options(oElements).Text Select Case strProduct Case "1 Second" Timerdelay=1000 CustomTime.style.visibility="hidden" ShowTime.style.visibility="hidden" Case "3 Seconds" Timerdelay=3000 CustomTime.style.visibility="hidden" ShowTime.style.visibility="hidden" Case "5 Seconds" Timerdelay=5000 CustomTime.style.visibility="hidden" ShowTime.style.visibility="hidden" Case "30 Seconds" Timerdelay=30000 CustomTime.style.visibility="hidden" ShowTime.style.visibility="hidden" Case "0.5 Seconds" Timerdelay=500 CustomTime.style.visibility="hidden" ShowTime.style.visibility="hidden" Case "Custom" CustomTime.style.visibility="visable" ShowTime.style.visibility="visable" Timerdelay= CustomTime.Value End Select End Sub </SCRIPT> <span id=ShowTime><P>Enter Your Time Delay In Miliseconds<P> <input type="text" name="CustomTime" size="30"></span> <Input Type = "Button" Name = "btn01" VALUE = "START"> </BODY>
You can use the atribute onchange='myfunctionName(possible_value)' on the dropdown. On the linked function, check the value of the dropdown and your switch case should work. Also, check for syntax error such as "visable" instead of "visible". If you don't know how to retrieve the value from the dropdown, you can refert to this link: Get drop down value
Scilab: How to use cbmenu in xclick()
I do not understand the explanation of the output argument cbmenu in the Scilab documentation of xclick. It says: cbmenu: String: callback associated to a menu if xclick returns due to a click on a menu. I did not find any example in the web so I ask here. I have coded a snippet which lumps together the elements which may be relevant for cbmenu. The snippet does nothing, when I click on CLICK. Could anyone alter/complement/revise the code so that it does something - whatever it is to give me a clue what could be done with cbmenu? xdel() x=[-1 +1]; cf=figure(0); plot(x,x) m=uimenu(cf,'label','CLICK','callback','two=1+1'); [ibutton,xcoord,yxcoord,iwin,cbmenu]=xclick(); Kind regards Rosestock
This is a minimal script which explains what the 5th output argument of xclick() can do: xdel() x=[-1 +1]; winnum=1; win=string(winnum); cf=figure(winnum); plot(x,x) C=["Green" "Red" "Abort"];//case name strings addmenu(winnum, C(1)); C1="execstr("+C(1)+"_"+win+"(1))"; addmenu(winnum, C(2)); C2="execstr("+C(2)+"_"+win+"(1))"; addmenu(winnum, C(3)); C3="execstr("+C(3)+"_"+win+"(1))"; while %t [!,!,!,!,cbmenu]=xclick(); //Get the clicked option by cbmenu if cbmenu==C1, cf.background=3; end if cbmenu==C2, cf.background=5; end if cbmenu==C3, break, end end
If I get your intentions right, you want to create a custom menu. Here is a small demo, how to bulid custom menu elements, and also how to use locate to get back coordinates (but you don't need xclick to sense menu clicking). This code does not use explicitly cbmenu, but it is not necessary to get it work. If you run the code, first click the "Select range" menu, then click two times on the graph. Then the "Regression" menu is activated, and you can choose "Linear regession". By clicking "Exit program", the execution aborts. Not all nenu functions are implemented, they are there only to demonstrate a multilayer structure. I hope it helps! //Interactive menu demo // Scilab 5.5.2 // 2016.12.20. Attila Eredics // //Attention! //Do not close the graphic window with the original x symbol // while the program is running, // because the program will run infinitely! // But you can stop it in the Consol with: Ctrl+C and then typing: abort clc; clear; lines(0); //artificial data vectors row = 100; t=gsort(rand(row,1),'r','i'); //time c=10*t+8; //concentration c=c+rand(c); //add some noise //graphic window scf(0); clf(0); w=gcf(); //get current figure //new menu elements m3=uimenu(w,"Label","Select range","Callback","m=3"); m4=uimenu(w,"Label","Regression","Enable","off","ForegroundColor","0.5|0.5|0.5"); m41=uimenu(m4,"Label","Linear","Callback","m=41","Enable","on"); m42=uimenu(m4,"Label","Nonlinear","Callback","m=42","Enable","on"); m5=uimenu(w,"Label","Save results","Callback","m=5"); m6=uimenu(w,"Label","Exit program","Callback","abort","ForegroundColor","1|0|0"); plot2d(t,c,style=-5,frameflag=6); //plot the data xtitle("","time","concentration"); //axis labels while %T //infinite loop //-------------wait for user action (click on a menu)------- m=0; while m<1 xpause(1e4); //pause 10ms end //------------------the menu actions------------------------- if m==3 then //Select range mprintf("\nChoose 2 points (click on the graph)!"); coord=locate(2); //locate two clicks disp(coord); //coord: according to the axes //Select range in t vector for i=1:row-1 if coord(1,1)>=t(i) & coord(1,1)<t(i+1) then //t(i) <= 1st click < t(i+1) i1=i; end if coord(1,2)>=t(i) & coord(1,2)<t(i+1) then //t(i) <= 2nd click < t(i+1) i2=i; end end //selected range clear tt; clear cc; tt=t(i1:i2); cc=c(i1:i2); plot2d(tt,cc,style=-5); //plot selected points h2=gce(); h2.children.mark_foreground=3; //green m4.Enable="on"; //enable Regression menu m4.ForegroundColor="0|0|0" m3.Enable="off"; //Disable selection menu m3.ForegroundColor="0.5|0.5|0.5" elseif m==41 then //linear regression of the selected points mprintf("\nLinear regression"); [a,b,sig]=reglin(tt',cc'); plot2d([tt(1),tt($)],a*[tt(1),tt($)]+b,style=2); //blue line m41.Enable="off"; //disable Linear regression menu m41.ForegroundColor="0.5|0.5|0.5" elseif m==42 then //Nonlinear regression mprintf("\nNot implemented yet!"); elseif m==5 then //Save mprintf("\nNot implemented yet!"); end end
Autoit get current caret position Or current text box position
So i am working on a project and i got stuck on this part. I am trying to locate the position of ether the typing caret(The blinking line while typing) or the current text box that is being typed in. The main part that is hard is i am looking to do this for every input on my computer (Firefox search, Notepad, Renaming files, writing this post...) I am beginning to doubt that auto-it can do this, i am open to using another language that can do this. (I have not checked any other language but Auto-it yet) I have tested "WinGetCaretPos()" and a few other random scripts, but they had the same problem, they don't return the correct position. ~Thanks
Not all controls are standard window controls that can be accessed with AutoIt functions. Many programs (especially browsers) have nonstandard controls so "every input" on the computer might be hard to get. Here is an example of how to get the control information of any active window that is giving focus to a control AND has standard windows controls. HotKeySet("{ESC}", "Terminate") While 1 Sleep(500) GetControlFocus() WEnd Func GetControlFocus() Local $hWinHandle = WinGetHandle("[Active]") Local $sControl = ControlGetFocus($hWinHandle) Local $sText = "The active window handle is: " & $hWinHandle & #CRLF If $sControl <> "" Then $sText &= "The control with focus in the active window is: " & $sControl & #CRLF Local $aPos = ControlGetPos($hWinHandle, "", $sControl) $sText &= "Mouse position: X: " & $aPos[0] & " Y: " & $aPos[1] & #CRLF & "Size: " & $aPos[2] & ", " & $aPos[3] Else $sText &= "The active window is not giving focus to a control that AutoIt recognizes." EndIf ToolTip($sText, 0, 0) EndFunc ;==>GetControlFocus Func Terminate() Exit EndFunc ;==>Terminate You can get the control position of other programs using IUIAutomation and this UDF. But it would not be as simple as using a few standard AutoIt functions.
expression to format date as Su 1 in SSDT
I am working in SSDT creating a report. Trying to get a row/field to display "Su 1" , "Mo 2" for the day of week + increment the number of that day in the pay period. First half of code works. returning (Mo, Tu, We, Th, Fr etc) = LEFT(FORMAT(Fields!TransactionDate.Value,"ddd"),2) Issue Need to complete 2nd half to provide the increment count for the pay period. Code: + " "+ (STR(FORMAT(Fields!TransactionDate.Value,"d"))
FIX! bottom line of code produced the result I needed. =LEFT(FORMAT(Fields!TransactionDate.Value,"ddd"),2) + " "+ CStr(CInt(Format(Fields!TransactionDate.Value,"dd")))