Author Topic: DLLC  (Read 28674 times)

0 Members and 2 Guests are viewing this topic.

JRS

  • Guest
Re: DLLC
« Reply #60 on: November 06, 2014, 10:13:56 AM »
It's something to do with loading the source from the file. I made the source as a string in O2.inc and it worked. (sort of) No exception /O2 error.


C:\scriptbasic\o2dev>scriba testo2.sb
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZYXWVUTSRQPONMLKJIHGFEDCBA
abc
(
d
[
xx
]
+
7
/
6
,
"qwerty"
)

 Given        a            text         file       of       many        lines,        where   fields   within        a   line
 are          delineated   by           a        single   'dollar'    character,      write        a
 that         aligns       each         column     of       fields        by       ensuring     that    words       in   each
 column       are          separated    by         at       least         one
 Further,     allow        for          each      word        in          a          column       to       be   either   left
 justified,   right        justified,   or       center   justified     within          its                                      The

 qu
ick
 br
own
 fo
x j
ump
ed
ove
r t
he
laz
y d
og'
s b
ack
 12
345
678
90
tim
es.

C:\scriptbasic\o2dev>


JRS

  • Guest
Re: DLLC
« Reply #61 on: November 06, 2014, 10:31:20 AM »
I know what the problem is. I had this same issue on Koding.com. I had to put a SLEEP(1) after the file close to flush to remainder of the file into the string. I may try using the T ext. module  load string function instead of native INPUT.

Update

Putting the SB CLOSE(1) in the Finish function solved the problem and the SLEEP(1) wasn't needed. It seems that CLOSE() right after a INPUT needs some time.
« Last Edit: November 06, 2014, 10:41:32 AM by John »

Charles Pegge

  • Guest
Re: DLLC
« Reply #62 on: November 06, 2014, 10:57:58 AM »
Thanks John, useful to know about the file buffering.

JRS

  • Guest
Re: DLLC
« Reply #63 on: November 06, 2014, 11:32:58 AM »
Is the GetTextWords() function broken or am I not understanding how it works?

Aurel

  • Guest
Re: DLLC
« Reply #64 on: November 06, 2014, 12:41:11 PM »
I think that work as you can see from screenshot...
// this time i use latest oxygen.dll    ;)
Code: [Select]
function GetTextWord(char*s, sys *i) as char*
      =============================================
      static string w
      sys           a,j
      byte          b at @s
      j=i
      i--
      @b--
      do
        i++
        @b++
        select b
        case 0            : exit do      'end of string
       case 33 to 255    : exit do      'non white space
       end select
      end do
      '
     j=i
      '
     do
        select b
        case 0 to 32 : exit do
        end select
        i++
        @b++
      end do
      '
     if i>j
        w=mid s,j,i-j
        return w
      else
        return ""
      end if
      '
end function

 print GetTextWord("Aurel",3)   

.

Charles Pegge

  • Guest
Re: DLLC
« Reply #65 on: November 06, 2014, 12:57:42 PM »
I see the parsing problem now!

 missing
  @b+=i

Code: OxygenBasic
  1.   function GetTextWord(char*s, sys*i) as char*
  2.   ============================================
  3.   static string w
  4.   sys           j
  5.   byte          b at strptr s
  6.   j=i
  7.   i--
  8.   @b+=i
  9.   @b--
  10.   do
  11.     i++
  12.     @b++
  13.     select b
  14.     case 0            : exit do      'end of string
  15.    case 33 to 255    : exit do      'non white space
  16.    end select
  17.   end do
  18.   '
  19.  j=i
  20.   '
  21.  do
  22.     select b
  23.     case 0 to 32 : exit do
  24.     end select
  25.     i++
  26.     @b++
  27.   end do
  28.   '
  29.  if i>j
  30.     w=mid s,j,i-j
  31.   else
  32.     w=""
  33.   end if
  34.   return w
  35.   '
  36.  end function
  37.  

JRS

  • Guest
Re: DLLC
« Reply #66 on: November 06, 2014, 01:06:53 PM »
Thanks Charles!

