Some help with scripting functions

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
Rigido
Posts: 4
Joined: 2006-05-01 21:29:17
Location: Rome, Italy

Some help with scripting functions

Post by Rigido »

Hi,
I'm trying to update my script (terminalvideo.it) as they changed their site. Right now I have two problems:

1. I don't know a function to check if a given variable (string) is a "good" integer or not. I saw that If I assign a wrong value to fieldDisks it is empty so I did this:

Code: Select all

SetField (fieldDisks, sDisk);
sDisk := GetField (fieldDisks);
if Length(Trim(sDisk))=0 then
 begin
  SetField (fieldDisks, '1');
end;
There is a "clean" way to do it?

2. I put a "capitalize" function on my script but I'm experiencing some problems with roman numbers (I, II, III, etc.), can someone please help me? :wink:

Thanks you all...
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

1. you can do that:

Code: Select all

if StrToInt(sDisk, -1) <> -1 then
  // you have a valid integer in sDisk
To check if a string is empty or not you can also compare it to '' (empty string), it is maybe cleaner than check the length. But it still require the use of Trim if the string may contain spaces.

2. What do you do currently for this function?
Post Reply