Comparision of two fields in progress 4GL - progress-4gl

I have buffer bufCustomer for table Customer global buffer gbufOrder for table Order.
But this code is not working I wrote the code like
find bufCustomer where bufCustomer.CustomerID = gbufOrder.CustomerID no-lock no-error.
but if i check the table data,data is there but if i wrote a code like above its not working.
Is there any other way to get the values?

w/BUFFER:
DEFINE BUFFER gbufOrder FOR Order.
DEFINE BUFFER bufCustomer FOR Customer.
FIND FIRST gbufOrder NO-LOCK NO-ERROR.
IF AVAILABLE(gbufOrder) THEN
DO:
FIND bufCustomer where bufCustomer.CustNum = gbufOrder.CustNum NO-LOCK NO-ERROR.
IF AVAILABLE(bufCustomer) THEN
DO:
DISP bufCustomer.name.
END.
ELSE
DO:
MESSAGE "Customer is not available!"
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
END.
END.
ELSE
DO:
MESSAGE "Order is not available!"
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
END.
w/o BUFFER
FIND FIRST Order NO-LOCK NO-ERROR.
IF AVAILABLE(Order) THEN
DO:
FIND Customer where Customer.CustNum = Order.CustNum NO-LOCK NO-ERROR.
IF AVAILABLE(Customer) THEN
DO:
DISP Customer.name.
END.
ELSE
DO:
MESSAGE "Customer is not available!"
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
END.
END.
ELSE
DO:
MESSAGE "Order is not available!"
VIEW-AS ALERT-BOX ERROR BUTTONS OK.
END.
This program works with sports200 sample database (it is located in PROGRESS / OpenEdge install directory)
UPDATE:
checking availbility of Customer
add sample code without BUFFER

Related

Problems with append using a for loop involving lists in Python 2

I'm a beginner with python 2 and I've got two problems with 'append' command using a for loop.
I'trying to make run this piece of code, but it doesn't work properly:
def pole():
fish_pole = []
fish_elements = ['stick', 'liana', 'worm', 'bended needle']
pick_choice = raw_input()
if pick_choice == "pick up":
print "Good boy. You start picking up your 'tools'"
for element in fish_elements:
fish_pole.append(element)
fish_elements.remove(element)
print "You've found a %s and then" % element
if not element in fish_elements:
print "Ok you have the tools you need."
print "Now you can go to the river."
river()
else:
print "Come on. The sun is dying."
pole()
Ok, my problems are these:
I can't figure out why it prints the "You've found a %s and then" string only for the element 'stick' and the element 'worm';
if I write simply "if not fish_elements:" I have the first problem I've just mentioned above plus this one: as soon as the script finishes printing the two strings for 'stick' and 'worm', it goes straight for the 'else' option and it restarts the entire pole() definition from the beginning.
Please help me. Thanks guys!
Since you're iterating through all the elements of fish_elements you can consider removing fish_elements.remove(element) as it may be the main problem.
for element in fish_elements:
fish_pole.append(element)
print "You've found a %s and then" % element

MIRC, Ignoring " | " when reading a text file?

in my MIRC script, it is set up to read a text file, in these text files there is the symbol " | " followed by a space on both ends, it seems to read everything before " | " just fine, but cuts it off right at the first space. Any help is appreciated.
I am using
msg $nick $read(test.txt, n, 1)
to read the text file.
EDIT:: I have tried all switches which result in the same thing.
EDIT:: It also tells me in the server window "Unknown Command"
EDIT:: After making a new pastebin uploading script, it still seems to get that issue? It will completely just cut off the rest of the text after a "&" or " | "
The symptoms is matching to a scenario which $read was evaluated to a command and the result will take the separators as set of commands to be executed.
This can be due to aliases or events.
Try the first /play command, which will play the file from the 3rd line to see if it behaving as the line we expect it to be or instead each line as a set of commands, separated by /
Then perform the 2nd /play command to view how it should been send to the server.
This is design to see where the problem lie.
/play -axl3 echo test.txt
/play -exl3 test.txt
The output should be the same and as we expect it with the line being displayed including |.
This will make sure the problem is to blame upon other corrupt aliases or events.
We will perform the following and after each step you will test you code to see if it was solved.
Test to see if it an alias named msg hurt you, by converting your script command to /!msg $nick$read(test.txt, n, 1).
Check for dangerous events such as the infamous INPUT or the rising bandit PARSELINE by disabling them.If the problem solved then return the events one by one the find the problematic event and fix it.
Due to the lack of a responses/answers, I was unable to solve it, I have made a makeshift fix for this issue by using
play -xl# $nick test.txt
rather than
msg $nick $read(test.txt, n, 1)
I had almost the same problem and was able to solve it, using the same solution, try this:
Your previous script was: msg $nick $read(test.txt, n, 1)
Now remove the 'msg $nick' and add that to the beginning of every line in the text.txt file with a space between 'msg $nick' and the rest of the line, i.e : msg $nick Hey I see you are back | msg $nick Missed You!
Then your script becomes: $read(test.txt, p)
^^ Hope that makes sense, but I found the original issues was Double Evaluation hence why sometimes you would see the error: Unknown Command or something along those lines.

If Line Number Exists