testo2.sb
Code: Script BASIC
  1. IMPORT O2.inc
  2.  
  3. FOR x = 65 TO 90
  4.   alpha &= CHR(x)
  5. NEXT
  6. PRINT alpha,"\n"
  7. PRINT O2::RevStr(alpha),"\n"
  8. p = 1
  9. Next_Word:
  10.   wd = O2::GetWords("abc(d[xx]+7/6,\"qwerty\")", p)
  11.   IF wd <> "" THEN
  12.     PRINT wd,"\n"
  13.     GOTO Next_Word
  14.   END IF
  15. q = """
  16. Given;;a;;text;;file;;of;;many;;lines,;;where;;fields;;within;;a;;line;;
  17. are;;delineated;;by;;a;;single;;'dollar';;character,;;write;;a;;program
  18. that;;aligns;;each;;column;;of;;fields;;by;;ensuring;;that;;words;;in;;each;;
  19. column;;are;;separated;;by;;at;;least;;one;;space.
  20. Further,;;allow;;for;;each;;word;;in;;a;;column;;to;;be;;either;;left;;
  21. justified,;;right;;justified,;;or;;center;;justified;;within;;its;;column.
  22. """
  23. PRINT O2::ColumnAlign(q, "LLLLCCCRRRRR", ";;", "\n"),"\n"
  24. p = 1
  25. Next_Text_Word:
  26.   wd = O2::GetTextWords("The quick brown fox jumped over the lazy dog's back 1234567890 times.", p)
  27.   IF wd <> "" THEN
  28.     PRINT wd,"\n"
  29.     GOTO Next_Text_Word
  30.   END IF
  31.  
  32. O2::Done()
  33.  

O2.inc
Code: Script BASIC
  1. MODULE O2
  2.  
  3. include "dllcinc.sb"
  4.  
  5. oxy=dllfile("/scriptbasic/Debugger/modules/oxygen.dll")
  6.  
  7. o2_basic = dllproc( oxy, "o2_basic i =(c*source) " )
  8. o2_exec  = dllproc( oxy, "o2_exec  i =(i call)   " )
  9. o2_error = dllproc( oxy, "o2_error c*=()         " )
  10. o2_errno = dllproc( oxy, "o2_errno i =()         " )
  11. o2_len   = dllproc( oxy, "o2_len   i =()         " )
  12. o2_mode  = dllproc( oxy, "o2_mode     (i mode)   " )
  13.  
  14. dllcall o2_mode,1
  15.  
  16. OPEN "/scriptbasic/Debugger/include/O2.src" FOR INPUT AS #1
  17. src = INPUT(LOF(1), 1)
  18.  
  19. a = oxygen(src)
  20. Finish  = dllproc(a,"Finish ()", dllcald(a,0))
  21. Reverse = dllproc(a,"Reverse (c*value)", dllcald(a,1))
  22. Words   = dllproc(a,"getword c* = (c* strraw, i* start)", dllcald(a,2))
  23. ColAlign   = dllproc(a,"AlignText c* = (c* in, c* ju, C* dl, c* cr)", dllcald(a,3))
  24. Text = dllproc(a,"GetTextWord c* = (c* in_str, i* start)", dllcald(a,4))
  25.  
  26. FUNCTION oxygen(src)
  27.   dllcall o2_basic,src
  28.   IF (dllcall(o2_errno)<> 0) THEN
  29.     dllprnt dllcall(o2_error)
  30.     a = 0
  31.   ELSE
  32.     a = dllcall(o2_exec,0)
  33.   END IF
  34.   oxygen = a
  35. END FUNCTION
  36.  
  37. FUNCTION Done
  38.   rtnval = dllcall(Finish)
  39.   dllfile
  40.   CLOSE(1)
  41.   Done = rtnval
  42. END FUNCTION
  43.  
  44. ' SB wrapper functions
  45.  
  46. FUNCTION RevStr(strarg)
  47.   dllcall(Reverse, strarg)
  48.   RevStr = strarg
  49. END FUNCTION
  50.  
  51. FUNCTION GetWords(strarg, longarg)
  52.   GetWords = dllcall(Words, strarg, longarg)
  53. END FUNCTION
  54.  
  55. FUNCTION ColumnAlign(in_str, just_str, dlm_str, eol_str)
  56.   ColumnAlign = dllcall(ColAlign, in_str, just_str, dlm_str, eol_str)
  57. END FUNCTION
  58.  
  59. FUNCTION GetTextWords(in_str, start)
  60.   GetTextWords = dllcall(Text, in_str, start)
  61. END FUNCTION
  62.  
  63. END MODULE
  64.  

