I want to draw a diagram like below.
And my origin code is :
#startuml
start
if (c1) then (YES)
:A;
else (NO)
if (C2) then (NO)
:A;
else (NO)
:C;
endif
endif
stop
#enduml
It seems that there is no alias syntax in new plantUml syntax. I've found the old syntax is --> "some activity" as render.
How can I refer to the same activity?
Maybe you saw this experimental feature already?
You can use label and goto keywords to denote goto processing, with:
label <label_name>
goto <label_name>
#startuml
start
if (c1) then (YES)
label sp_lab0
label A ' define the label to later reference it with goto
:A;
else (NO)
if (C2) then (NO)
label sp_lab1
goto A ' reference label to goto
else (NO)
:C;
endif
endif
stop
#enduml
Related
I want to build something like this using PlantUML:
But I'm only able to build this:
This is my code:
#startuml
start
:Init;
fork
:Treatment 1;
fork again
:Treatment 2;
end fork
#enduml
As far as I understand Activity Diagrams
you can parallelize things into swimlanes, but there's only one start
everything has to be in a swimlane (so I proposed "Control" as the start of your diagram)
PlantUML (and maybe UML in general) expects you to have a join after a fork (which again, I did in the "Control" lane):
#startuml
|Control|
:Init;
fork
|#AntiqueWhite|Swimlane1|
'start
:foo1;
'stop
fork again
|Swimlane2|
'start
:foo2;
:foo3;
'stop
|Control|
end fork
stop
#enduml
The PlantUML layout also isn't ideal, since the fork line stays only in the swimlane of the Control process.
This is possible by combining an extra column for forking and hiding the start arrows:
#startuml
| |
|a| Swim1
|b| Swim2
|c| Swim3
| |
fork
|a|
-[hidden]->
start
if (A?) then (no)
stop
else (yes)
if (B?) then (no)
stop
else (yes)
:C;
endif
endif
stop
fork again
|b|
-[hidden]->
start
:Process 2;
stop
fork again
|c|
-[hidden]->
start
:Process 3;
stop
| |
end fork
#enduml
Not a complete solution but:
#startuml
start
:Init;
fork
start
:Treatment 1;
end
fork again
start
:Treatment 2;
end
end fork
#enduml
see also:
the code through the plantuml web server:
http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuG8pkAmyyp9BhBdIyekoOI8XHQc99RcfUIKAXjPSgNafO4c5nFJ4p3nC9KPW9I2i03R30SW2cWu0
the corresponding png:
In emacs , when I place the cursor on a } the echo buffer displays the corresponding content of the matching {
for example:
if(a==b){
.
.
.
}
placing my cursor on } would display " if (a==b). "
Googling helped find this plugin that sounded similar
https://github.com/vim-scripts/tEchoPair/blob/master/README
I'm new to vim. I installed the plugin but I don't get the intended result.
Is there a better way to get the matching parenthesis text? If not, how do I use this plugin ?
I tried to code a tiny script ShowMatchBrace.vim (that you can put it in your .vimrc) which displays the matched line for "}" and ")" during normal mode. (You are free to do whatever you want with it)
autocmd! CursorMoved * call <SID>MatchBraces()
"This variable is for redrawing the cmd-line"
if !exists("s:brace")
let s:brace=0
endif
function! s:MatchBraces()
let l:currentPos=getpos('.')
if getline('.')[col('.') - 1] =~# '\v\}|\)'
let s:brace=1
normal! %
if getline('.')[col('.')-1] =~# '\v\{|\('
echo getline('.')
else
echohl ErrorMsg | echomsg "No match found for }|)" | echohl None
endif
elseif s:brace ==# 1
call feedkeys("\<c-l>")
let s:brace=0
endif
call setpos('.',l:currentPos)
endfunction
Demo1
1 The Demo was before adding little changes to the code to include ")" case but it behaves exactly the same way as "}".
Is it possible to make a Batch, or .vbs if needed, is it possible to make batch have a little icon down there with the flag, battery and volume.
I want it to be a "Shutting down in xx minutes/hours", and mayyybbe clicking it cancels' it.
Thanks in advance :)
Well, I know how to accomplish part of what you want -- making a systray balloon tip by borrowing from PowerShell. But I don't know how to make it listen for dismissal of the balloon. Maybe someone else can offer another answer building upon mine?
Anyway, I use this for a conversion script I made to convert flac to mp3 in batches. Feel free to hack it for your own evil purposes.
#echo off
setlocal
for %%I in (*.flac) do (
rem // This initiates the systray balloon.
call :systray converting from "%%~nxI" to "%%~nI.mp3"
)
goto :EOF
rem // Here's the :systray function
:systray <message>
setlocal enabledelayedexpansion
set "args=%*"
set "args=!args:'=''!"
set "code="[void] [Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms');^
$o=New-Object Windows.Forms.NotifyIcon;$o.Icon='%systemroot%\System32\PerfCenterCpl.ico';^
$o.BalloonTipIcon='Info';$o.BalloonTipText='!args!';$o.BalloonTipTitle='%~nx0';$o.Visible=1;^
$o.ShowBalloonTip(10000);Start-Sleep -M 12000;$o.Dispose();Exit""
start /b "" "powershell" %code%
endlocal & goto :EOF
The n values in $o.ShowBalloonTip(n1) and Start-Sleep -Mn2 are in milliseconds. Salt to taste.
Update: I found a bit about registering an event for $o.BalloonTipClicked as well as a lovely example in the wild. Basically, replace this:
$o.ShowBalloonTip(10000);Start-Sleep -M 12000;$o.Dispose();Exit
... with this:
$o.ShowBalloonTip(10000);register-objectevent $o BalloonTipClicked clicked;^
if (wait-event clicked -t 12) {$true} else {$false}; $o.Dispose(); Exit
You also need to execute powershell in a single threaded apartment for the event to work.
start /b "" "powershell" -STA %code%
Now, you need to figure out how to make that relevant back in the context of your batch process. For one thing, you'd probably no longer be able to use start /b to make the balloon tip non-blocking, and you'd probably use a for /F loop to capture the output of the powershell command.
Adding to your worries, I propose that "Shutting down in xx minutes" is not entirely user-friendly. What if "Shutting down in 30 minutes" appeared 29 minutes ago, but the user just now saw it? "Shutting down at 9:51 AM" might be better.
So with all this in mind, since what you want is event driven and since the batch language doesn't handle date-time math all that easily, I suggest doing the whole damn thing in PowerShell. Save this with a .ps1 extension. Right-click and run with PowerShell. Or if you want to execute it from a cmd console, do powershell ".\scriptname.ps1".
set-executionpolicy remotesigned
if ([threading.thread]::CurrentThread.GetApartmentState() -eq "MTA") {
& powershell.exe -window minimized -sta $MyInvocation.MyCommand.Definition
exit
}
[void] [Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
$minutes = 30
$launch_time = (Get-Date).AddMinutes($minutes).ToShortTimeString()
$o = New-Object Windows.Forms.NotifyIcon
$o.Icon = "$env:SystemRoot\System32\PerfCenterCpl.ico"
$o.BalloonTipIcon = "Info"
$o.BalloonTipText = "Shutting down at $launch_time"
$o.BalloonTipTitle = "Shutdown pending..."
$o.Visible = 1
function show-balloon { $o.ShowBalloonTip($minutes * 60 * 1000) }
show-balloon
$o_hover = [Windows.Forms.MouseEventHandler]{ show-balloon }
$o.add_MouseMove($o_hover)
register-objectevent $o BalloonTipClicked clicked
if (wait-event clicked -t ($minutes * 60)) {
remove-event clicked
$o.BalloonTipText = "Have a nice day!"
$o.BalloonTipTitle = "Shutdown aborted"
$o.ShowBalloonTip(10000)
if (wait-event clicked -t 10) { remove-event clicked }
} else {
# Initiate shutdown sequence on my mark. Authorization rojo alpha 3. Mark.
stop-computer
}
unregister-event clicked
$o.Dispose()
Bill_Stewart, if you're reading this, I know you're pleased. As it happens, PowerShell is indeed the correct tool for the job this time.
When using the TAB key in the dos command prompt you can cycle through the names of files and folders in the current directory... (and it even seems to work with historical commands via DOSKEY as well). Does anyone know if it's possible to extend this somehow so that pressing TAB (or any other key combination) would autocomplete from a provided list of items as well as the previously mentioned sources? I think an example is in order....
My desired behavior is to add another source to the possible items that would appear when TAB is used. At my job we make heavy use of a scheduling product called AutoSys and administer it almost exclusively through command prompt. Basically I would love to find a way to cycle through job names so the prompt would autocomplete the names when we have the first part of the job name entered already...
Common command usage:
'autorep -J JOBNAME'
Example of what I'd like to do:
'autorep -J ABC_C_EXPORT_Re' [TAB]
where the TAB key press allows me to cycle through the jobs that start with 'ABC_C_EXPORT_Re' until I find the one I want.
It seems like a possible (but very poor) ïsolution would be to have one empty file created and named for each job in the environment... But this doesn't strike me as an effective solution to the problem, especially considering that at any one time we can have between fifty thousand and a hundred thousand jobs in our environment.
I apologize for posing this strange question in an even stranger way..... I hope I was at least able to convey a sense of the central question I'm asking. Something like this would be a huge help to our operations support staff who have to find jobs by command line all day long!
Thanks for having a look!
Scott
You can make your own command processor pretty easy.
Here's something from Filter.vbs. Unlike this you'd want to read characters rather than lines (so .read(1) rather than .readline). Echo out each character, do something special on tab, when user presses enter execute the command line you built in memory, capturing it's stdout using wshshell.exec.
Here's something from help
Do While Not WScript.StdIn.AtEndOfLine
Input = Input & WScript.StdIn.Read(1)
Loop
WScript.Echo Input
Here's a menu, not everything is included.
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
Showmenu
Sub ShowHelpMenu
outp.writeline " -----------------------------------------------------------------------------"
outp.writeblanklines(1)
outp.writeline " Menu"
outp.writeline " ----"
outp.writeblanklines(1)
outp.writeline " 1 Help 2 HTML Help 3 Version 4 History"
outp.writeblanklines(1)
outp.writeline " 5 Exit"
outp.writeblanklines(1)
outp.write "Filter>"
End Sub
'=============================================
Sub ShowMenu
Do
ShowHelpMenu
Answ=Inp.readline
If Answ = "1" Then
ShowGeneralHelp "TEXT"
Elseif Answ = "2" Then
ShowGeneralHelp "HTML"
Elseif Answ = "3" Then
Version
Elseif Answ = "4" Then
History
Elseif Answ = "5" Then
Exit Do
End If
Loop
End Sub
'=============================================
Sub History
On Error Resume Next
WshShell.Run """" & FilterPath & "FilterHistory.txt""" , 1, False
err.clear
End Sub
'=============================================
Sub Version
outp.writeblanklines(1)
outp.writeline " Version"
outp.writeline " -------"
outp.writeblanklines(1)
outp.writeline " Filter Ver 0.6 - 2015 (Public Domain)"
outp.writeblanklines(1)
outp.writeline " by David Candy"
outp.writeblanklines(1)
End Sub
Consider the following makefile:
# various settings, lots of them
# (supposed to be in defaults.mk)
option1="glob_val1"
option2="glob_val2"
#option3="glob_val3" # uncomment and it will override target-specific in sub-make
option4="glob_val4"
# goal is to make many items with various options
# which share common setup, but change in details.
all: item1 item2
# Item 1 is common + changed option3
item1: export option3="i1_val3"
item1:
#echo "start item1:option3=$(option3)"
$(MAKE) generic_item
#echo "done item1"
# Item 2 is common + another option3
item2: export option3="i2_val3"
item2:
#echo "start item2: option3=$(option3)"
$(MAKE) generic_item
#echo "done item2"
# This is generic item that does everything
# basing on options settings
generic_item:
#echo "do generic option3=$(option3) [expecting i<X>_val3 here]"
What I want is to override any of options in target and
then call generic routine in 'generic_item'.
The issue is that if option3 is defined on top of the Makefile,
it is passed unchanged into sub-make. If option3 on top is commented
out, then all works as expected:
start item1:option3=i1_val3
make generic_item
make[1]: Entering directory `/tmp/make_items'
do generic option3=i1_val3 [expecting i<X>_val3 here]
make[1]: Leaving directory `/tmp/make_items'
done item1
start item2: option3=i2_val3
make generic_item
make[1]: Entering directory `/tmp/make_items'
do generic option3=i2_val3 [expecting i<X>_val3 here]
make[1]: Leaving directory `/tmp/make_items'
done item2
I don't want to use $(MAKE) option1=... option2=... generic_item
syntax since it doesn't look good and there can be a lot of options
with long values and all this will go into log and doesn't look good.
The goal is to have one common target that does stuff basing on values
of options (lots of them) and ability to extend it with additional
targets which only need to override specific values/add new actions
and leave rest to the common target.
Please suggest another approach if my looks wrong.
The main fix is adding -e to submake
I suggest a number of enhancements. The GNU Make manual is a treasure trove for this kind of advanced scripting.
Note that with the approach shown below the submake is hardly necessary. I only do submake when
I need to reload the main Makefile due to changed includes (I consider that a design smell and try to avoid it)
I want to split the work across submakes
For your convenience, I stuck with your submake approach to show you that it can be done:
export option="glob_val"
.SECONDEXPANSION: # http://www.gnu.org/s/hello/manual/make/Secondary-Expansion.html
TARGETS=item1 item2 item3 item4 item5
all: $(TARGETS)
$(TARGETS): option="$(#)_val"
$(TARGETS):
#echo "start $#:option=$(option)"
$(MAKE) -e generic_item
#echo "done $#"
generic_item:
#echo "do generic option=$(option)"
Output of make -s
start item1:option=item1_val
start item2:option=item2_val
start item3:option=item3_val
start item4:option=item4_val
start item5:option=item5_val
do generic option=item1_val
do generic option=item2_val
done item1
do generic option=item4_val
done item2
do generic option=item3_val
done item4
do generic option=item5_val
done item5
done item3