Solved

@Environment Question Reloaded Please Help URGENT

Posted on 2003-11-21
18
267 Views
Last Modified: 2013-12-18
I have a button carrys the code: (with other fields)

@Environment("InvoiceNumber"; @Text(InvoiceNumber));
@PostedCommand([FileCloseWindow]);
@PostedCommand([Compose]; ""; "Customer Log")

and the field has the code:

envvar := @Environment("InvoiceNumber");
@If(envvar != ""; @SetEnvironment( "InvoiceNumber"; ""); "");
envvar;

What i need is, if the button is pressed and the field already has an invoice number (which it would have) for a suffix of a, or if it has already a suffix of a then b and if it has already a suffix of b then c etc etc, but only one letter to be present at any time

Qwaletee gave me this, but it does not work:

envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );
letters := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
base := @Left(envVar;6);
priorLetter := @Right(envVar;1);
newLetter := @Replace(priorLetter; "dummy" : letters; letters : "error- ran out of alphabet!");
base + newLetter

Any ideas URGENT




0
Comment
Question by:DavidAbbott
  • 7
  • 6
  • 4
  • +1
18 Comments
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 9797087
What problem are you facing. The code seems to be correct.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9797209
Let's try to to debug this...


envvar := @Environment("InvoiceNumber");
@Prompt([OK]; "envvar"; envvar);
@SetEnvironment( "InvoiceNumber"; "");
@Prompt([ok]; "shortcut decision when no suffix yet"; @If(@Length(envVar = 6; "@Return (final result): " + envVar + "a"; "no shortcut, continuing") );
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );
letters := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
base := @Left(envVar;6);
@Prompt([ok];"base";base);
priorLetter := @Right(envVar;1);
@Prompt([ok];"priotLetter"; priorLetter);
newLetter := @Replace(priorLetter; "dummy" : letters; letters : "error- ran out of alphabet!");
@Prompt([ok];"newLetter";newLetter");
@Prompt([ok];"final result w/o shortcut"; base + newLetter);
base + newLetter

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9797301
David,

I think I already gave you a simplified soln for the problem

anyway I repeat it here (There was a minor error in previous formula that I gave) here is the corrected one

envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );
alphas := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
idx  := @If(@Ends(envvar;alphas); @member(@Right(envvar; 1); alphas); 0);
final := @leftback(envvar;1) + @if( idx > 0; @Subset(@Subset(alphas;idx+1);-1);  "");
final

~Hemanth
0
 

Author Comment

by:DavidAbbott
ID: 9797754
qwaletee

it is cutting off one of the numbers and not adding the first letter in the first instance
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 250 total points
ID: 9798267
do you ever hear me ?
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 250 total points
ID: 9804953
HemanthaKumar,
That's simplified?  OK, so it is 7 lines instead of 8.  That's only due to desnity.  M original code was meant to be readiable.  Wanna see it dense?  Only 4 lines.  Can you get it tighter without repeating @Environment or letters/alphas list?

envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
letters := @If(@Length(envVar = 6; @Return(envVar + "a"); "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");
@Left(envVar;6) + @Replace(@Right(envVar;1); "dummy" : letters; letters : "error- ran out of alphabet!");
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9804967
DavidAbbott,
> qwaletee
>
> it is cutting off one of the numbers and not adding the first letter in the first instance
Could you please give me the eaxt sequence of prompt messages?  For example, I would expect something like:

envvar: 123456
shortcut decision when no suffix yet: @Return (final result): 123456a

I know it is tedious, but I can't tell where it cuts it off unless I know all the steps it takes!

In the case of 123456a, it should result in the following prompts:
envvar: 123456a
shortcut decision: no shortcut
base: 123456
priorLetter: a
newLetter: b
final result w/o shortcut: 123456b

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9805809
your formula is hardcoded for a fixed length, mine doesn't rely on that and mostly generic code.. I am not telling your code is wrong.. If that is so then try to answer the previous thread where you proposed the soln.. I am trying to give him a new direction in this new question...
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9815779
I figured that the current format is 6-dgot plus 1 alpha.  To be really certain, you would have to use an @Matches check for either 6 digits alone, or 6 digits plus one alpha.  In either case, at that point, the break occurs after 6.  If there was any change, it cold be to 7 numbers (a problem for my code), or to a number/letter mix (a problem  for your code).
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9819594
Let us not argue on this.. Let David work it out.
0
 

Author Comment

by:DavidAbbott
ID: 9826129
Hi

Sorry, just got back, the following code bums out on my machine and says too many functions etc

envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
letters := @If(@Length(envVar = 6; @Return(envVar + "a"); "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");
@Left(envVar;6) + @Replace(@Right(envVar;1); "dummy" : letters; letters : "error- ran out of alphabet!");

so does:

envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );
alphas := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
idx  := @If(@Ends(envvar;alphas); @member(@Right(envvar; 1); alphas); 0);
final := @leftback(envvar;1) + @if( idx > 0; @Subset(@Subset(alphas;idx+1);-1);  "");
final




0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9827069
Left a paren off: letters := @If(@Length(envVar = 6     )     ; @Return(envVar + "a"); "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");


But that code is essentially identical to what I gave you last time.  You the version with the embedded prompts, s we can debug this thing, OK?!
0
 

Author Comment

by:DavidAbbott
ID: 9830640
OK this code produces the following results:

With the invoice number being 328072

envvar = 328072
base = 328072
priorletter = 2
newletter = 2
final result = 328072

>>CODE<<

envvar := @Environment("InvoiceNumber");
@Prompt([OK]; "envvar"; envvar);
@SetEnvironment( "InvoiceNumber"; "");
@Prompt([ok]; "shortcut decision when no suffix yet"; @If(@Length(envVar = 6; "@Return (final result): " + envVar + "a"; "no shortcut, continuing") );
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );
letters := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
base := @Left(envVar;6);
@Prompt([ok];"base";base);
priorLetter := @Right(envVar;1);
@Prompt([ok];"priotLetter"; priorLetter);
newLetter := @Replace(priorLetter; "dummy" : letters; letters : "error- ran out of alphabet!");
@Prompt([ok];"newLetter";newLetter");
@Prompt([ok];"final result w/o shortcut"; base + newLetter);
base + newLetter
0
 

Author Comment

by:DavidAbbott
ID: 9832747
Oh no, I am in trouble, no solution
0
 

Author Comment

by:DavidAbbott
ID: 9832873
Correction on that code produce:

envvar = 328072
base = 328072
priorletter = 2
newletter = 2
final result = 3280722

sorry
0
 

Author Comment

by:DavidAbbott
ID: 9834461
OK, worked on it and i think it is completed. From my understanding the problem bit was:

@If(@Length(envVar = 6); @Return(envVar + "a"); CONTINUE );

As it was completely ignoring the logic in the arguement and as such just continued on regardless, hence the adding of the last number if it did not have an alpha.

Most other code for some reason ignored the logic and skipped the condition after much trail and error, this following line of code replaced the above, and it worked:

@If(!@Ends(envVar;letters); @Return(envVar + "a"); CONTINUE );

Thanks for the help,


0
 

Author Comment

by:DavidAbbott
ID: 9834487
both you guys (qwaletee & HemanthaKumar) helped greatly and i obtained understanding from both sets of answers, but there can only be one main answered and one assisted acceptance, so on balance i think qwaletee came out on top this time.

Thanks to you both
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9834497
I got it!


Change:
@If(@Length(envVar = 6); @Return(envVar + "a"); CONTINUE );   ...into...
@If(@Length(envVar) = 6; @Return(envVar + "a"); CONTINUE );

Misplaced parenthesis on @Length.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now