O2.src
Code: OxygenBasic
  1. ' O2 source
  2.  
  3. extern
  4.  
  5. function reverse(char*s)
  6. '=======================
  7.  addr ecx,s
  8.   mov edx,0
  9.  .rlen
  10.   mov al,[ecx]
  11.   cmp al,0
  12.   jz xlen
  13.   inc edx
  14.   inc ecx
  15.   jmp rlen
  16.  .xlen
  17.   ;
  18.   addr ecx,s
  19.   add  edx,ecx
  20.   dec ecx
  21.   ;
  22.  .rswap
  23.   inc ecx
  24.   dec edx
  25.   cmp edx,ecx
  26.   jle xswap
  27.   mov al,[ecx]
  28.   mov ah,[edx]
  29.   mov [ecx],ah
  30.   mov [edx],al
  31.   jmp rswap
  32.  .xswap
  33.   end function
  34.  
  35. function getword(char*ss,sys*b) as char*
  36. '=======================================
  37. if b=0 then b=1
  38. byte s at @ss
  39. byte c,d
  40. sys bb,bc
  41. static char z[128]
  42. a=0
  43. bb=b
  44.  
  45. 'SKIP LEADING SPACES
  46. do
  47.   c=s[b]
  48.   select c
  49.    case 33 to 255,0 : exit do 'SKIP SPACE
  50.  end select
  51.   b++
  52. end do
  53. bc=b
  54.  '
  55. 'QUOTES
  56. select c
  57.  case 34,39
  58.    do
  59.      b+=1
  60.      d=s[b]
  61.      if d=0 or d=c then b+=1 : jmp fwd done
  62.    end do
  63. end select
  64. 'WORDS AND SYMBOLS
  65. do
  66.   c=s[b]
  67.   select c
  68.   case 0 to 32    : exit do
  69.   case 35         : jmp fwd more
  70.   case 33 to 47   : 'symbols
  71.  case 48 to 57   : jmp fwd more 'numbers
  72.  case 58 to 64   : 'symbols
  73.  case 65 to 90   : jmp fwd more 'capitals
  74.  case 95         : jmp fwd more 'underscore
  75.  case 91 to 96   : 'symbols
  76.  case 97 to 122  : jmp fwd more 'lower case
  77.  case 123 to 127 : 'symbols
  78.  case 128 to 255 : jmp fwd more 'higher ascii
  79. end select
  80.  
  81. if b=bc then b++
  82.   exit do
  83.  
  84.   more:
  85.   b++
  86. end do
  87.  
  88. done:
  89.  
  90. if b > bb then
  91.   z=mid ss,bc,b-bc
  92. else
  93.   z = ""
  94. end if
  95. return z
  96.  
  97. end function
  98.  
  99. =================
  100. Class AlignedText
  101. =================
  102.  
  103. indexbase 1
  104.  
  105. string  buf, bufo, pr, cr, tab, jus, dlm
  106. sys     Cols, Rows, ColWidth[0x100], TotWidth, ColPad, ld
  107.  
  108. method SetText(char*s)
  109. ======================
  110. if not len cr then cr=chr(13,10)
  111. tab=chr(9)
  112. if not len jus then jus=string 200,"L"
  113. buf=s
  114. measure
  115. end method
  116.  
  117.  
  118. method measure()
  119. ================
  120. sys a, b, wa, wb, cm, c, cw
  121. a=1 : b=1
  122. Cols=0 : Rows=0 : ColPad=3
  123. ld=len dlm
  124. if not ld then dlm="," : ld=1 'default to comma
  125. do
  126.   wb=b
  127.   a=instr b,buf,cr
  128.   if a=0 then exit do
  129.   cm=0
  130.   c++
  131.   do
  132.     wa=instr wb,buf,dlm
  133.     if wa=0 or wa>a then exit do
  134.     cm++
  135.     if cm>cols then cols=cm
  136.     cw=wa-wb
  137.     if cw > ColWidth[cm] then ColWidth[cm]=cw
  138.     wb=wa+ld
  139.   end do
  140.   b=a+len cr
  141. end do
  142. rows=c
  143. '
  144. c=0
  145. for i=1 to cols
  146.   ColWidth[ i ]+=ColPad
  147.   c+=ColWidth[ i ]
  148. next
  149. TotWidth=c+len cr
  150. 'print ShowMetrics
  151. end method
  152.  
  153.  
  154. method ShowMetrics() as char*
  155. =============================
  156. pr="METRICS:" cr cr
  157. pr+=rows tab cols tab totwidth cr cr
  158. pr+="column" tab "spacing" cr
  159. for i=1 to cols
  160.   pr+=i tab ColWidth[ i ] cr
  161. next
  162. return pr
  163. end method
  164.  
  165.  
  166. method justify(char*j)
  167. ======================
  168. jus=j
  169. end method
  170.  
  171. method delimiter(char*j)
  172. ========================
  173. dlm=j
  174. end method
  175.  
  176. method endofline(char*j)
  177. ========================
  178. cr=j
  179. end method
  180.  
  181.  
  182. method layout() as char*
  183. ========================
  184. sys a, b, wa, wb, wl, cm, lpos, cpos
  185. bufo=space Rows*TotWidth
  186. a=1 : b=1
  187. do
  188.   wb=b
  189.   a=instr(b,buf,cr)
  190.   if a=0 then exit do
  191.   cm=0
  192.   cpos=1
  193.   do
  194.     wa=instr(wb,buf,dlm)
  195.     if wa=0 or wa>a then exit do
  196.     '
  197.    cm++
  198.     '
  199.    'JUSTIFICATION
  200.    '
  201.    wl=wa-wb
  202.     p=lpos+cpos 'default "L" LEFT ALIGN
  203.    '
  204.    select case asc(jus,cm)
  205.       case "R" : p=lpos+cpos+ColWidth[cm]-wl-Colpad
  206.       case "C" : p=lpos+cpos+( ColWidth[cm]-wl-Colpad )*.5
  207.     end select
  208.     '
  209.    mid bufo,p, mid buf,wb,wl
  210.     cpos+=colwidth[cm]
  211.     wb=wa+ld
  212.   end do
  213.   b=a+len cr
  214.   lpos+=TotWidth
  215.   if lpos<len(bufo) then mid bufo,lpos-1,cr
  216. end do
  217. return bufo
  218. end method
  219.  
  220. end class
  221.  
  222. '#recordof AlignedText
  223.  
  224. AlignedText atxt
  225.  
  226. function AlignText(char *in,*ju,*dl,*cr) as char*
  227. =================================================
  228. atxt.justify         ju
  229. atxt.delimiter       dl
  230. atxt.endofline       cr
  231. atxt.SetText         in
  232. return               atxt.layout
  233. end function
  234.  
  235. function GetTextWord(char*s, sys*i) as char*
  236. '===========================================
  237. static string w
  238. sys           j
  239. byte          b at strptr s
  240. j=i
  241. i--
  242. @b+=i
  243. @b--
  244. do
  245.   i++
  246.   @b++
  247.   select b
  248.     case 0            : exit do      'end of string
  249.    case 33 to 255    : exit do      'non white space
  250.  end select
  251. end do
  252. j=i
  253. do
  254.   select b
  255.     case 0 to 32 : exit do
  256.   end select
  257.   i++
  258.   @b++
  259. end do
  260. if i>j
  261.   w=mid s,j,i-j
  262. else
  263.   w=""
  264. end if
  265. return w
  266.  
  267. end function
  268.  
  269. sub finish()
  270. '===========
  271.  terminate
  272. end sub
  273.  
  274. function link(sys n) as sys
  275. '==========================
  276.  select n
  277.   case 0 : return @finish
  278.   case 1 : return @reverse
  279.   case 2 : return @getword
  280.   case 3 : return @AlignText
  281.   case 4 : return @GetTextWord
  282.   end select
  283. end function
  284.  
  285. end extern
  286.  
  287. addr link
  288.  

