[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

about while loop and case

How can I change the case statement in the while loop looping?
can you show me the source code for this question?
0
lewis_loo
Asked:
lewis_loo
1 Solution
 
kretzschmarCommented:
hi lewis_loo

Why this

that are two different things

meikl
0
 
omsecCommented:
think you mean :

while Something <> True then
  begin
    case ThisVar of
      ...
  end
else // "Something" is now True
  begin
    case ThatVar of
      ...
  end;

not sure if you mean that
0
 
kretzschmarCommented:
hi omsec

something is wrong in your example. Where come the else. In while ..do there can no else in the case there can be a else but then something <> true.

meikl
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
InteqamCommented:
To lewis_loo:

Can you explain more?


0
 
omsecCommented:
i see, i didnt check the Syntax. I also never used While and Else
together, i thought WHILE "something" is true do the case block,
Else (after) do the other, the else-bleck

while Something <> True then
  begin
    case ThisVar of
      ...
    end; { of case}
  end
else // "Something" is now True
  begin
    case ThatVar of
      ...
    end; {of case}
  end;

.but never done it this way

0
 
saamCommented:
strange question... more info please
0
 
FuzzyLogicCommented:
If you mean that the case switches are changed every time (for example according to some input string), while the while loop continue, this is not possible. You should use a bunch of "if" statements.
Anyway, too long thread for a two points question...
0
 
vikiingCommented:
The question is not clear enough, Lewis. Give an example of what you need, or specify a bit more.
0
 
daittCommented:
I guess you want to change a case statement's constants (and maybe the switch) within a while statement. There's only one way to do this (as far as I know), and it's not easy at all. You have to have Assmbler knowledges, compiler knowledges to do this.
Just decode your program (using Debug or Sourcer is up to you), then look at the code generated by the compiler. You'll see the positions of the constant, the code to compare the switch to the constants and ranges... everything there. Write down the offset of these things. Then you can return to your Pascal program, append the modifying code after the case statement (to write the value needed into memory at constants's position).
These things above is just for understanding Pascal compiler and enhance you knowlegde of Machine Language. If you have no experience in these, don't touch your exe file. A good way is to use IF statement instead of CASE statement. IF statement can be change anytime you want.
Anyway, it's too much for your two points.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now