将一组数字转换为String [英] Convert the numbers of a set to String
问题描述
我想将数字从 MySet =集1..8
保存到 MyString:String
。是否有像 IntToStr
这样的函数可以做到这一点?
I would like to save the numbers from MySet = set of 1..8
to MyString : String
. Is there a function like IntToStr
which can do this?
我有一个调度程序,它在其中接收一个字符串(* * * * * * * *)
的形式。星号之一代表执行的天数,而 MySet
是执行天数的列表。例如1是星期一,2是星期二。我必须将数字从集合保存到该字符串,所以它看起来像这样:(0 0 15 * * * 1,2,3 *)
。这意味着,调度程序将在每个星期一,星期二,星期三的15:00触发。
I have a scheduler, which takes in a string in the form of (* * * * * * * *)
. One of the stars represents the days of execution, and MySet
is the list of days. For example 1 is monday, 2 is tuesday. I have to save the numbers from the set to that string, so it would look something like this: (0 0 15 * * * 1,2,3 *)
. This means, that the scheduler will trigger every Monday, Tuesday, Wednesday at 15:00.
如果您想了解更多有关此格式的信息: http://www.nncron.ru/help/ZH/working/ cron-format.htm
推荐答案
使用 for..in 迭代器以生成所需的字符串:
Use the for..in iterator to produce the wanted string:
Type
MySet = set of 1..8;
function MySetToString(const s: MySet): String;
var
i: Integer;
begin
Result := '';
for i in s do begin
Result := Result + IntToStr(i) + ',';
end;
SetLength(Result,Length(Result)-1);
end;
这篇关于将一组数字转换为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!