Output

C:\scriptbasic\o2dev>scriba testo2.sb
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZYXWVUTSRQPONMLKJIHGFEDCBA
abc
(
d
[
xx
]
+
7
/
6
,
"qwerty"
)

 Given        a            text         file       of       many        lines,        where   fields   within        a   line
 are          delineated   by           a        single   'dollar'    character,      write        a
 that         aligns       each         column     of       fields        by       ensuring     that    words       in   each
 column       are          separated    by         at       least         one
 Further,     allow        for          each      word        in          a          column       to       be   either   left
 justified,   right        justified,   or       center   justified     within          its
The
quick
brown
fox
jumped
over
the
lazy
dog's
back
1234567890
times.

C:\scriptbasic\o2dev>

JRS

  • Guest
Re: DLLC
« Reply #67 on: November 06, 2014, 01:19:56 PM »
Code: Script BASIC
  1. SPLITA "The quick brown fox jumped over the lazy dog's back 1234567890 times." BY " " TO a
  2. FOR x = 0 to UBOUND(a)
  3.   PRINT a[x],"\n"
  4. NEXT  
  5.  

In one line.
Code: Script BASIC
  1. PRINT REPLACE("The quick brown fox jumped over the lazy dog's back 1234567890 times.", " ", "\n"),"\n"
  2.  


