我是shell脚本的新手,有人可以帮忙吗?我想删除文件夹中的脚本,从当前日期回到10天.脚本如下:
2012.11.21.09_33_52.script
2012.11.21.09_33_56.script
2012.11.21.09_33_59.script
Run Code Online (Sandbox Code Playgroud)
该脚本将每隔10天与Crontab一起运行,这就是我需要当前日期的原因.
我想用 SQL 数据库中的数据填充组合框,但它不起作用。我的查询有到数据库的连接,查询SQL属性字段是select * from provider_table
Query1.SQL.Clear;
Query1.SQL.Add('select name from provider_table where region_code = '+quotedstr('eng')');
Query1.Open;
while NOT Query1.Eof do begin
ComboBox1.Items.Add(Query1['name']);
Query1.Next;
end;
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?感谢您的回答!
任何人都可以帮助我如何找到包含数字的第一个完整的Word?我有一个地址,例如:
procedure TForm1.Button4Click(Sender: TObject);
var
SourceString : String;
strArray : TArray<string>;
i : Integer;
begin
SourceString := 'Saint Steven St 6.A II.f 9';
strArray := SourceString.Split([' ']);
for i := 0 to Length(strArray)-1 do
showmessage(strArray[i]);
Run Code Online (Sandbox Code Playgroud)
结束;
结果:
Saint
Steven
St
6.A
II.f
9
Run Code Online (Sandbox Code Playgroud)
我想得到第一个包含数字的Word.在示例中:'6.A'.
任何人都知道如何?
有没有办法填写并set
从清单箱中获取项目?
我做了什么:
TColorItem = (ms_red, ms_blue, ms_green, ms_yellow);
TColorItems = set of TColorItem;
Run Code Online (Sandbox Code Playgroud)
我有一个组件,我可以选择 TColorItems
TProperty = class(TCollectionItem)
private
FModuleItem: TColorItems;
procedure SetColorItem(const Value: TColorItems);
published
property ColorTypes: TColorItems read FColorItem write SetColorItem;
procedure SetColorItem(const Value: TColorItems);
begin
FColorItem := Value;
end;
Run Code Online (Sandbox Code Playgroud)
在我设置(选中)组件中的项目后,我创建了一个表单.
我的表单看起来像这样:
如果我检查清单箱中的任何项目,我想得到Result
一TColorItems
组:
如果选中红色和绿色,则set
必须
Result := [ms_red, ms_green]
如果选中蓝色,绿色和黄色:
Result := [ms_blue, ms_green, ms_yellow]
等等..
在Result
必须在此[value1, value2] …
海兰!我想请求使用例外的建议.我想简化这个......
if (functionSomething1) and (functionSomething2) and (functionSomething3) then
Do Something Good
else
Raise Exception(errormsg_functionSomething1IsFalse or errormsg_functionSomething2IsFalse or errormsg_functionSomething3IsFalse);
Run Code Online (Sandbox Code Playgroud)
我的所有函数都返回一个布尔值.
什么是逐个获取错误消息的最佳方法?
例如......如果functionSomething1为False,那么我应该得到errormsg_functionSomething1IsFalse
如果functionSomething2为False,那么我应该得到 errormsg_functionSomething1IsFalse等...
我认为If-then-else不是一个好的解决方案.
案例或尝试除外?你怎么看?
谢谢你的回答!
如何检查组件是否具有文本属性.当我读到Rtti将是一个很好的解决方案,但我之前没有使用它.任何帮助将不胜感激.
function HasTextProp(aControl: TControl): Boolean;
begin
Result := False;
if (aComponent is ?) then
Exit(True);
end;
var
ObjList: TObjectList<TControl>;
ObjIdx: Integer;
begin
ObjList := TObjectList<TControl>.Create,
ObjList.Add(comp1); {is TcxButton}
ObjList.Add(comp2); {is Tedit}
ObjList.Add(comp3); {is TDateTimeEdit}
for ObjIdx := 0 to lObjList.Count -1 do
begin
if HasTextProp(lObjList.Items[ObjIdx]) then
do something...
end;
end;
Run Code Online (Sandbox Code Playgroud) 我想知道如何比较列表框之间的项目.在我的主表单上有两个列表框.我想通过点击事件将项目从第1个添加到第2个,但是当使用它时,相同的项目将在第2个列表框中相乘.任何想法解决"文件已存在"?
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
for i := ListBox1.Items.Count - 1 downto 0 do
if ListBox1.Selected[i] then
ListBox2.Items.Add(ListBox1.Items.Strings[i]);
end;
Run Code Online (Sandbox Code Playgroud) 我想使用2个TEdit项目和一个按钮.如何检查所有编辑是否具有某些文本值.之后我想激活一个按钮.
主要形式Onshow事件:Btn1.Enabled:= false;
如果Edit1.text + Edit2.text有值,那么btn1.enabled:= true?
谢谢您的帮助!
任何人都可以帮助比较两个stringlist并从中获得差异的最佳方法是什么?
例如,如果我有AList和BList之类的话
一个列表
BList
如果我比较他们就好
for i := 0 to BList.count-1 do
if AList.indexof(BList[i]) < 0 then
ResultList.Add(BList[i]);
Run Code Online (Sandbox Code Playgroud)
结果是:
我只需要一次元素.我怎样才能避免多件物品?有没有比制作从List中删除多个项目的过程更好的解决方案?对不起我的英文,谢谢你的帮助!
procedure TForm1.DateTimePicker2Change(Sender: TObject);
var
day:tdatetime;
begin
Datetimepicker2.date:=day;
label1.caption:=(FormatDateTime('dd.mm.yyyy', day));
Run Code Online (Sandbox Code Playgroud)
嗨!
我想在标签上显示datepicker中的选定日期,但标签只显示'30 .12.1899'日期,而不是我从datepicker中选择的日期.
有人有想法吗?谢谢你的回答!
谁能告诉我这个脚本会做什么?什么是第3行的-z?
Filename=File.txt
X=`ls /home/$Filename`
if [ -z "$X" ]; then
exit
fi
Run Code Online (Sandbox Code Playgroud)