[SOLVED] Simple .bashrc function problem
Hi, I'm trying to set up a function in my .bashrc to automatically direct stdout and sterr to /dev/null as well as background the process. The only problem I'm having is trying to set it up so I can use it with a program and its arguments, like "gedit file.txt". So far I've tried
q() {
"$@" &> /dev/null &
q() {
"$*" &> /dev/null &
q() {
"$1 $2" &> /dev/null &
and without quotes. Every time it returns exit status of 127, "command not found" probably because it tries to run file.txt, it does show a blank gedit window.
I want to be able to type "q gedit file.txt" instead of having to type "gedit file.txt &> /dev/null &" every time. Thanks for the help.
Last edited by Halcyon22 (2010-11-10 10:25:43)
q() {
"$@" &>/dev/null &
works for me. (q gedit foo.txt)
man bash wrote:"$@" is equivalent to "$1" "$2" ...
Edit:
BTW, in your last post, ${arg[@]:1:2} will not work if "$2" contains spaces. You should put double quotes around it. Or, you could have just written:
q() { "${@:1:2}" &>/dev/null & }
which is equiv. to
q() { "$1" "$2" &>/dev/null & }
which, of course, is less "portable" than "$@"
Last edited by lolilolicon (2010-11-10 10:45:02)
Similar Messages
-
[solved] Need ! function of bashrc
Hi. Can anyone search ! function in your ~/.bashrc or bash.bashrc ?
I'm using CentOS now and remembered of ! command that was realy usefull. It does the last command executed, but preceded with a sudo. I think it may be a bashrc function and as did not remember seeing it in the .bashrc, I think it may be in /etc/bash.bashrc. Can anyone look and paste that function? It would be a huge help, because I tried searching in google and in here, but I've got too many pages/posts with my searches.
Thanks in advance.
Last edited by NotFromBrooklyn (2012-07-15 10:00:41)Huh?
Will be replaced by your last command. So you can type
sudo !!
Is that what you're talking about? -
Hi,
I am testing the simple mail functionality in transaction VA01.
In customizing (output determination processing routines) for simple mail is being used a program and a smartform. It was not me who developed them.
The problem is that when I try to test this through VA01 (I choose simple mail, etc), I get a dump saying: Invalid commit work in an update function module. Termination occurred in the ABAP program SAPLSOI1 in SO_DOCUMENT_SEND_API1. The main program was RSM13000.
My problem now is how can I try to debug this when I am in transaction VA02? I am not able to execute the program I have in customizing
How can I found more information about this?
Thanks a lotWeird..
I am working with SAP ECC 6.0 - release 700
In version history no one has modified the program...
function so_document_send_api1.
""Lokale Schnittstelle:
*" IMPORTING
*" VALUE(DOCUMENT_DATA) LIKE SODOCCHGI1 STRUCTURE SODOCCHGI1
*" VALUE(PUT_IN_OUTBOX) LIKE SONV-FLAG DEFAULT SPACE
*" VALUE(SENDER_ADDRESS) LIKE SOEXTRECI1-RECEIVER DEFAULT SY-UNAME
*" VALUE(SENDER_ADDRESS_TYPE) LIKE SOEXTRECI1-ADR_TYP DEFAULT 'B'
*" VALUE(COMMIT_WORK) LIKE SONV-FLAG DEFAULT SPACE
*" EXPORTING
*" VALUE(SENT_TO_ALL) LIKE SONV-FLAG
*" VALUE(NEW_OBJECT_ID) LIKE SOFOLENTI1-OBJECT_ID
*" VALUE(SENDER_ID) LIKE SOUDK STRUCTURE SOUDK
*" TABLES
*" PACKING_LIST STRUCTURE SOPCKLSTI1
*" OBJECT_HEADER STRUCTURE SOLISTI1 OPTIONAL
*" CONTENTS_BIN STRUCTURE SOLISTI1 OPTIONAL
*" CONTENTS_TXT STRUCTURE SOLISTI1 OPTIONAL
*" CONTENTS_HEX STRUCTURE SOLIX OPTIONAL
*" OBJECT_PARA STRUCTURE SOPARAI1 OPTIONAL
*" OBJECT_PARB STRUCTURE SOPARBI1 OPTIONAL
*" RECEIVERS STRUCTURE SOMLRECI1
*" EXCEPTIONS
*" TOO_MANY_RECEIVERS
*" DOCUMENT_NOT_SENT
*" DOCUMENT_TYPE_NOT_EXIST
*" OPERATION_NO_AUTHORIZATION
*" PARAMETER_ERROR
*" X_ERROR
*" ENQUEUE_ERROR
data begin of object_hd_change.
include structure sood1.
data end of object_hd_change.
data begin of attach_hd_change.
include structure sood1.
data end of attach_hd_change.
data begin of object_data.
include structure soodd.
data end of object_data.
data begin of objhead occurs 1.
include structure soli.
data end of objhead.
data begin of objcont occurs 100.
include structure soli.
data end of objcont.
data begin of atthead_tab occurs 1.
include structure soli.
data end of atthead_tab.
data begin of attcont_tab occurs 10.
include structure soli.
data end of attcont_tab.
data begin of atthead occurs 1.
include structure soli.
data end of atthead.
data begin of attcont occurs 10.
include structure soli.
data end of attcont.
data begin of new_pack_list occurs 10.
include structure soxpl.
data end of new_pack_list.
data begin of rec_table occurs 10.
include structure soos1.
data end of rec_table.
data begin of object_fl_change.
include structure sofm1.
data end of object_fl_change.
data rcode like sonv-rcode.
data object_type like sood-objtp.
data object_id_new like soodk.
data file_format(3).
data: originator like soos1-recextnam,
originator_type like soos1-recesc.
data: hex_size like sy-tabix.
data: old_object like swotobjid,
* sh070900 5.0A reconvert R30 into OBJ Docs is possible.
sood_id like soodk.
data: old_folder_id like soodk,
old_object_id like soodk,
old_forwarder like soud-usrnam,
old_object_data like sood2.
data hex_mode type sonv-flag value space.
data dummy_hex type solix_tab.
**data i.
**if sy-uname = ''
while i ne 1.
endwhile.
**endif.
describe table contents_bin lines hex_size.
if hex_size gt 0.
call function 'SO_CONVERT_CONTENTS_BIN'
exporting
it_contents_bin = contents_bin[]
importing
et_contents_bin = contents_bin[].
data l_new_size type i.
data l_line_size type i.
data l_new_doc_size type i.
describe table contents_bin lines l_new_size.
if l_new_size <> hex_size.
describe field contents_bin-line length l_line_size in character mode.
loop at packing_list where transf_bin = on.
packing_list-body_start = packing_list-body_start * 2 - 1.
packing_list-body_num = packing_list-body_num * 2.
l_new_doc_size = packing_list-body_num * l_line_size / 2.
if packing_list-doc_size <= l_new_doc_size.
packing_list-doc_size = l_new_doc_size * 2.
endif.
modify packing_list.
endloop.
endif.
endif.
describe table contents_hex lines hex_size.
if hex_size gt 0.
refresh contents_bin.
MOVE CONTENTS_HEX[] TO CONTENTS_BIN[].
hex_to_cont contents_hex contents_bin.
endif.
* transfer document data
perform transfer_objdat_to_obj using document_data
object_hd_change
object_fl_change.
perform set_default_object_data using object_hd_change.
* read object out of table
* take API1, so no receiver conversion is necessary here
read table packing_list index 1. "first object is document
if sy-subrc ne ok. "no packing list
raise parameter_error.
endif.
perform read_object_out_of_tables tables object_header
contents_txt
contents_bin
objhead
objcont
using packing_list
object_data
rcode.
* parameters for tracing
LOOP AT OBJHEAD.
PERFORM TRACE(RSSOEXTR) USING 'OBJHEAD' OBJHEAD-LINE.
ENDLOOP.
if rcode ne ok. "no object found
raise parameter_error.
endif.
* out of object data use only extern content flag and perhaps the size
move object_data-extct to object_hd_change-extct.
if object_hd_change-objlen = 0 or
object_hd_change-objlen is initial.
move object_data-objlen to object_hd_change-objlen.
endif.
perform format_prepare_for_insert in program sapfssoa "873845
using packing_list-transf_bin
dummy_hex
changing objhead[]
objcont[]
packing_list-doc_type
object_hd_change-file_ext
rcode.
move packing_list-doc_type to object_type.
* for old types move size to header
perform size_to_header tables objhead
using object_type
document_data-doc_size.
get now all attachments, decreibed in packing list
refresh new_pack_list.
refresh atthead_tab.
refresh attcont_tab.
loop at packing_list from 2.
clear new_pack_list.
perform read_object_out_of_tables tables object_header
contents_txt
contents_bin
atthead
attcont
using packing_list
object_data
rcode.
check rcode = ok.
* sh240899 46C check for executable mail attachment (MAPI)
if packing_list-doc_type = 'R3O'.
read table attcont index 21 into old_object.
if old_object-objtype = 'SOFM'.
read table attcont index 22.
if attcont = 'PROCESS'.
* it's an attachment created by MAPI because of an executable
* mail
* read old mail and fill new one with process parameters
move: old_object-objkey(17) to old_folder_id,
old_object-objkey+17(17) to old_object_id,
old_object-objkey+34(12) to old_forwarder.
call function 'SO_OBJECT_READ'
exporting
folder_id = old_folder_id
forwarder = old_forwarder
object_id = old_object_id
importing
object_hd_display = old_object_data
tables
objpara = object_para
objparb = object_parb
exceptions
folder_not_exist = 4
folder_no_authorization = 5
object_not_exist = 6
object_no_authorization = 7
operation_no_authorization = 8
owner_not_exist = 9
parameter_error = 10
others = 15.
if sy-subrc = 0.
move: old_object_data-vmtyp to object_hd_change-vmtyp,
old_object_data-skips to object_hd_change-skips,
old_object_data-acnam to object_hd_change-acnam,
old_object_data-acmem to object_hd_change-acmem.
endif.
continue.
elseif attcont = 'DISPLAYATTACHMENT'.
* sh070900 5.0A reconvert R30 into OBJ Docs is possible.
* get object instance and method into attachment body
refresh: attcont, atthead.
move old_object-objkey+17(17) to sood_id.
perform socx_select(sapfsso0) tables atthead
attcont
object_para
object_parb
using sood_id
hex_mode
rcode.
move atthead[] to attcont[].
* fill new packing list parameter
describe table atthead lines packing_list-head_num.
describe table attcont lines packing_list-body_num.
packing_list-doc_size = '255'.
packing_list-doc_type = obj.
endif.
endif.
endif.
move-corresponding packing_list to new_pack_list.
move: packing_list-obj_descr to new_pack_list-objdes,
packing_list-obj_name to new_pack_list-objnam,
packing_list-doc_size to new_pack_list-objlen,
packing_list-obj_langu to new_pack_list-objla,
packing_list-mess_type to new_pack_list-extct,
packing_list-doc_type to new_pack_list-objtp,
packing_list-transf_bin to new_pack_list-transf_bin."873845
describe table atthead_tab lines new_pack_list-head_start.
add 1 to new_pack_list-head_start.
describe table attcont_tab lines new_pack_list-body_start.
add 1 to new_pack_list-body_start.
perform format_prepare_for_insert in program sapfssoa "873845
using packing_list-transf_bin
dummy_hex
changing atthead[]
attcont[]
new_pack_list-objtp
new_pack_list-file_ext
rcode.
get new sizes (also for attcont, someone forgot this...)
describe table atthead lines new_pack_list-head_num.
describe table attcont lines new_pack_list-body_num.
loop at atthead.
clear atthead_tab.
move atthead to atthead_tab.
append atthead_tab.
endloop.
loop at attcont.
clear attcont_tab.
move attcont to attcont_tab.
append attcont_tab.
endloop.
append new_pack_list.
endloop.
* transfer receiver data
perform transfer_rec_to_tab tables receivers
rec_table.
* sender in right format
move sender_address to originator.
perform convert_sndart_esc using sender_address_type
originator_type.
call function 'SO_OBJECT_SEND'
exporting
EXTERN_ADDRESS = ' '
FOLDER_ID = ' '
FORWARDER = ' '
object_fl_change = object_fl_change
object_hd_change = object_hd_change
OBJECT_ID = ' '
object_type = object_type
outbox_flag = put_in_outbox
originator = originator
originator_type = originator_type
OWNER = ' '
STORE_FLAG = ' '
importing
object_id_new = object_id_new
sent_to_all = sent_to_all
originator_id = sender_id
tables
objcont = objcont
objhead = objhead
objpara = object_para
objparb = object_parb
packing_list = new_pack_list
att_head = atthead_tab
att_cont = attcont_tab
receivers = rec_table
exceptions
object_not_sent = 15
object_type_not_exist = 17
operation_no_authorization = 21
parameter_error = 23
too_much_receivers = 73
others = 1000.
case sy-subrc.
when ok.
move object_id_new to new_object_id.
when object_not_sent.
perform transfer_tab_to_rec tables rec_table
receivers.
raise document_not_sent.
when too_much_receivers.
raise too_many_receivers.
when object_type_not_exist.
raise document_type_not_exist.
when operation_no_authorization.
raise operation_no_authorization.
when parameter_error.
raise parameter_error.
when others.
raise x_error.
endcase.
MOVE OBJECT_ID TO NEW_OBJECT_ID.
perform transfer_tab_to_rec tables rec_table
receivers.
set commit work
if commit_work = on.
commit work.
endif.
endfunction. -
Boost Function problem in Studio 12.2
Hi,
I'm having a problem compiling a simple boost::function declaration which worked fine with 12.1 (and gcc). Here's the test code:
#include <boost/function.hpp>
#include <string>
int main(int argc, char* argv[])
boost::function<void(std::string)> foo;
Which produces the error:
"boostfn.cc", line 7: Error: In this declaration "foo" is of an incomplete type "boost::function<void>".
1 Error(s) detected.
Compiler version:
CC: Sun C++ 5.11 SunOS_i386 2010/08/13
Boost version: 1.38.0.
Command line:
CC -g0 -DSOLARIS -features=tmplife -features=tmplrefstatic -erroff=wbadinitl,wbadasgl -library=stlport4 -I<path to boost> boostfn.cc
Any ideas why this doesn't work?
Thanks,
GrahamThanks Steve, I see. So is there a list of such known issues? I didn't notice anything related to it in the Known Problems section of the docs (http://docs.sun.com/app/docs/doc/821-2414/gkezt?a=view). It's a shame, because this put us in a position where we need to upgrade to 12.2 due to a bug in 12.1, but this regression means we can't use 12.2.
Cheers,
Graham -
Has anyone had a problem with TapMedia File Manage installed on iPhone 5? I reported a WIFI functionality problem to the developer and asked for support. Instead the company has been very unprofessional by name calling me instead of logically evaluate and troubleshoot the problem
Hi AKE1919,
Welcome to the Support Communities!
The following information should help you with this:
How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
http://support.apple.com/kb/HT1933?viewlocale=en_US
Cheers,
Judy -
SIMPLE Database Design Problem !
Mapping is a big problem for many complex applications.
So what happens if we put all the tables into one table called ENTITY?
I have more than 300 attributeTypes.And there will be lots of null values in the records of that single table as every entityType uses the same table.
Other than wasting space if I put a clustered index on my entityType coloumn in that table.What kind of performance penalties to I get?
Definition of the table
ENTITY
EntityID > uniqueidentifier
EntityType > Tells the entityTypeName
Name >
LastName >
CompanyName > 300 attributeTypes
OppurtunityPeriod >
PS:There is also another table called RELATION that points the relations between entities.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
check the coloumn with WHERE _entityType='PERSON'
as there is is clustered index on entityType...there
is NO performance decrease.
there is also a clustered index on RELATION table on
relationType
when we say WHERE _entityType ='PERSON' or
WHERE relationType='CONTACTMECHANISM'.
it scans the clustered index first.it acts like a
table as it is physically ordered.I was thinking in terms of using several conditions in the same select, such as
WHERE _entityType ='PERSON'
AND LastName LIKE 'A%' In your case you have to use at least two indices, and since your clustered index comes first ...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Have you ever thought of using constraints in your
modell? How would you realize those?
...in fact we did.We have arranged the generic object
model in an object database.The knowledge information
is held in the object database.So your relational database is used only as a "simple" storage, everything has go through your object database.
But the data schema is held in the RDBMS with code
generation that creates a schema to hold data.If you think that this approach makes sense, why not.
But in able to have a efficent mapping and a good
performance we have thought about building only one
table.The problem is we know we are losing some space
but the thing is harddisk is much cheaper than RAM
and CPU.So our trade off concerated on the storage
cost.But I still wonder if there is a point that I
have missed in terms performance?Just test your approach by using sufficiently data - only you know how many records you have to store in your modell.
PS: it is not wise effective using generic object
models also in object databases as CPU cost is a lot
when u are holding the data.I don't know if I'd have taken your approach - using two database systems to hold data and business logic.
PS2: RDBMS is a value based system where object
databases are identity based.we are trying to be in
the gray area of both worlds.Like I wrote: if your approach works and scales to the required size, why not? I would assume that you did a load test with your approach.
What I would question though is that your discussing a "SIMPLE Database Design" problem. I don't see anything simple in your approach when it comes to implementation.
C. -
Hi All,
I am new BPS planning functions, I am trying to write a simple exit function to manipulate amount.
Example: For value type as Plan i.e. '020' , I want to added constant to existing values say '100'.
like price = price + 100 (for all value types as '020').
I know this can be done by formula function as well , I know that i need to build a function inorder to create a exit function. I need help in building the ABAP code.
Any help greatly appreicated.
Regards,
Reddy.Hi Vachan,
Thanks for the reply, you mentioned that XXX-value type.
What XXX stand for? As i am new to SAP please can you be of more specific.
Regards,
Reddy. -
Any way of finding out how Apple will solve the Aperture / ACR problem?
Has anyone out there gotten any comments from Apple support or other people "in the know" about how Apple is going to solve the Aperture / ACR problem, and any potential time frame?
Of course, Apple is going to work on problems with its own RAW conversion; that goes without saying. But does anyone have any knowledge of whether Apple is going to open up the ability for Apple to send RAW, unconverted images to Photoshop, so that ACR can handle them?
I think knowing this now is pretty crucial. I am willing to live with the pain Aperture is going to impose on my workflow, in exchange for the file organization benefits it provides, IF I know that I'll be able to use Aperture with ACR soon (near term). But if Apple is going to just tinker with the RAW converter, and not attempt to send RAW files to ACR, then as someone else posted in another topic, this could be a long wait, and other companies have taken years to hone their RAW converters.
This is kind of my last-ditch effort to keep Aperture around, and build my workflow around it. If I know that within a month or two at the most, I'll be able to be using ACR directly when editing new versions, then I'll absorb the pain until then. But if I am looking at waiting six months for it (several man years), or riding out the process of Apple trying to get their own converter fixed, then as much as I don't want to, Aperture is going to get returned or hit eBay.
Does anyone have any idea on this? I've held up my projects for the past week trying to reorganize my workflow to work with Aperture, and I've got to pound the gavel, make a decision, and pursue a direction. Knowing what direction Apple is going to take with this makes all the difference in the world in what I do.
Thanks in advance for any info you can pass on.
Brad
Powerbook G4-1.33GHz-17" / Powermac G4-1.4GHz Mac OS X (10.4.2) PB: 1GB RAM, Radeon 9600-64MB / PM: 1.25GB RAM, Radeon 9000Pro-128MBThis "Open External Editor from Master NEF", versus open from a dynamicaly created version is, I have decided, crucial.
I am getting less clumsy with the interface, but I simply can not get all white balance, and noise reduction done on my best available light shots.
ACR in CS2, and a subsequent "Neat Image" scrubbing is excellent for this.
The automatic association within a stack, of the resulting flattened file would be a big difference. I agree a formal statement from Apple would make me more inclined to really commit to Aperture for all my work.
Going one step further, it would be nice to keep the layers on the round-trip Master file, even if you would work with a dynamicaly created version of the returned "master" within a stack. It would occupy more disk space, but would do so only for those images where the user has made a quality decision.
Michael
Powermac G5 dual 2GHZ, 2.5GB - 2x20in Mac OS X (10.3.4) -
HT1212 How to solve the forgotten passcode problem
If I never connect my iPhone5 to iTunes, didnt turn on the iCloud, and did not backup my phone before, how can i solve the forgotten passcode problem without erasing the data?
Read the article that brought you here
http://support.apple.com/kb/ht1212
There is nothing you can do other than that and you will lose your data if you have never backed up -
Solving u0091Out of Memoryu0092 problem u0096 Using JNLP
Hi all,
I am just following the below mentioned blog /people/keerti.nayak/blog/2007/03/05/solving-145out-of-memory146-problem-150-using-jnlp
I got stuck @ step 2.
can anyone tell me... whats the exact path of the launcher file.
Regards
BiplabHi,
If you place the Mouse on the Integration Repository,
You will be able to see the path on the bottom left side of the screen, which is marked as Red in the Blog
In my case the path is----http://sxddev:50000/rep/start/repository.jnlp
Regards
Seshagiri -
Does upgrading from Premiere Elements 12 to 13 solve the Organizer thumbnail problem?
Thumbnails do not show up after importing clips into Premiere Elements 12 Organizer. I've tried right clicking on a clip and telling it to recreate the thumbnail but it doesn't work. I've tried refreshing and repairing the catalog. I've even started a new catalog and reimported the files. The system says it's creating thumbnails but they still do not show up. Does upgrading from Premiere Elements 12 to 13 solve the Organizer thumbnail problem?
listiak
That is one of those questions best answered by evaluating Elements Organizer13 with your specific files in your specific computer environment.
Each of the Elements Organizer versions often appears to carry along its own baggage.
One of the things that came up about Elements Organizer 13 thumbnails recently was a problem with files with MPEG2
video compression. The Adobe word on this was that this is only an Elements Organizer 13 tryout issue...supposed not to exist
in the purchased version.
ATR -
Common SAP MM Functional problems
Fellows
Is there anyone who can explain some common SAP MM daily functional problems. im junior consultant and want to be prepared for interviews. you may just state them in point form briefly.
thanks
rashCommon Issue
1)Vendor is not created for Purchasing Organisation XXXX.
2)Though Vendor Master is Flag for Deletion ,Vendor is shows at the time of PO Creation.
3)How to extend the materials for another storage location
4)How to Create the PO for Different Currencies.
5)While Posting The Doc . Error Occure,1) Account Determination for Entry 1000 BSV _ _ not Posssible.2) Account Determination for Entry 1000 FRL _ _ not Posssible.
6)Not Authorisation for Movt Type ......,Transaction Code......
7) Account Determenation for transaction .... Cost center ...does not maintain.
8)While Creation of GR -Authorisation missing for Company Code 0000 Asset Class XXXX,
9)While Removing The Stock of material by Cancelling the Goods Receipt Doc.Error occur that Stock Qty difficial by xx No.
10)While GR Cancellation error occure that document does not contain any selected item.
11)While Creating Service Entry Sheet Error occured that Qty entered exceeded by Qty in PO
12)While cancelling the matl.Doc Error occure that matl is deficit of sales ordr stock.
13) Error-Tax code does not Exist while creating Miro
14)TDS Amount is not Captured at Miro entry.
15)While Miro error occure that No suitable item found for Purchase Order.
16)User ID gets Blocked due to wrong Password entered more than 3 times.
18)Error-Gl account does not created for Chart of account XXXX while Miro
19)In Purchase Order Service tax is 12.24 % and at Bill service tax is 10.5 .How to adjust it and How to cancell Wrong Miro
20)Stock Statement not matched Value still lying into Stock A/c
Rewards if Helpful...
Regards
Sanjay L -
[Haskell]How to read in haskell and solve simple problems
Hello,
I'm an experienced C/C++ programmer and I would like to use Haskell to solve some problems.
But it is hard to me to write a simple way to read input from a file and analyze it, so I ask you how to do this. I didn't find how to do this around google or this forum, that's why I came to here.
Suppose we are given this problem:
"We're analyzing numbers and we want to know which numbers are even. The input consists on a number, N, and then N lines which contain a single integer. You are to say what numbers are even."
INPUT EXAMPLE:
3
1234
5555555
123044390581349287182
OUTPUT EXAMPLE:
yes
no
yes
I wrote the module that returns a string depending on if the number is even or not... But I would like to know how to repeat that function for N numbers. I don't want a superoptimized way or a strange way, I just want a simple and readable one...
In C++ i would do:
for (int i = 0; i < cases; i++)
cin >> number;
cout << analyze(number) << endl; // analyze returns a string
Can you iluminate with your knowledge, archers?
Thank you.Well, you said that the first line has the number N, followed by N lines. Given your description the program would always test the whole file.
If you have a file with X lines and you'd only like to test N <= X lines, this should do it:
module Main where
import System.IO
import Control.Applicative
main = do
let test x = if even (read x) then "yes" else "no"
withFile "test" ReadMode $ \handle -> do
nlines <- read <$> hGetLine handle
content <- hGetContents handle
mapM_ ( putStrLn . test )
. take nlines
. lines
$ content -
Does labVIEW have a function to solve the following math problem?
In Labview what is the easiest way to solve the following problem?
|---- ---| -1 |-- ---| |-- --|
| 1 1 0 | | a | | x |
| 1 0 1 | | b | = | y |
| 0 1 1 | | c | | z |
|__ __| |_ _| |_ _|
from the equations:
a = x + y
b = x + z
c = y + z where a, b, c are know values. The problem I actually have is a system of 9 equations.
Thank you.You have a known matrix, a known vector, and a vector you need to solve for given the equation Ax = b. This is exactly the problem this VI is designed to solve:
With the values I made up for a, b, and c, the solution is [2, 3, 4].
Chris M -
How to solve this case sensitive problem for the parameters in function?
Hi,
I have a function, which should receive one parameter comes from textbox in BSP form. User will input upper case or lower case characters together in this textbox. But when I debug function, I found after function recevice the value from BSP form, the string value was converted into upper case automatically.
I don't want system convert string to upper or lower case. I want keep the original value that user inputted.
So is it possible to do this?
Thanks!Hi,
Thanks for your reply.
Yes, I use the inputfield. The problem is if I use the parameter which contain user's input in the event handler of BSP, the value is equal to the user's input. But if the parameter was transfered into function, the value was converted to uppercase.
But I want to keep the original value.
Thanks!
Maybe you are looking for
-
How to print a group of pictures?
I have 4 photos I need to print. I've set the image canvas at 288 pixels per inch and arranged the picture within a page that is 1746 x1048 pixels in horizontal view. However whenever I try to print they only fill about 1/4th of the page. How do I in
-
Dev Environment: Flash Builder 4.7<br/> SDK: Flex 4.6.0 (build 23201) AIR 3.5<br/> Arguments: -local en_US -swf-version=16<br/> Testing Platform: iOS 6 on iPad 2 Severe bug, I believe. Renders iOS apps developed using these technologies utterly unus
-
How to auto-generate a "empno" field at run time in oracle forms 6i
Hello! I have connected to a SCOTT schema. And i am using emp table. At run time mode when i press F8 then the data is displayed in the fields. My task is to generate auto "empno" as soon as i run the form. Kindly do the needful. Thanks in advance
-
Layer 0 exceeds max when formatting?
Please help. I don't know DVD studio pro so well, but I am trying to burn a DVD with a lot of menus and I get this message popping up: "Formatting was not successful. Layer 0 exceeds the maximum layer size allowed. Please choose a suitable marker loc
-
Cloning of production Database to Development
We are planning to clone the development box same as the production box. After the cloning, do we have to change any setting or values or take care of any data dependencies? We are using Oracle Warehouse Builder (OWB). Cedric Edited by: user10950010