C:\scriptbasic\o2dev>scriba altmeth.sb
The
quick
brown
fox
jumped
over
the
lazy
dog's
back
1234567890
times.

C:\scriptbasic\o2dev>


Sometimes making the right call can save time and effort.  :)
« Last Edit: November 06, 2014, 04:16:31 PM by John »

JRS

  • Guest
Re: DLLC
« Reply #68 on: November 07, 2014, 12:11:38 AM »
Charles,

I'm going to remove the GetTextWord() function as it would be a duplication what SB already does well. I still would like to have numeric formating for the AlignText() function. It would be great if you had an array sort function laying around.  :)

I have two goals with creating this library with you.

1. To provide a library of functions that enhance the syntax of SB dynamically with JIT functions provided by O2.

2. Create a library of functions that show the features of O2 and provides a test suite to run against current O2 builds.
« Last Edit: November 07, 2014, 01:24:14 AM by John »

Charles Pegge

  • Guest
Re: DLLC
« Reply #69 on: November 07, 2014, 07:24:13 AM »
Hi John,

Proposed format:



'params
' source string
' format string
' n padding spaces between columns
' field delimiter string
' end of line string

'FORMAT STRING:
'L left align (default)
'C centre align
'R right align

' 1...n optional number fixing column width.
         (data exceeding the column width is right-clipped


PRINT O2::ColumnAlign(quo, "L16 LCR R20", 1, ";;", "\n"  )
« Last Edit: November 07, 2014, 07:33:02 AM by Charles Pegge »

JRS

  • Guest
Re: DLLC
« Reply #70 on: November 07, 2014, 08:05:57 AM »
That looks good. Will we be able to have text and numerics and formatting only applies to number columns?

Charles Pegge

  • Guest
Re: DLLC
« Reply #71 on: November 07, 2014, 08:43:35 AM »
Yes, L is the preferred alignment for alpha text, and R for number text.

Where a width is not specified, a column will be adjusted to accommodate its widest member.

A metrics function is needed to return column offsets and widths for processing in SB

JRS

  • Guest
Re: DLLC
« Reply #72 on: November 07, 2014, 08:55:08 AM »
This might be a good time to start interacting with SB arrays. Dave's engine code does a great job of parsing, returning SB arrays. My next goal is array sort and that would mean passing O2 a SB array and it returning (in the original array argument) the sorted results.

Aurel

  • Guest
Re: DLLC
« Reply #73 on: November 07, 2014, 10:16:43 AM »
Charles...
did i miss something ?
Function GetTextWord (char,int) extract words in loop ..right?
Is there function like Parse(delimiter,text) or in another words is there a easy way to modify
function  GetTextWord  to function buffer = Parse(delimiter,text)
or something similar already exists in examples.
if not there is no problem ..don't worry  ;)

JRS

  • Guest
Re: DLLC
« Reply #74 on: November 07, 2014, 01:07:06 PM »
Charles,

This is my first attempt at using SB arrays in an extension module.

Windows - Iup::Info
C:\SB3\test>sb3 iupinfo.sb
SYSTEMLANGUAGE: English (United States)
DRIVER: Win32
SYSTEM: WinXP
SYSTEMLOCALE: 1252  (ANSI - Latin I)
COMPUTERNAME: JRS-C997F91780C
USERNAME: John
MONITORSINFO: 0 0 1280 800

SCREENSIZE: 1280x766
SCREENDEPTH: 32
VIRTUALSCREEN: 0 0 1280 800
DLGFGCOLOR:   0   0   0
DLGBGCOLOR: 236 233 216
DEFAULTFONT: Tahoma,  8
DEFAULTFONTSIZE: 8
TXTFGCOLOR:   0   0   0
TXTBGCOLOR: 255 255 255
C:\SB3\test>

Linux - Iup::Info
jrs@laptop:~/sb/test$ scriba iupinfo.sb
SYSTEMLANGUAGE: en-us
DRIVER: GTK
SYSTEM: Linux
SYSTEMLOCALE: UTF-8
COMPUTERNAME: laptop
USERNAME: jrs
MONITORSINFO: 0 0 1280 800

SCREENSIZE: 1280x749
SCREENDEPTH: 24
VIRTUALSCREEN: 0 0 1280 800
DLGFGCOLOR:   0   0   0
DLGBGCOLOR: 220 218 213
DEFAULTFONT: Ubuntu 11
DEFAULTFONTSIZE: 11
TXTFGCOLOR:   0   0   0
TXTBGCOLOR: 255 255 255
jrs@laptop:~/sb/test$


Code: [Select]
IMPORT iup.bas
IUP::Open()

IUP::Info(INFO)

PRINT "SYSTEMLANGUAGE: ",INFO{"SYSTEMLANGUAGE"},"\n"
PRINT "DRIVER: ",INFO{"DRIVER"},"\n"
PRINT "SYSTEM: ",INFO{"SYSTEM"},"\n"
PRINT "SYSTEMLOCALE: ",INFO{"SYSTEMLOCALE"},"\n"
PRINT "COMPUTERNAME: ",INFO{"COMPUTERNAME"},"\n"
PRINT "USERNAME: ", INFO{"USERNAME"},"\n"
PRINT "MONITORSINFO: ",INFO{"MONITORSINFO"},"\n"
PRINT "SCREENSIZE: ",INFO{"SCREENSIZE"},"\n"
PRINT "SCREENDEPTH: ",INFO{"SCREENDEPTH"},"\n"
PRINT "VIRTUALSCREEN: ",INFO{"VIRTUALSCREEN"},"\n"
PRINT "DLGFGCOLOR: ",INFO{"DLGFGCOLOR"},"\n"
PRINT "DLGBGCOLOR: ",INFO{"DLGBGCOLOR"},"\n"
PRINT "DEFAULTFONT: ",INFO{"DEFAULTFONT"},"\n"
PRINT "DEFAULTFONTSIZE: ",INFO{"DEFAULTFONTSIZE"},"\n"
PRINT "TXTFGCOLOR: ",INFO{"TXTFGCOLOR"},"\n"
PRINT "TXTBGCOLOR: ",INFO{"TXTBGCOLOR"},"\n"

INFO IUP Function
Code: C
  1. #define ELEMENTS(x) (sizeof (x) / sizeof *(x))
  2.  
  3. besFUNCTION(PuiInfo)
  4.   VARIABLE Argument;
  5.   unsigned long __refcount_;
  6.   LEFTVALUE Lval;
  7.   char buffer[1024];
  8.   int i;
  9.   const char *glbvar[] = {
  10.   "SYSTEMLANGUAGE",
  11.   "DRIVER",
  12.   "SYSTEM",
  13.   "SYSTEMLOCALE",
  14.   "COMPUTERNAME",
  15.   "USERNAME",
  16.   "MONITORSINFO",
  17.   "SCREENSIZE",
  18.   "SCREENDEPTH",
  19.   "VIRTUALSCREEN",
  20.   "DLGFGCOLOR",
  21.   "DLGBGCOLOR",
  22.   "DEFAULTFONT",
  23.   "DEFAULTFONTSIZE",
  24.   "TXTFGCOLOR",
  25.   "TXTBGCOLOR"
  26.   };
  27.  
  28.   besRETURNVALUE = NULL;
  29.  
  30.   Argument = besARGUMENT(1);
  31.   besLEFTVALUE(Argument,Lval);
  32.   besRELEASE(*Lval);
  33.   *Lval = NULL;
  34.  
  35.   *Lval = besNEWARRAY(0,ELEMENTS(glbvar)*2-1);
  36.   if( *Lval == NULL )return COMMAND_ERROR_MEMORY_LOW;
  37.  
  38.   for (i =0; i < ELEMENTS(glbvar);i++) {
  39.     ARRAYVALUE(*Lval,2*i) = besNEWSTRING(strlen(glbvar[i]));
  40.     memcpy(STRINGVALUE(ARRAYVALUE(*Lval,2*i)),glbvar[i],strlen(glbvar[i]));
  41.     memset(buffer,0,1024);
  42.     strcpy(buffer, IupGetGlobal(glbvar[i]));
  43.     ARRAYVALUE(*Lval,2*i+1) = besNEWSTRING(strlen(buffer));
  44.     memcpy(STRINGVALUE(ARRAYVALUE(*Lval,2*i+1)),buffer,strlen(buffer));
  45.   }
  46.  
  47.   besALLOC_RETURN_LONG;
  48.   LONGVALUE(besRETURNVALUE) = -1;
  49. besEND
  50.