Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: Applying function pointers
« Last post by Kuron on August 22, 2017, 01:49:09 PM »
Euphoria

OT.  Bought that when it came out in '93.  Great language and racked up some $$ in long distance charges using their BBS.  Still have the old printed manual boxed up somewhere.
2
General / Applying function pointers
« Last post by Arnold on August 22, 2017, 10:42:36 AM »
Hi Charles,

at Rosettacode.org there is a task: "Apply a callback to an array". I tried to apply some of the examples with Oxygenbasic. This one is adapted from Euphoria:

Code: OxygenBasic
  1. 'Oxygenbasic A43 2017-08-07
  2.  
  3. include "$/inc/console.inc"
  4.  
  5. function apply_to_all(int s[], int c, sys @f)
  6.     ' apply a function to all elements of a sequence
  7.  
  8. '    dim result[] as int at @s
  9.    int *result[] = @s[]
  10.  
  11.     for i = 1 to c
  12.         ' we can call add1() here although it comes later in the program
  13.         result[i] = call f(s[i])
  14.     next i
  15.     return result[]
  16. end function
  17.  
  18. function add1(int x) as int
  19.     return x+1
  20. end function
  21.  
  22. int array[] = {10, 20, 30, 40, 50}
  23.  
  24. ' add1() is visible here, so we can call the function
  25. array[] = apply_to_all(array[], countof array, @add1)
  26.  
  27. printl
  28. for x=1 to countof array
  29.   print array[x] " "
  30. next
  31. printl
  32.  
  33. printl "Enter ..." : waitkey
  34.  

Output:

11 21 31 41 51

Enter ...

This example is adapted from Freebasic. When I coded it I noticed that in fact I would not need any pointer to a function at all, but anyway:

Code: OxygenBasic
  1. 'Oxygenbasic A43 2017-08-07
  2.  
  3. include "$/inc/console.inc"
  4.  
  5. sub PrintEx(int n)
  6.   printl n + tab + n * n + tab + n * n * n
  7. end sub
  8.  
  9. sub Proc(int array[], c, sys @call_back)
  10.   for i = 1 to c
  11.     call call_back(array[i])
  12.   next
  13. end sub
  14.  
  15.  
  16. int a[10] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
  17.  
  18. printl "n" + tab + "n^2" + tab + "n^3"
  19. printl "-" + tab + "---" + tab + "---"
  20. Proc(a[], countof a, @PrintEx)
  21. printl
  22.  
  23. printl "Enter ..." : waitkey
  24.  

Output:

n       n^2     n^3
-       ---     ---
10      100     1000
20      400     8000
30      900     27000
40      1600    64000
50      2500    125000
60      3600    216000
70      4900    343000
80      6400    512000
90      8100    729000
100     10000   1000000

Enter ...

Is this approach ok? Are there altenatives in Oxygenbasic when using function pointers?

There is also another interesing example done in FBSL with languages[]. But I am not sure about the purpose of the MAP() function. Is this something which you achieve in tests\Constructs\ArrayOfCalls.o2bas or in examples\Linkage\FuncLinkTbls.o2bas?

Roland
3
User Interface / Re: Aurel Edit
« Last post by Aurel on August 21, 2017, 01:48:09 PM »
hi
some changes and cleaning( awinh is now called awinh035 )
some bindings removed,PW functions removed
work with scilexer: 1.6.7.0 also tested with 3.6.1.0
compiled with o2 - A041
4
Open Forum / Re: Object-Oriented Programming is Bad
« Last post by John on August 20, 2017, 08:12:02 PM »
Thanks Charles!

I have really enjoyed Brian Wills OOP presentations. I'm fighting this battle with Sage and their emulation of OOP with ProvideX Business BASIC.
5
Latest Version / Re: FBSL Website
« Last post by Kuron on August 19, 2017, 10:15:51 PM »
I am with Charles, I miss the old keyboards not only for reliability, but my typing speed and accuracy was much better on them.

When I went to move to Nashville and was packing everything into the truck, when it came to all of my old computer systems in the closet, I said there is no way I am taking these with me, even though I had some semi valuable stuff.  I tossed them all in the dumpster.  The only old systems I kept are my old TI-99/4A computers.  One beige one silver.  Also kept my old Palm Pilot and my Psion Series 3a.

My normal computers, are still packed in boxes.  After a year of not being online or touching a computer, I simply bought a couple of budget notebooks to hold me over until I can get things unpacked and get my studio set up.

I still buy keyboard covers for my laptops if a cover is available for them. 
6
Latest Version / Re: FBSL Website
« Last post by Mike Lobanovsky on August 19, 2017, 03:24:56 PM »
What I miss most of all are those transparent plastic top covers for the keyboards they used to supply even the cheapest brands with, to protect against dust accumulating in the slots between the keys. I hate having to vacuum clean my modern keyboards once a week of all those bread and chip crumbs and also hairs from my occasional beard. :)
7
Latest Version / Re: FBSL Website
« Last post by Charles Pegge on August 19, 2017, 02:42:18 PM »

All my computers died well before they could become collectable antiques. I think our damp marine climate and lack of central heating  makes them go rusty or mouldy inside :)

I miss the old keyboards. They were so solidly engineered.
8
Open Forum / Re: Object-Oriented Programming is Bad
« Last post by Charles Pegge on August 19, 2017, 02:25:33 PM »
There are two more videos along the same lines, in which Brian Will explores some examples and compares them with the procedural equivalent:


Object-Oriented Programming is Embarrassing: 4 Short Examples
https://www.youtube.com/watch?v=IRTfhkiAqPw
4 mar 2016

Object-Oriented Programming is Garbage: 3800 SLOC example
https://www.youtube.com/watch?v=V6VP-2aIcSc
 21 Mar 2016
9
Latest Version / Re: FBSL Website
« Last post by Mike Lobanovsky on August 19, 2017, 02:21:14 PM »
Last November my wife decided to refurbish the closet in her room. I was out of town for a few days then and by the time I came back home, the work had already been done. "Look", I said, "I recon one of my old notebooks was supposed to be there somewhere on the shelf in your closet. Where did you move it to, darling?". "Oh," she said, "That iron box really didn't look like anything you have in your study. I thought it was some toolbox incidentally forgotten by the workers who had done refurbishing three years before. So I told the taskmaster he could have it if he wished".

There on the spot I remained frozen and speechless for quite some time.

Suffice it to say the "iron toolbox" was in fact an IBM PC Convertible, a museum rarity item in perfect working order and near mint cosmetic condition quotable on eBay at around $800 in Europe. (Just FYI, the medium salary in my country is currently under $200 per month)




So, what I am left with is an original 15V DC IBM power supply with cables, two 720KB diskettes that booted the laptop into BASIC, complete user documentation, and of course, my beloved wife.  :D
10
Open Forum / Re: Object-Oriented Programming is Bad
« Last post by John on August 18, 2017, 12:56:23 PM »
My only interest in OOP, COM/OLE is on Windows. The QuickBooks API is COM/OLE and I need an easy to use interface to MSOffice. I use no OOP in Script BASIC anywhere else.
Pages: [1] 2 3 ... 10