Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

@Environment Question Reloaded Please Help URGENT

Posted on 2003-11-21
18
270 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 

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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Missing Rules 1 307
Domino Lotusscript Scheduled Agent Tranfer File from AS400 to another 6 119
lotus notes, exchange 7 111
Domino Website - Redirection 12 84
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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