Im trying to get a code that will do something if a certain line number is in a text file for example "Test.txt"
Ex.
if line "x" exists in test.txt msg $chan working
thanks #denny for being the one to help me out.
if ($read(test.txt, n, x)) {
msg $chan working
}
You have couple of options.
Searching to see if the number is lower or equal to the total lines. e.g: $lines(filename)
You can extract the line and use a condition if it's full. e.g: $read(filename, LINE-NUMBER)
Notes for each method:
Will only tell you if there is a line number, NOT if there is something inside this line.
Will only give you the line if exists, if the line is empty or there is no such line then it will appears like it's empty.

Applescript freezes when extracting email from mail

I'm running an applescript to extract all the email adress from all the messages in my boss's inbox and it freezes on his computer and works fine on mine.
my computer is running Snow leopard with mail 4.6 and his is running Lion with mail 5.3 if that makes any difference.
Also my inbox only has around 400 mails since i don't usually use mail and only got those messages to test the script and his has over 60 000.
The script ran through my email in around 20 seconds and on his took 2 minutes to do 40 then froze.
I was wondering if there was anything wrong with the code that could cause it to freeze in his higher version or due to the increase in email present.
On another note i know that writing them all one by one is probably counter-productive because the script i adapted this from was sorting the adresses and removing duplicates before writing them to the file but i thought that due to the large number of mails that it would speed the process and use less memory to just write them. PLus the counters helps to know where the script is at.
here is the code :
tell application "Finder" to set ptd to path to documents folder as string
set theFile to ptd & "extracted3.txt"
set theFileID to open for access theFile with write permission
set counter to 0
tell application "Mail"
set selectionMessage to selection -- just select the first message in the folder
set thisMessage to item 1 of selectionMessage
set theseMessages to (every message in (mailbox of thisMessage))
repeat with eachMessage in theseMessages
try
set counter to counter + 1
set theFrom to (extract address from sender of eachMessage)
set theFromName to (extract name from sender of eachMessage)
set theFromTemp to theFrom & "," & theFromName & "," & counter
write theFromTemp & return to theFileID as «class utf8»
if (address of to recipient) of eachMessage is not {} then
repeat with i from 1 to count of to recipient of eachMessage
set theTo to (address of to recipient i) of eachMessage as string
set theToName to (name of to recipient i) of eachMessage as string
set theToTemp to theTo & "," & theToName & "," & counter
write theToTemp & return to theFileID as «class utf8»
end repeat
end if
if (address of cc recipient) of eachMessage is not {} then
repeat with i from 1 to count of cc recipient of eachMessage
set theCC to (address of cc recipient i) of eachMessage as string
set theCCName to (name of cc recipient i) of eachMessage as string
set theCCTemp to theCC & "," & theCCName & "," & counter
write theCCTemp & return to theFileID as «class utf8»
end repeat
end if
end try
end repeat
end tell
close access theFileID
EDIT: after further thought, I removed the first script I posted. My thought is the problem you are seeing is because you are getting 60,000+ emails at once in this line...
set theseMessages to (every message in (mailbox of thisMessage))
So the idea is to just get a bunch at a time. I use the variable writeEveryXMessages to specify that you should get 500 messages at a time, and on each loop we get the next 500 until finished.
NOTE: I modified your code to be a little more efficient and fixed a few possible bugs, for example the write command is no longer in the Mail tell block of code. Also it now writes those 500 messages to file at one time. This script works on Mountain Lion and Mail v6.2. It should work for you too.
I hope this fixes your problem! Good luck.
set theFile to (path to documents folder as text) & "extracted3.txt"
set writeEveryXMessages to 500
set counter to 1
try
set theFileID to open for access file theFile with write permission
tell application "Mail"
set selectedMessage to item 1 of (get selection)
set theMailbox to mailbox of selectedMessage
set messageCount to count of messages in theMailbox
end tell
repeat
set endCount to counter + writeEveryXMessages
if endCount is greater than messageCount then set endCount to messageCount
set theString to ""
tell application "Mail"
set theseMessages to messages counter thru endCount of theMailbox
end tell
repeat with eachMessage in theseMessages
set theFromTemp to ""
set theToTemp to ""
set theCCTemp to ""
try
tell application "Mail"
tell eachMessage
set theSender to sender
set toRecipients to to recipients
set ccRecipients to cc recipients
end tell
set theFrom to extract address from theSender
set theFromName to extract name from theSender
set theFromTemp to "From: " & theFrom & "," & theFromName & "," & counter & return
if toRecipients is not {} then
repeat with toRecipient in toRecipients
try
set theTo to address of toRecipient
set theToName to name of toRecipient
set theToTemp to theToTemp & " To: " & theTo & "," & theToName & "," & counter & return
end try
end repeat
end if
if ccRecipients is not {} then
repeat with ccRecipient in ccRecipients
try
set theCC to address of ccRecipient
set theCCName to name of ccRecipient
set theCCTemp to theCCTemp & " CC: " & theCC & "," & theCCName & "," & counter & return
end try
end repeat
end if
end tell
set theString to theString & theFromTemp & theToTemp & theCCTemp & return
end try
set counter to counter + 1
end repeat
write theString to theFileID as «class utf8»
if counter is greater than or equal to messageCount then
set theString to ""
exit repeat
end if
end repeat
close access theFileID
on error theError
log theError
try
close access file theFile
end try
end try

perl readline autocomplete

I call an auto complete function in perl it returns an array and values printed but I want each command display help text too - same as cisco/juniper does.
I can't print inside any function.
$attr->{print_completions_horizontally} = "on"; and I print its result it is on, but still the result is not achieved.
desired result:
show ?
show print's different system variables.
result im getting (when i press the tab key):
s (tab)
promt>
set show
promt> set