关于排序的一点点请教

aupha 2008-07-13 10:40:43

不知道在这里发这个问题合不合适,如果有问题,请版主移版(手下留情,让他多呆2天哈)
在一个页面处理中,条件不同,会报不同的警告信息,警告信息只能报一个,所以要有一定的优先顺序,比如如果满足条件4,那么警告信息就报条件4的信息。如果条件4不满足,条件2满足,就报条件2的信息。条件1~12都不满足的话(条件6,7不报错),就报其他的条件的信息。现在的报错顺序是10>11>12>4>5>8>9 ,从排序上如何实现呢?想了半天了,没想出来。

过程1
if 其他条件 then
add 1 to idx
move errNumN to w_Msg_cd
end
if 条件1 then
add 1 to idx
move errNum1 to w_Msg_cd
end if

if 条件2 then
add 1 to idx
move errNum2 to w_Msg_cd
end if

if 条件3 then
add 1 to idx
move errNum3 to w_Msg_cd
end if

if 条件4 then
add 1 to idx
move errNum4 to w_Msg_cd
end if

if 条件5 then
add 1 to idx
move errNum5 to w_Msg_cd
end if
...
if 条件8 then
add 1 to idx
move errNum8 to w_Msg_cd
end if
...
if 条件12 then
add 1 to idx
move errNum12 to w_Msg_cd
end if
过程1

然后进行循环idx ,如果outmsg(输出的警告信息)里面没有值,msg赋给outmsg.
for idx = 1 to 20 , 1 ++
读取数据库:
select msg from msg_tbl where msg_cd = w_Msg_cd
if 条件6 and outmsg = space then
move msg to outmsg
end if
end for


===============================
ps:写的有点乱,大家先54我的语法错误哈。大体意思就是这样的。
...全文
109 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
aupha 2008-07-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 JeffChung 的回复:]
看看能不能改成select case,会清晰很多
[/Quote]
不行。现在程序里是这样的处理顺序。
并且,条件数大于30,每个条件都有不同的处理。

现在要做的是,在尽量不动原来程序逻辑的基础上,添加部分代码来实现这个功能。

我想在条件1-12的判断处理中,加一个flag来进行判断,然后在循环处理中
for idx = 1 to 20 , 1 ++
读取数据库:
select msg from msg_tbl where msg_cd = w_Msg_cd
if 条件6 then
if and outmsg = space and flag = 1
move msg to outmsg
else if flag ≠ 1
move msg to outmsg1 'outmsg1是临时变量
end if
end if
end for

if outmsg = space and outmsg1 ≠ space then
move outmsg1 to outmsg
end if

现在的问题是如何在条件中再排序下。
changjiangzhibin 2008-07-13
  • 打赏
  • 举报
回复
自己定义好触发条件,确保只触发其中之一

if
else if
else if
...
JeffChung 2008-07-13
  • 打赏
  • 举报
回复
看看能不能改成select case,会清晰很多
aupha 2008-07-13
  • 打赏
  • 举报
回复
题目不是很清楚。
其中条件这里
if 条件2 then
add 1 to idx
move errNum2 to w_Msg_cd(idx)
end if
写到了一个集团变量里面的。

110,825

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