Hi.
Can anybody point me to documents and samples that would allow me to drag a value from a grid and drop it to another grid with predefined values identify its source rows and cols so I can save the source location. I'm trying to find out if I can convert my EDI mapping tool from C# to pure J. I already made a preliminary form and you can use the sample EDI document from http://www.amosoft.com/edi_docs/EDI_850_X12_Sample.html Note: if you use the sample above, you have to specify '~' as a segment separator/delimiter in the application window. Just copy and paste to a J edit window and run the sample. The main verb is mainForm_run '' Any info is appreciated. Thanks. r/Alex NB. ========================================== require 'grid regex' MAINFORM=: 0 : 0 pc mainForm; xywh 8 8 46 11;cc lbl1 static;cn "Source EDI:"; xywh 50 7 201 12;cc sourceEDI edit; xywh 254 7 16 12;cc selectSource button;cn "..."; xywh 26 22 60 11;cc lbl2 static;cn "Segment Delimiter:"; xywh 88 22 60 12;cc segmentDelimiter edit; xywh 27 36 60 12;cc lbl3 static;cn "Element Delimiter:"; xywh 88 38 60 12;cc elementDelimiter edit; xywh 158 23 48 28;cc preview button;cn "View File"; pas 6 6;pcenter; rem form end; ) mainForm_run=: 3 : 0 wd MAINFORM NB. initialize form here wd 'pshow;' ) mainForm_close=: 3 : 0 wd'pclose' ) mainForm_selectSource_button=: 3 : 0 filename=. wd'mbopen' if. 0 ~: #filename do. wd 'set sourceEDI *', filename NB. Open the file and look for the 'ST' segment data=. freads filename NB. check if the file was opened if. not isnumeric data do. 'stpos stcount'=. 2 take ravel 'IEA' rxmatch data NB. check if we found a matching 'IEA' if. stpos > _1 do. NB. identify the element then the segment delimiter element=. data {~ stpos + stcount segment=. data {~ <: stpos NB. save this values wd 'set elementDelimiter *', element wd 'set segmentDelimiter *', segment end. end. end. ) mainForm_preview_button=: 3 : 0 data=. freads sourceEDI if. 1 =# elementDelimiter do. element=. 0 pick elementDelimiter else. element=. elementDelimiter end. select. #segmentDelimiter case. 0 do. segment=. 10 { a. case. 1 do. segment=. 0 pick segmentDelimiter data=. data rplc (10 { a.);'' case. do. segment=. segmentDelimiter data=. data rplc (10 { a.);'' end. grid element cutstring every segment cutstring data ) NB. ========================================================= NB.*cutstring v cut string into boxes NB. NB. examples: NB. NB. cutstring ' one, two,,three' NB. +----+-----++-----+ NB. | one| two||three| NB. +----+-----++-----+ NB. NB. cutstring ' one, ''two,three'',,four' NB. +----+-----------++----+ NB. | one| two,three||four| NB. +----+-----------++----+ NB. NB. cutstring ' ,one, ''two, ''''three'''',four'',,''Ron''''s Stuff'',' NB. +-+---+---------------------++-----------++ NB. | |one| two, 'three',four||Ron's Stuff|| NB. +-+---+---------------------++-----------++ NB. NB. cutstring ',,''one, two'',,three' NB. +++---------++-----+ NB. |||one, two||three| NB. +++---------++-----+ NB. NB. '2' cutstring 'The2flux2capacitor2requires21.32jigawatt' NB. +---+----+---------+--------+---+--------+ NB. |The|flux|capacitor|requires|1.3|jigawatt| NB. +---+----+---------+--------+---+--------+ cutstring=: ','&$: : (4 : 0) if. 0 = #y do. '' return. end. if. L. y do. y return. end. txt=. y, {.x msk=. txt = '''' com=. (txt e. x) > ~: /\ msk msk=. (msk *. ~:/\msk) < msk <: 1 |. msk NB. Modified so that it won't delete the extra blanks NB. deb each (msk # com) <;._2 msk # txt (msk # com) <;._2 msk # txt ) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
