Awkwardsaw
2009-07-11 03:50:16
i was lurking through the SCAR help file and i found this little neat function:
what this does, is open up a little pop up menu, and asks a question, specified by "question", and returns what you type into the edit box.
run this little script:
as you can see, if readln returns no(if you typed it in) then it will exit.
how this can be used, is lets say you made a version checker, you can say
or, something else can be:
i hope you get the main idea of this :)
Extra stuff
also, i got this idea from Da Ownder, to use "GetApplication.MessageBox". this is also very simple, but just incase you dont know i will try to explain.
this also makes a popup menu, but instead of an edit box, it gives buttons, based off of "typeofform". there are 7(i think) different types of forms, all with theyre different uses. for this example we will use 4, and use it in a version checker.
this opens up the menu, and will ask the question. either hit "yes" or "no".
there really isnt much else to explain, so i will let you play around with it a bit :p
i know this is a small and simple tut, but not a lot of people seem to know about this, or know how it can be utilized.
function Readln(question: string): string;what this does, is open up a little pop up menu, and asks a question, specified by "question", and returns what you type into the edit box.
run this little script:
program New;
begin
if readln('Is this cool?') = 'no' then exit;
writeln('Your cool too!');
end.as you can see, if readln returns no(if you typed it in) then it will exit.
how this can be used, is lets say you made a version checker, you can say
program New;
begin
if getversion <> version then //your own version checker stuff
begin
if readln('This script is outdated! Would you like to continue the script?') = 'no' then
terminatescript;
end;
writeln('Script up to date');
end.or, something else can be:
program New;
var s: string; c: integer;
begin
s:= readln('How many cycles do you want to do?');
repeat
inc(c);
writeln('test');
until c = strtoint(s);
end.i hope you get the main idea of this :)
Extra stuff
also, i got this idea from Da Ownder, to use "GetApplication.MessageBox". this is also very simple, but just incase you dont know i will try to explain.
GetApplication.MessageBox('Message', 'Title', typeofform)this also makes a popup menu, but instead of an edit box, it gives buttons, based off of "typeofform". there are 7(i think) different types of forms, all with theyre different uses. for this example we will use 4, and use it in a version checker.
program New;
begin
if getversion <> ver then
if GetApplication.MessageBox('This script is outdated! Would you like to continue the script?', 'Continue?', 4) = mrno then
begin
writeln('Terminating script');
wait(2000);
terminatescript;
end
writeln('Moving on');
end.this opens up the menu, and will ask the question. either hit "yes" or "no".
there really isnt much else to explain, so i will let you play around with it a bit :p
i know this is a small and simple tut, but not a lot of people seem to know about this, or know how it can be utilized.