Jump to content
Sign in to follow this  

What the hey?! Should work?

Recommended Posts

Hi all,

Once again, when I think I'm making headway with my self- teaching methods, I take one right across the forehead.

I have a number in a text field (so that it will display a hyphen) that is 8 digits long.


This "job number" can have "sub" jobs, and we ad "-1", "-2", etc.



My script starts like this:


(Length (GetAsNumber (Job Number)) = 8); (Job Number) & "-1";

That determines that the number has 8 numerals and it ads a "-1" to it. It works fine.

Then, if it doesn't see 8 numerals, it asks what the suffix is here (in this case, it sees 12345678-7, and makes the next record 12345678-8. It works fine.

[color:green]Right (Job Number;1)=7; (Left (Job Number;8)) & "-8";

Then, when it gets to the teens, it only adds the last number! I can't figure it out. It does NOT work fine. So the following would be 12345678-13, but the returned number is 12345678-4.

[color:green]Right (Job Number;2)=13; (Left (Job Number;8)) & "-14";



Share this post

Link to post
Share on other sites

It's a little unclear... Is this a Set Field script step? Is everything in green part of the same Case statement?

I'm assuming yes to both of those questions and the answer is simple...a Case statment evaluates test sequentially. So if the job number is -13, the statment evaluates the Right(Job Number;1)=3 first and it tests true and returns -4.

You can rejigger your Case function by switching the second and third tests as stated in your post and it should work, though

I'm guessing the whole statement is very kludgy.

Try this:


Nums = Length(Trim(Job Number));

NextNum = 1+ Case(Nums = 8;0; Right(Job Number; Nums-9) )


Left(Job Number;8) & "-" & NextNum


Edited by Guest
Slight change to calc

Share this post

Link to post
Share on other sites

Smack! (That's my palm hitting my forehead)

Yes, it sees the second digit of the teens again.

I am going to try your calc. It is certainly a lot cleaner than mine. One more lesson learned.



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.