[q-lang-cvs] qcalc calclib.q,1.35,1.36
Brought to you by:
agraef
|
From: Albert G. <ag...@us...> - 2007-11-17 07:40:01
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1519 Modified Files: calclib.q Log Message: code cleanup, make index and friends work in tasks Index: calclib.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/calclib.q,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** calclib.q 17 Nov 2007 07:19:55 -0000 1.35 --- calclib.q 17 Nov 2007 07:39:57 -0000 1.36 *************** *** 4,14 **** /* This module provides some useful support functions for use in QCalc spreadsheets. You need to import this if you want to use any of the ! operations of this module in your spreadsheet script. ! ! Note that for QCalc to work properly, this script needs to be on the QPATH, ! therefore it is recommended that you install QCalc under the prefix where ! your Q installation lives. Otherwise you will have to set your QPATH ! accordingly. ! Please also refer the QCalc manual for a closer description of the functions provided by this module. */ --- 4,11 ---- /* This module provides some useful support functions for use in QCalc spreadsheets. You need to import this if you want to use any of the ! operations of this module in your spreadsheet script. Also note that for ! QCalc to work properly, this script needs to be on the QPATH, therefore it ! is recommended that you install QCalc under the prefix where your Q ! installation lives. Otherwise you will have to set your QPATH accordingly. Please also refer the QCalc manual for a closer description of the functions provided by this module. */ *************** *** 19,23 **** /* The following functions can be used to convert between numeric cell indices ! and symbolic ones, either in string form ("A1") or as a quoted symbol ('A1). */ --- 16,20 ---- /* The following functions can be used to convert between numeric cell indices ! (I,J) and symbolic ones, either in string form ("A1") or as a quoted symbol ('A1). */ *************** *** 29,41 **** public message S; ! /* Set a cell value (and return that value). The given cell index KEY can ! either be in the numeric format as returned by the index function or in any ! of the symbolic formats supported by the cellindex routine (see above), and ! X may be any Q expression. */ public setval KEY X; ! /* Convenience functions to convert a list to a matrix or row/column vector of ! table cells, and return the given list value. */ public matrix KEY Xs, rowvect KEY Xs, colvect KEY Xs; --- 26,37 ---- public message S; ! /* Set a cell value. The given cell index KEY can either be in the numeric ! format as returned by the index function or in any of the symbolic formats ! supported by the cellindex routine (see above). */ public setval KEY X; ! /* Convenience functions to store a list in a matrix or row/column vector of ! table cells. */ public matrix KEY Xs, rowvect KEY Xs, colvect KEY Xs; *************** *** 60,69 **** Inside the background task, the task_input function provides a Q semaphore queue used to communicate values to the executing task in response to GUI ! actions inside QCalc, and the task_params function can be used to extract ! arguments from a quoted taskbutton call (which is sent to the task when the ! button gets updated). */ public special taskbutton ~ARGS X, task_params X; ! public task_input, task_index, task_row, task_column; /* Implementation. *********************************************************/ --- 56,65 ---- Inside the background task, the task_input function provides a Q semaphore queue used to communicate values to the executing task in response to GUI ! actions on the button inside QCalc, and the task_params function can be ! used to extract arguments from a quoted taskbutton call (which is sent to ! the task when the button gets updated). */ public special taskbutton ~ARGS X, task_params X; ! public task_input; /* Implementation. *********************************************************/ *************** *** 81,87 **** private yyloop, yyout X, yyerror X; index = (I,J) where (I,J) = get YYKEY; ! row = I where (I,J) = get YYKEY; ! column = J where (I,J) = get YYKEY; /* Some helper routines. */ --- 77,88 ---- private yyloop, yyout X, yyerror X; + private task_index; + + /* index and friends. */ + index = (I,J) where (I,J) = get YYKEY; ! = (I,J) where (I,J) = task_index; ! row = I where (I,J) = index; ! column = J where (I,J) = index; /* Some helper routines. */ *************** *** 117,126 **** cellname (I,J) = valq S where S:String = cellstr (I,J); ! /* Message display */ message S:String = printf "\f+++ Message: %s\n" (str S); ! /* GUI elements. */ checkbox S:String --- 118,156 ---- cellname (I,J) = valq S where S:String = cellstr (I,J); ! /* Message display. */ message S:String = printf "\f+++ Message: %s\n" (str S); ! /* setval and friends. */ ! ! private indexarg KEY; ! ! indexarg (I:Int,J:Int) ! = (I,J) if (I>=0) and then (J>=0); ! indexarg S:String ! = (I,J) where (I,J) = cellindex S; ! indexarg 'X = (I,J) where (I,J) = cellindex 'X; ! ! setval KEY X = printf "\f+++ Update: %s %s\n" (str (I,J),str X) || ! if member (get YYDATA) (I,J) then yyset (I,J) X else X ! where (I:Int,J:Int) = indexarg KEY; ! ! matrix KEY Xs:List ! = dowith setval Ks (cat Xs) || Xs ! where Ks = [(I0+I,J0+J) : I in [0..N-1], J in [0..M-1]] ! if all islist Xs and then all ((=M).(#)) Xs ! where Ys:List = hd Xs, N = #Xs, M = #Ys ! where (I0:Int,J0:Int) = indexarg KEY; ! ! rowvect KEY Xs:List ! = matrix (I0,J0) [Xs] || Xs ! where (I0:Int,J0:Int) = indexarg KEY; ! ! colvect KEY Xs:List ! = matrix (I0,J0) $ map (push []) Xs || Xs ! where (I0:Int,J0:Int) = indexarg KEY; ! ! /* Basic GUI elements. */ checkbox S:String *************** *** 303,308 **** task_index = (I,J) where (I,J,SEM) = get YYSEM!thread_no this_thread; - task_row = I where (I,J) = task_index; - task_column = J where (I,J) = task_index; private begin_task ARGS, end_task; --- 333,336 ---- *************** *** 344,376 **** where (I,J) = task_index; - /* setval and friends. */ - - private indexarg KEY; - - indexarg (I:Int,J:Int) - = (I,J) if (I>=0) and then (J>=0); - indexarg S:String - = (I,J) where (I,J) = cellindex S; - indexarg 'X = (I,J) where (I,J) = cellindex 'X; - - setval KEY X = printf "\f+++ Update: %s %s\n" (str (I,J),str X) || - if member (get YYDATA) (I,J) then yyset (I,J) X else X - where (I:Int,J:Int) = indexarg KEY; - - matrix KEY Xs:List - = dowith setval Ks (cat Xs) || Xs - where Ks = [(I0+I,J0+J) : I in [0..N-1], J in [0..M-1]] - if all islist Xs and then all ((=M).(#)) Xs - where Ys:List = hd Xs, N = #Xs, M = #Ys - where (I0:Int,J0:Int) = indexarg KEY; - - rowvect KEY Xs:List - = matrix (I0,J0) [Xs] || Xs - where (I0:Int,J0:Int) = indexarg KEY; - - colvect KEY Xs:List - = matrix (I0,J0) $ map (push []) Xs || Xs - where (I0:Int,J0:Int) = indexarg KEY; - /* Internals. */ --- 372,375 ---- |