[REBOL] Find cant find reference to block. Re:

2000-07-14 Thread Galt_Barber




 list: []
== []

 reduce ['a copy ["a"]]
== [a ["a"]]

 append list [a ["a"]]
== [a ["a"]]

 list
== [a ["a"]]

 append list [b ["b"]]
== [a ["a"] b ["b"]]

 list
== [a ["a"] b ["b"]]

 select list 'a
== ["a"]

 append select list 'a "a-test"
== ["a" "a-test"]

 list
== [a ["a" "a-test"] b ["b"]]


find list select list 'a ; no good find can't find the reference to the
block

Brett.

append/only doesnt seem to help.
basically, select is going to return the element
after the position found.  Note that it doesn't
return the position of that element, it actually
returns the element itself.  Then you are  appending "a-test" to that.
then your select statement returns a block and you are searching
for a block with find.

 find [[a][b]] [a]
== none

this seems to indicate that you can't search for a block in Rebol with find?

 find [a b] [a]
== [a b]
I did that by mistake, and it worked!?

I should have done this:
 find [a b] 'a
== [a b]

 find [[a][b]] [[a]]
== [[a] [b]]
that was weird.
it found the block.

So here is one fix for it, apparently.
Why it should be necessary, I don't know.
It's as if when you specify a search parameter x,
and it's a block, rebol will grab first x and try to find that.

 find list reduce [select list 'a]
== [["a" "a-test"] b ["b"]]

-Galt





[REBOL] Block to string Re:

2000-07-14 Thread Galt_Barber





don't do this:

button "Convert to string" [
 host-addr2: to string! host-addr
 login-name2: to string! login-name
 Pass-word2: to string! Pass-word
 ]

but this might work:

button "Convert to string" [
 host-addr2:  host-addr/text
 login-name2: login-name/text
 Pass-word2:  Pass-word/text
 ]

-galt

(I don't know much about /View yet.)





[REBOL] more context clues

2000-07-11 Thread Galt_Barber




Thanks to Joe Marshall for his extremely helpful explanation
of Rebol 1 vs. Rebol 2 and contexts and GC.

 make-adder: func [x][func[y][+ x y]]
 add6: make-adder 6
 add6 1
== 7
 add5: make-adder 5
 add5 1
== 6
 add6 1
== 6
 source add6
add6: func [y][+ x y]

OK, this is the "problem", as we all  know.We wish add6 1 still returned 7.

We are told that each function has its own context.
Well, I thought that might mean that add6 having it's own
context would be fine.  But the problem I guess is that
add6 just gets a pointer to the function func[y][+ x y]
that is created once only when make-adder's definition is first evaluated.
And add5 gets another pointer to the same function instance.
I am not sure if add5 and add6 have a context, because they
are just words that point to the actual function, not functions themselves!
Clear?  Dizzy?  Have an aspirin.

 make-adder: func [x][print "stuff changed" func[y][+ x y]]
 source add6
add6: func [y][+ x y]
 add6 1
== 6
 add5 1
== 6

So, re-defining make-adder makes no difference now.
add6 and add5 still have a pointer to the original func instance and
there's still only one and it has only one context.

I finally figured out what  Joe Marshall meant by "free variable".
in our function func[y][+ x y] it is x that is the free variable,
because it is not a parameter nor a local variable, so it must
be resolved beyond the local function.
Usually vars not local are resolved to a global variable, but in this
case the dynamic, "unpredictable" extent of Rebol 2 leaves x
resolving to a function's context that make-adder can still fool with
upon it's next use.

I thought if I could get another instance of the function it could
have it's own context and be safe from further changes by make-adder,
but look, this doesn't work and I don't know of any way to fake it:

 make-adder: func [x][copy func [y][+ x y]]
 add6: make-adder 6
** Script Error: copy expected value argument of type: series port bitset.
** Where: copy func [y] [+ x y]

this didn't work, either:
 make-adder: func[x] [do [func [y] [+ x y]]]

nor this:
 make-adder: func[x] compose [func [y] [+ x y]]

So, is there a clever way to get it to cough up another instance
of the function with it's own context that won't get changed by running
make-adder again?

I guess I don't even care if the GC still ruins
it because I assume that will actually get fixed, silly me.


Thanks!
-galt


p.s.  More thoughts on the matter:

Frankly, being able to treat functions in special flexible ways
was one of the things that most attracted me to Rebol.
There are lots of other good things about Rebol, too, but losing
first class functions/continuations does impact your possibilities,
for sure.

Just recently I heard an interview (on the web) with the new guy they got at
rebol
(sorry, I am bad with names sometimes) who is heading up the company
bragging about rebol having first-class continuations,
It seems like he's using old sources of info.  If the first class
stuff is broken and doomed, he should stop referring to it.
Of course he probably has no idea what a first-class continuation is,
most people don't.

Where is Rebol going to go now?
They are going to have to change something,
because its a lame design now.  They should
either figure out a way to get their first class contexts back,
or else abandon contexts entirely.  This half-way stuff is
not really desirable.   And if contexts are gone, then
we can stop getting confused by examples from Rebol 1 days
when they were something you would want to actually use.
With the current design you should try to avoid them
and anything that depends on them.

With so many C-programmers at Rebol, it's likely Rebol
will continue to become more c-like by the day, I suppose.

-galt






[REBOL] func[func] Re:(8)

2000-07-11 Thread Galt_Barber




Hi, Larry!  I am having fun with your tricks!

I just got into what you were doing.
It's fun to see what /local and saved are doing
after running make-add a couple of times:
 add6: make-add 6
 add5: make-add 5

 source make-add
make-add: func [x /local saved][
  saved: [
make object! [
  z: 6
  f: func [y][+ z y]
]
make object! [
  z: 5
  f: func [y][+ z y]
]
  ]
  get in last append saved make object! [
z: x
f: func [y] [+ z y]
] 'f
]

I finally figured out that saved is none at the top of the loop,
but that right away it is assigned to the un-named constant (not)
[] that becomes full of objects as make-add is executed.

I have a question:
Is the function f inside each object in saved actually pointing
to the same code, or is it a separate instance completely?

I see now of course that z sure looks like a free variable,
resolving to the context of the object?  Does an object have a context, too?
Does the object reach into the context of f and tweak it's value, or does
it run f inside it's own object context?

-galt






[REBOL] more context clues Re:

2000-07-11 Thread Galt_Barber




I think this is quite amusing.
I am using contexts, combined with the use of compose first
mentioned by Ladislav.

Of course it is an awful perversion, but it can't be helped:

 make-adder: func [
 x
 /reset
][
 if reset [exit]
 func [y] compose [
   make-adder/reset (x)
   add x y
 ]
]

 add6: make-adder 6
 add6 1
== 7

 add5: make-adder 5
 add5 1
== 6

 add6 1
== 7

 source add6
add6: func [y] [
   make-adder/reset 6
add x y
]

So, it actually works!
Can you go to jail for this?
Free variables want to be free!

-galt





[REBOL] How to execute a rebol script from an html page? Re:(3)

2000-07-11 Thread Galt_Barber




SCRIPT language="REBOL"

It won't support the SCRIPT tag if the web server doesn't know what
REBOL is.

Is there a way to get my NT IIS server to allow me
to put Rebol into an .asp page?

I would be kind of surprised if it could already do this.

VBScript and Javascript have access to a lot of stuff inside
the IIS server's environment.  How would Rebol do that?


-galt





[REBOL] more context clues Re:(2)

2000-07-11 Thread Galt_Barber




Just when I thought I understood context,
e.g. each function has one, I read this:

 a: 1
== 1

block: [a]
== [a]

 use [a] [  a: 2   insert tail block [a]   ]
== []

 block
== [a a]

 reduce block
== [1 2]

well, I guess that words have context all by themselves.
so much for progress.

-galt





[REBOL] func[func] Re:(4)

2000-07-10 Thread Galt_Barber




Galt wrote:
make-adder: func [x] [func [y] [+ x y]]

Ladislav pointed out that if you use it more than once,
you must do this:
make-adder: func [x] [func [y] compose[+ (:x) y]]

Galt again:
what is the bloody point of having to put in the compose?
I thought the whole idea here was that contexts were cool,
and you could use them to have a hidden local variable.

I got this from a Scheme example and there's no extra compose
needed there.

I am guessing that the problem is that there is only one
copy of the block [+ x y] and that it has a context, whatever
that is, and that it can only have one context, and that one
gets changed everytime you run make-adder again with a new
parameter value for x.  So running make-adder a 2nd time
messes up the value hidden in the context of the first?

with the original simple method, you get this:
 source add6
add6: func [y][+ x y]

with Ladislav's method, you get this:
 source add6
add6: func [y][+ 6 y]

which is a nice demonstration.
But it's mechanism doesn't depend on context at all any more.
The function is really returning 6 not X with context.
6 is 6 in any context, so big whoop?

Did this used to work in an older rebol without compose?

I note that this works, too, silly as it is:
 make-adder: func [x] [func [y] reduce['+ x 'y]]


And this failed to work, which surprised me, so I guess I still don't get it
yet:
 z: [+ x y]
 make-adder: func [x] [func [y] bind copy z 'x]
I was hoping that I could make a new copy of the z block each time
make-adder was called, and then make x take on a different value
in the context of each copy.

Maybe somebody could show me how to do it using contexts?

-galt







[REBOL] NETSCAPE vs EXPLORER... CGI problem solved! Re:(3)

2000-07-10 Thread Galt_Barber




Hi, Ralph!

You could make better use of lists in Rebol.

order: join "https://abooks.safeserver.com/cgi-bin/bookord.r?title=" title
order: join order {author=}
order: join order trim author
order: join order {isbn=}
order: join order trim isbn
order: join order {pub=}
order: join order trim pub
order: join order {price=}
order: join order trim price

This bit about using "order: join" repeatedly is a good clue.
That's one of the great things about rebol list syntax.

order: join copy "" [
 https://abooks.safeserver.com/cgi-bin/bookord.r?title=" title
 {author=} trim author
 {isbn=}   trim isbn
 {pub=}trim pub
 {price=}  trim price
]

I didn't actually test it, but it should work, or something very similar to
this.
It's roughly right, for sure, and still easy to read.

Cool, huh?

-galt





[REBOL] text file changes Re:(2)

2000-07-10 Thread Galt_Barber




With 500,000 rows in the file,
you may want to just read the rows one
at a time.  This might take some work.

Rebol is good at gulping everything all at once,
and computers are pretty fast and have lots of ram,
but for really big data that approach chokes like a dog.
You should also be careful about writing and testing
on toy size data because it might fail to scale.

good luck!

-galt




From: [EMAIL PROTECTED] on 07/09/2000 11:16 PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:(bcc: Galt Barber/LearningTree/US)
Subject:  [REBOL] text file changes Re:



At 03:59 PM 7/10/00 +1000, you wrote:
hi all
just need a little help with something..
i am trying to change all returns in a text file to tabs

file: read %some-filename.txt

replace/all file "^/" "^-"

and then change
every occurence of ZZZ to a returnis this possible?

replace/all file "ZZZ" "^/"

i am on windoze 98se.the file is about 12mb with about 500,000 records.
i have checked the user guide but couldn't get anything out of it regarding
this sort of thing

thanks in advance
keith




;- Elan [ : - ) ]










[REBOL] func[func] Re:(6)

2000-07-10 Thread Galt_Barber




Ladislav,thanks for pointing out highfun.r!!!

It sure is interesting that make-adder works with the old Rebol 1
but not with the newer ones.  What exactly did we lose?
What work-arounds are feasible?

I assume that the change was some deal with the devil that
RT made for more speed.  Still, it would be nice to know how
the system is doing things internally, descriptively at least.
Where is the clear explanation of context and so forth?

I remember a while back somebody was asking for a something like a whitepaper
on the language and at the time people either denied it's usefulness, or claimed
it would take
important developer time away from improving rebol so it couldn't be
written, or that nobody there seemed to understand the request.

Andrew initially defended the lack of such documentation in taking the position
that
nobody else documents their crap, you just have to fool with it till it works,
like every other system we've all had to get working.

Except that Lisp and Pascal and many others are in fact very well described.

And really we are talking here about the core functionality of the language,
not trying to get Rebol to cough up source code nor to dwell on the details of
the implementation of web protocols.  We just want to know how to think
about the process so we can write correct programs based on understanding.

I still don't even use parse for any but the simplest things.
If I had a burning need that nothing else could satisfy I probably would sit
down and grind through the details, but short of that I may never go any deeper.
The examples available for parse are certainly better today than they used to
be,
but they are not that easy.  This really means that only expert users with a
penchant for playing with parse will get much out of it.  Regular users will
merely boggle.  I suspect however that it is actually possible to document
parse better so that more people would be able to make it over the hump.

Please chime in, everyone!

-galt








[REBOL] func[func] Re:(6)

2000-07-10 Thread Galt_Barber




Jeff and Brian, you guys are terrific help, and I really
appreciate it.  Hopefully some of the other people
on the list have the same questions as me and are
benefitting from your wisdom, too.

Brian, one little interesting point, as you may have
seen from Ladislav's generous note:
---
 Did this used to work in an older rebol without compose?

Here you are:

REBOL
1.0.3.3 (Win32 x86)
TM  Copyright 1998 REBOL Technologies Inc.  All rights reserved.
Send bugs to [EMAIL PROTECTED]
Loading internal rebol.r
REBOL top level.
 make-adder: func [x] [func [y] [x + y]]
#[function [x] [func [y] [x + y]]]
 add5: make-adder 5
#[function [y] [x + y]]
 add6: make-adder 6
#[function [y] [x + y]]
 add6 1
7
 add5 1
6

So, it did used to work in an older Rebol.

--


One reason I was thinking the context was bound
to the block had to do with a vague memory of a something
posted a long time ago.

So, is it safe to say that a context is associated
only with a word?  Or is a word assoc. with a context?
Or only words that are functions are associated with
a context??  Does each function have one context?
What about dynamically generated functions not referred
to directly by assigning to some 'word  ?  Do these
automatically have a context, too?  Is rebol's use
of context similar enough to another language out
there that I could get some good guidance by referring
to that language's documentation/literature ?

-

Thanks! to everyone on the list who has been helping me
out here with getting a better understanding of Rebol.
I am going to print out those notes to study them better.

-galt






[REBOL] New REBOL Manual Re:

2000-07-10 Thread Galt_Barber




Yes, Carl, that new manual will really be valuable!
Thanks!

-galt





[REBOL] func[func]

2000-07-07 Thread Galt_Barber




 make-adder: func [x] [ func [y] [+ x  y] ]
 adder1: make-adder 6
 adder1 5
== 11

This is way cool.

But now, this doesn't work.

 make-adder 6 5
== 5
 (make-adder 6) 5
== 5
 ((make-adder 6) 5)
== 5

I sort of understand that.

 do make-adder 6 5
== 11

I guess that's the way.

-galt






[REBOL] Find speed Re:(2)

2000-07-07 Thread Galt_Barber





Eric wrote:
==
Hashes seem to be particularly slow when searching for nonexistent key
values. For 100,000 searches:

  loop 10 [ if select z "1533695" [x: x + 1]] ; first key value,   0:02
  loop 10 [ if select z "501730" [x: x + 1]]  ; 5000th key value,  0:53
  loop 10 [ if select z "1533696" [x: x + 1]] ; non-key value, 1:41
=


Well, how would it compare to find?
It looks to me like it's doing a linear search like find.

plus have you plugged select back into Ladislav's code to see
if it was any faster really?

this ought to be brainless.  What are we doing wrong on these hashes?

-galt





[REBOL] Find speed Re:

2000-07-05 Thread Galt_Barber




Ladislav,

your binary search code (bfind) runs faster than find,
but find works on unsorted data, so it's not optimized that way.

Hashes also dont work well with sorted data, they are great
for finding you a person given a social security number,
but hashes are not good for walking a list of people
in order by their ssn or name.

So I am not surprised that your bfind runs faster than find.

Do you think RT should add /ordered or something to 'find
when the data is pre-sorted so that it could use binary search internally?

If you want to create really really fast large capacity data
that is fast to search and insert/delete/modify and also be
able to walk in say order of the key (e.g. lastname), then
you will probably end up using B+ trees with nodes made of blocks
and use your binary search or something like it to search individual
blocks for nearest key match.

When you try to stick everything in one block eventually you will
hit a point with larger data where rebol is having a hard time with
a single block (unless rebol is more clever than I think and more clever
in this regard than any language I have ever seen).

I mentioned something about this awhile ago but there seemed to
be little interest in it then.  I suppose many people would say that
for large systems you need a multi-user, transaction protected,
database system like Oracle$$$ or MS-SQLServer, etc.

---

By the way, Tim mentioned ODBC access to his database C/Mix (?).
Well, the c++ source is going to have access to odbc dlls and stuff that
Rebol/Core and /View will not be able to do.  And command will probably
have ODBC built right in, so ...

-

Also, people are recommending re-writing the database code in Rebol,
which is fine I suppose.  One might want to choose new datastructures
which are best for rebol, but if his goal is file-format compatibility, then
he will not be free to change the data structures on disk, which may
make certain Rebol optimizations impossible.

If Tim just wants to make a single-user database that his web-app uses
to store data for itself, then he probably could implement something
decent that works without having to port the entire functionality of this
commercial product which is probably loaded with extra stuff he doesn't need.

For most purposes, you can get away with a minimal system employing
fixed-length records and an index of some kind for speed.
Given that, you can do most basic things you would need.  Even writing a little
db engine that did that much would take you a while, but it would be a lot
easier than porting hundreds or thousands of pages of c-code.



Concerning the copyright of the commercial c-code,
As far as I know, even if it is a translation to another language, the copyright
of the original is maintained.  This is certainly true of books.  If you
translate
The Little Prince to Cherokee or some other language, the original author's
copyright still exists and you won't be able to sell and distribute the
translated
version without permission.  Your work as a translator is itself still
protected, too,
I suppose, but that doesn't negate the rights of the original author.

--

So, if you decide to make your own db engine, what features do you
absolutely have to support?  Remember each one is going to cost you!

By the way, can I really open a very large file in Rebol without buffering and
jump right to anywhere
in the file and change some bytes?  It seemed like it didn't work for me the
last
time I was checking that out.  I either got buffering I didn't want or else I
couldn't skip to anyplace in the file.  It seems like most OSes must certainly
support random file access.  Does rebol have a problem with this?

-

-galt







[REBOL] Find speed Re:

2000-07-05 Thread Galt_Barber




Hi, Ladislav,

if you are interested only in an associative array,
then a properly implemented hash should beat the
hell out of even a binary search on large data.

I guess it depends somewhat on the quality of the
hash function and other aspects of the implementation.

So, if you can beat the Rebol hash, which is probably compiled
c-code, with your binary search written in interpreted Rebol,
then RT had better take a look at their Rebol hashes.

Would you like to share some test source code with us
so we can try to duplicate and analyze your results?

Thanks!

-galt

p.s. Does memo-ize only make sense when there are a limited
number of possibilities for the parameters?  If the space of possible
values is very large and requests could come in a sort of
random or rarely repeating way then the memo-ize trick wouldn't
do much good, would it?





[REBOL] REBOL/Core 2.3 Released! Re:(2)

2000-06-28 Thread Galt_Barber




T





[REBOL] REBOL/Core 2.3 Released! Re:(2)

2000-06-28 Thread Galt_Barber




Core 2.3 update:
Thanks!

-Galt

p.s. When is a fix for the /view focus problem going
to be available.  I stopped checking out /view in depth
when I hit that.





[REBOL] igpay atinlay Re:

2000-06-26 Thread Galt_Barber




do people say "ingthay" or "hingtay





[REBOL] Return From Middle Of Script? Re:(2)

2000-06-26 Thread Galt_Barber




There are some programs that actually work quite nicely
with goto or multiple exits, and the code is actually much easier to read.
I am not saying that they are good to use all the time, but I can make
a pretty strong case that they are not always the inferior solution.






[REBOL] open/direct not working right? Re:(2)

2000-06-22 Thread Galt_Barber




 o: skip o o/size

Thanks to everybody who suggested this.

But I am pretty sure I was already doing that
and it just behaved as if the skip never happened.
I didn't know if it was a bug or not.
Does anybody else want to try this?

To test it out, you have to open/direct on a file
that already exists and has some stuff.
Then try to skip to the end and append some stuff.

I guess the appended stuff will really be placed
at the beginning of the file, not the end, as
if the skip didn't have any impact nor error.
Seemed weird, which was why I wrote the msg
in the first place.

Then I had gc problems
just using write/append which I got around using
recycle/on, so eventually I did reach Mt. GigaJunk,
but the trek was tougher than expected.

-galt





[REBOL] forskip??? Re:(4)

2000-06-22 Thread Galt_Barber




Rebol [
]

audio: read/binary %/j/audio/first.au

forskip audio 2 [
  write/append/binary %/j/audio/firstdone.au to-char audio/1
]

Did somebody want the slowest audio program ever written?
Why not open the file once instead of for every byte?
Basically it looks as though you are keeping every other byte,
are you picking out just one track to go from stereo to mono?

I haven't tested it, but something like this ought to be a little faster.


Rebol []

audio: read/binary %/j/audio/first.au
newstuff: copy []

while not tail? audio [
  append newstuff first audio
  audio: skip audio 2
]
write/append/binary %/j/audio/firstdone.au newstuff


Does everyone like the word 'first ? It seems less than intuitive.
First what?  It's not really the first element in the list.
I know we can create our own words to alias 'first, but most
people won't do that and it makes it harder for others to read, too.

Also, having to say stuff like
   list: next list
is too bad.
Wouldn't it be nicer to have a syntax like
 list/next
 list/value
? That seems kind of nice.
list/value would return the same as "first list", and
list/next would be the same as "list: next list".

And speaking of understanding grammars,
You're = You are.   E.g. You are what you are.  You're my little bundle of
joy.
Your = possessive, e.g. It's your life!
Try this one:  You're your own best friend.

And if you can't remember which is which, just go phonetic: Yor.
At least that way people will not assume anything other than the sound.

- - -

Mu-law is pretty cool, and is used in many .au files.
I just found out about it the other day.
Some call it companding, like compression+expansion, but that's bull.
It's really just using a non-linear representation of the amplitude of the
sound wave, which is way cool, because that's the way all your
natural senses work anyways.

Because it uses a logarithm of the
amplitude, you can multiply easily just by adding (think mixing level)!
But adding itself (mixing two or more channels into final output) is made more
complex.
Also, I think some internet phone systems use Mu-law type companding,
as it adds more dynamic resolution and just sounds better without requiring
more actual bits.  You are not compressing any actual information, though.
It's not lossy.  You are however making better use of the bits so that what
the bits represent is a better match in value to your sense of hearing, e.g.
you can distinguish soft from very soft easily, but loud and very loud sound
pretty much the same.   Vision works in a similar fashion with brightness
levels.
You can see in near darkness but blinding light and twice-blinding light mean
nothing to you.

Most cameras that people buy don't perform well in low-light conditions.
You see the film coming back from the lab either black or all washed out
at light levels your eyes handle easily.  Sure, you can see a distant nebula
with long-exposure film in a gigantic telescope, but try taking that on
vacation.

- - -

By the way, how many lines of c code does it take to do this?:
   read http://www.rebol.com

And does that code run on 37 platforms without recompiling anything?

To me, the fact that I can't count an integer from 1 to 100 in an empty loop
is of no interest.  Plus the hardware coming out these days is amazing.
650 Mhz Wintel box is cheap.  Fry's has 13GB drives for $89 each.

What I want to know is what are you going to do with that hardware?
If you have rebol, you might be able to deliver a great program before you
are eligible for social security.

In fact, you could write a rebol program that
would assemble a binary executable for you if you really want to count
at the speed of the hardware.  Has anybody written any assemblers
entirely in Rebol?  It would probably turn out to be incredibly short, easy
to read (and write!) code.

Oh, and Rebol is certainly available at an attractive price.






[REBOL] Ping Tool Re:(2)

2000-06-22 Thread Galt_Barber




I believe I saw an example of doing Ping from rebol somewhere.
On the rebol site?  In the rebol examples library?  Submitted scripts?
/View stuff?  other sites that have rebol code submitted?
Well, anyway, it's worth looking around.  If I come across it again,
I'll send a msg to the list.





[REBOL] How's this for frustration... or...NT/CGI/mail prob solved... Re:(4)

2000-06-22 Thread Galt_Barber




should 'protect-system be the default for Rebol,
so beginning users don't hurt themselves?
I am surprised that so few problems have been
reported given the number of elements that must
exist in the system.  I myself have used the word
'query when writing sql code.  I suppose the only
reason I didn't choke on that was that I remembered
to declare it as a local var so when the func was
done the original global 'query was still ok.

-galt





[REBOL] typing it again Re:(4)

2000-06-22 Thread Galt_Barber




n-str: func  [
c [char! string!]
n [integer!]
/local
 s
][
either char? c [
 s: to-string c
][
 s: c
]
return head insert/dup copy "" s n
]

 n-str "t" 3
== "ttt"

 n-str "tab" 3
== "tabtabtab"

 n-str tab 3
== "^-^-^-"

 n-str #"t" 3
== "ttt"


n-tab: func  [
n [integer!]
][[integer!]
return n-str tab n
]


-galt





[REBOL] Optional Arguments Working? Re:(9)

2000-06-22 Thread Galt_Barber





print-val: func ['val [any-type!]] [
  print either unset? get/any 'val ["No value given"] [get 'val]
]

 print-val 1234 print-val print "DONE" print "WHAT?"

how about this?

print-val 1234 (print-val) print "DONE" print "WHAT?"

will that stop the greedy parser from grabbing the next item?






[REBOL] View equation solver Re:

2000-06-22 Thread Galt_Barber




f(x)=0,
thanks, Phil, that was fun!

can we get a graph with that?
-galt





[REBOL] Rebol for the world - in what language?

2000-06-22 Thread Galt_Barber




What are plans if any for dealing with non-european
character sets?  Many things are already out there
like Multi-byte schemes and Unicode.

What if anything does RT want to do to deal with the
need for internationalization?

Is there a problem as well because not every platform
Rebol ports to has Unicode support, etc.?

What about fonts in /View?  If I want to use a particular
font, is there a universal font format yet that will run on
all platforms?  Can I create one and ship it with the code?

Even non-vector non-scalable fonts would be better than nothing.
I suppose you could turn them into lots of little bitmaps and
stick them all in a little gif file and write a routine to blit chars
onto the screen from the font.gif for that, but yuck!

Ever curious,

-galt

p.s. I looked in the bookstore here in Santa Cruz for rebol books
last weekend but there didn't seem to be anything.
What should I be seeing about now?





[REBOL] A data inconsistency Re:

2000-06-19 Thread Galt_Barber




Probably by now somebody has already answered this,
but I will share what I discovered.

Ladislav wrote:
=
did anyone report The following?

 head insert copy [] ()
== [unset]
 change copy [1] ()
** Script Error: change is missing its value argument.
** Where: change copy [1] ()

=

well, anything in parentheses () will be evaluated immediately
before any function receives the parameter.
If you just type () at the prompt, it returns nothing.
Bu if you do type? () it says unset!

 ()
 type? ()
== unset!


So, you are trying to insert an unset! value into your copy [], an empty block.

I assume the same thing is happening to the change example.
If you are trying to create an empty parenthesis block, then I don't
know off the top of my head how that would look of if it would work.

-Galt





[REBOL] A data inconsistency Re:(3)

2000-06-19 Thread Galt_Barber




 Ladislav wrote:
 =
 did anyone report The following?

  head insert copy [] ()
 == [unset]
  change copy [1] ()
 ** Script Error: change is missing its value argument.
 ** Where: change copy [1] ()

 =


 ()
 type? ()
== unset!
 copy [()]
== [()]
 compose copy [()]
== []
 first compose copy [()]
** Script Error: Out of range or past end.
** Where: first compose copy [()]

well, compose seems to turn () in a block into literally nothing, not unset!,
so which do you think is right, the insert that sticks an unset value into the
block,
or the copy which refuses to change 1 to nothing at all?

Is there some great use to having unset in a block ?

Or were you just saying the two should behave consistently but don't?

-galt





[REBOL] open/direct not working right?

2000-06-19 Thread Galt_Barber




Hi, I tried to do this:
%waste2 is just about 3 megs of junk data.
I want to build %waste, a file with about a gigabyte of junk.

x: read %waste2
o: open/binary/direct %waste
for i 1 300 1 [
  insert tail o x
]
close o

when I do this, the file doesn't usually grow.
If it does, it always starts from the beginning as if the
"tail o" part were ignored.  Is this just how /direct works?
Why can't I seek to the end of the file and just append
some data without some buffering getting in the way?
If I don't say direct then rebol tries to buffer the whole file
as a series, and needless to say crashes or says out of
mem, etc. on large data like this.

I finally discovered write/append but why can't I work with
the file as a series properly?  My OS is NT and it certainly
has random access to any part of the file, just as any
part of the series, so you should have no trouble mapping
the rebol series operations to the OS file operations.

Has anybody reported this problem?
I discovered it using /Core, have not tested /View yet.

Thanks,
-galt







[REBOL] Resume getting a web page? Re:(3)

2000-06-16 Thread Galt_Barber




dear ddaley,
one thing that helped me get a big file via http last week
was to set the timeout, both the default and the http,
like this, if memory serves:

 system/schemes/http/timeout: 9000
 system/schemes/default/timeout: 9000

9000 is just a big number.  Never tracked down exactly what the units are.
the /http/timeout is none by default whatever that means.
the /default/timeout is 30 by default.

plus, to be a good citizen, you'd probably want to save the original timout
values
and restore them after you are done with the download.

Then I was finally able to read the whole file without Network Timeout.

I hope this is relevant to you...

galt





[REBOL] pseudo-globals? Re:(2)

2000-06-16 Thread Galt_Barber





r: make object! [
result: system/words/result
x: func [] [system/words/x result]
y: func [] [system/words/y result]
z: func [] [system/words/z result]
append: func [str] [system/words/append result str]
]

do bind [
x
y
z
append "stuff"
] in r 'self


Regards,
Gabriele.

Gabriele, you are one sharp cookie!
I always find myself saving your messages,
as they are chock full of superb thinking about Rebol.

This is a very good demonstration of using bind!

That's exactly the kind of thing I was looking for,
Bella!

-galt

p.s. Is there any way to do the same thing, even if
"result" were a local var and not global?

Also, I have 7 functions, and I would need to do this trick in each one.
Is it possible to create some other routine outside the 7 that sets up
the aliasing and then just refer to that function at the top of each of the 7?
It seems like this might be possible!
I can hide the unnecessary bits and without Global vars and so recursion is no
concern ?
Astounding.





[REBOL] Resume getting a web page? Re:(5)

2000-06-16 Thread Galt_Barber




no problem, but it took thirty seconds.

 x: read http://www.edreyfus.com/cgi-bin/cgipage?TAG=03MKTW+sp500fc

 length? x
== 638741


-galt





[REBOL] can't explain Re:

2000-06-16 Thread Galt_Barber




Tim,

you had this something like this:

command1: [print "doing command 1"]

do rejoin ["command" command]

try this:

do to word! rejoin ["command" command]

or this:

do do rejoin ["command" command]


your earlier equivalent was basically the same as this:
do "command1"

which is apparently not the same as this
do command1

do "command1"
is just enough to fetch the value of command 1, which is a block,
but that block is not required to be interpreted immediately, you see.

By turning "command1" into a word first, then the automatic parameter fetching
of a word
will grab the block and pass it to do.  So in that case, do never even sees the
actual
command1 word, it just sees it's reduced value, the block, and executes that.

If command1 had been defined as a function instead of as a block, then the
automatic running of it would have been seen even with the way you were doing
it.

It's sometimes hard to remember when you are working with Rebol
that all this parameter evaluation is going on automatically.

For instance, print doesn't just print the value, it evaluates everything first,
and then
prints that.  You have to use probe and "get" into the "words" a bit to really
see
more behind the scenes.

Basically, if command1 had been a function instead of just a block,
you would have succeeded.

Check this out:

 do "print {hello}"
hello

this works because print is itself a function, not a block

 do "[print {hello}]"
== [print "hello"]

this doesnt work by itself because a block is just a block,
which is returned as the result of doing the string.

notice that you would have gotten exactly the same result
by just typing the block at the prompt:

 [print "hello"]
== [print "hello"]


but these work:

 do do "[print {hello}]"
hello

do "do [print {hello}]"
hello

Even when you type stuff in at the command prompt, rebol is "do"-ing that,
so it gets reduced and evaluated.

And bizarrely enough for the beginner's perspective, one of the main jobs
of brackets is to suppress evaluation, e.g. here's the code, but to be run
LATER,
and not evaluated immediately.  In your original example, the block value
of command1 or command2 is fetched, and probably even bound and
ready to go, but you didn't tell it to do that resulting value...

notice that had you just typed this, it would amount to the same thing:

 command1
== [print "Doing Command 1"]

See, it's fetched, but not executed.  But it is ready to rock.  Just do that.



Rebol, is of course nearly a human language, and therefore easy to understand.
;-)

You have to admire the flexibility here, though.  You just invented code on the
fly.
Beats the heck out of most languages right there.  The only others that can
really
do this are things like Lisp and Scheme and Smalltalk, too, I believe.
Java won't really do it, will it?  Anybody?

-galt






[REBOL] pseudo-globals?

2000-06-15 Thread Galt_Barber




I have some routines where it references the same
string over and over and over.

e.g.

somefunc:  func [
   someparam [string!]
   /local
   result  ;  [string!]
][
 x result
 y result
 z result
 append result "Blah"
 { etc. ad nauseum }

 return result

]

And I noticed that I was using "result" as the first parameter
passed to nearly everything.

Well, your first thought is that maybe you ought to make
result just be a global variable.  But not only does it
go against one's training and experience, but
in fact I actually have a case where somefunc calls somefunc2,
a routine that does something similar, and that would mess
me up.

So, how do I have a sort of almost global variable in the sense that
I can set it and then have all these functions know about it without
having to pass the darn value all around to everyone of them?
It gets tedious and one hopes that an advanced language
like Rebol might have some tricks to cure this ailment.

It reminds me a little bit of execution-scope?  where the scope
is defined by the block where it is first defined (or  redefined)
and then any funcs called after that see the var bound to the
new value, but then when the original block that had redefined
it goes out of scope then the older original value is restored
automatically.

Can some clever use be made of bind and objects in some way?
Can new instances of the functions be made and the words
in the procedure bound to them?
e.g. bind x,y,z to this "result", or bind copies of them?

I thought already about creating an object which has a layer like
this:

r: make object! [
 parm1: result
 xx: x parm1
 yy: y parm1
 zz: z parm 1
 aappend: func[ str] [append parm1 str]
]

and then going like this
r
r/xx
r/yy
r/zz
r/aappend "stuff"

but then I thought that it's only slightly better, and still not ideal.
what would be really cool is a way to bind x, y, and z
so that I don't need any extra clutter, so my code would just be
x
y
z
append "stuff"

and all these operations would happen on "result"

Does anybody have any idea what the heck I am trying to get at?
I hate seeing oodles of functions where the same stupid parameter
is passed over and over and over and over up and down thru the
various levels, never changing, just getting passed again and again and again,
and sometimes not just one but several.  Ick.  This situation must
be very common.

When we speak in human languages, we
often introduce a subject or topic and then it's understood
that we are referring to that until we say otherwise.
Computers are very precise, but only through tedious programmer
effort.  The obvious stuff shouldn't have to be said, said, said, said.

?

-galt





[REBOL] Andrew, you beast!

2000-06-15 Thread Galt_Barber




REBOL [
Title: "Andrew, you beast!"
File: %test3.r
]

rf: func [
][
 do %test3.r
]

O: make object! [
f1: func [] [print "F1."]
f2: func [] [print "F2."]
set 'Dialect func [blk [block!]] [reduce bind blk 'f1]
print
{
Amazingly, you can put any code in the object and the darn stuff
will just get executed when the object is creation code is executed.
Otherwise you wouldn't be seeing this message now.
Of course when you create an object by simple cloning
of another object you probably don't get this
execution side-effect.

Notice how Andrew had previously named blk
as Dialect, which was certainly confusing
but as far as I could tell didn't add to
the understanding.

However, he has to use "set 'Dialect"
instead of simply having  "Dialect:"
because he doesn't want Dialect hanging
around as another element (method) of the object,
but in fact wants Dialect to be a global critter
accessible outside the object later.

Notice that because
F1 and F2 are functions they will be
automatically executed when they are reduced.

What all this has to do with dialects exactly is
still abit unclear.  I suppose it means you
can bind a block to another block or word
and it will share the context of that other
block.  I wonder what would happen if you
unset O at this point.  Could you still
run Dialect and have it bind and reduce another block
to what O was bound to?
}
]

;--  just a side-track

OO: make O []   ;-- notice you dont see all that text repeated again now.

unset 'OO;-- just to keep it from being a distraction

;--  the main enchilada   (anyone hungry?)

B: [f1 f2 f1]

Dialect B

print "-"

;--  more derring do

unset 'O

C: [f1 f2 f2 f1]

Dialect C;-- that ol' abracadabra still has some magic left in it.

halt





[REBOL] pseudo-globals? Re:(2)

2000-06-15 Thread Galt_Barber




Thanks, Thomas J, I am looking over your globalizer code now!!





[REBOL] pseudo-globals? Re:(2)

2000-06-15 Thread Galt_Barber




I asked if anybody knew clever tricks to avoid passing
the same paramters over and over and over.

Allen reminded me,
I had forgotten about the syntax of system/words/varname.

Thanks, Allen K!

===

Just for an experiment, I made a copy of the source file in question
and used that to butcher it about a bit until I had some interesting results.

I am creating several functions, one for each of the 7 tenses in Irish.
Each does similar things and calls similar functions to change
the root word until it is fully conjugated.

I noticed that when I had condensed it down earlier, I had gotten to
a bunch of lines that looked like this:

somethinga result
somethingb result
if firstperson? somethingc result

etc.

So, I went back and I looked real hard at the alternatives.
I wanted the Rebol code to look as much like english as possible,
in the sense that the routine for each tense would be able to
be followed by someone interested in the Irish rather than
in programming, it should look almost like a (normal-)human readable set of
steps for conjugating any tense of an irish verb.

I was willing to hide the complexity in some functions,
as long as each function was ultimately a simple idea that
the language user would recognize.
e.g. "lenition" is a process that in modern standard adds an  'h' after
allowable consonants.  So I hide the testing of lenitable? and
so forth and just show Lenite Result.  e.g. ball lenited becomes bhall.

Well, I wanted to get rid of "result", and the only way I could figure it out
was to just make the darn thing global, now called "conj".
 Then I found that wasn't so bad
after all!  the code was a lot shorter and cleaner.  There was only
one place where you could effectively cheat and get the result
from calling another tense, and I figured I could deal with that if I had to,
by saving the 'person and restoring after the call.

It worked extremely well.  The seven main tense functions and the assorted
helpers now just use a bloody global variable, and the thing is ridiculously
simplified.  In the same spirit, the 'person doesn't change during a run
of the conjugation, so I made it also global and used by the main 7
and their helpers.   I basically had originally had 3 parameters and 2 local
variables defined at the head of each main function before.  Now there are none.
I used to have some lines of subtle tricks at the top of each of the 7 main and
a return line at the bottom, which certainly would distract the non-technical
person, so I yanked them out, too.

To make a long story shorter, I basically scrapped all the usual way of
paramaterizing
everything - and felt like I was doing "non-functional" programming, almost.
Back to my earliest days of basic without sub routines or parameters, almost.

I thought that the code would be a mess, but in fact it's shorter and more
comprehensible both to myself and to anyone else now.  Weird.

And although I now have to be careful about calling it recursively
and be more careful about stepping on the global value, it seems
like it may be worth it.  I am never really going to call these functions
recursively in a serious fashion.  I have one case where the Imperative
is constructed by calling other tenses, but it only goes one level deeper
and comes back.  There's no indefinite levels of recursion or anything like
that.

I feel like I am regressing here.  Anybody seen GOTO lately?

In fact, if it were possible to write a source code analyzer that could
warn you of potential problems, you might be able to let it tell
about the few issues there really are with clobbered variables
and fix them, rather than adopting the typical generic approach which is so
wasteful
of the programmer's and the computer's time.

I will include just one of the tenses here for comparison:

"sinn" means "we" in Irish
"fear" stands for the autonomous case, like in english "something was done" by
who?, not specified
"áil" is a special ending to be dealt with, and so is "éigh"

= original, before tried to condense it 

FutureTense: func [
 root[string!]
 person  [integer!]
 plural? [logic!]
 /local
 result
][

 result: lowercase copy root

 if matchtail result "áil"
  [remove skip tail result -2]

 if matchtail result "éigh"
  [remove/part skip tail result -2 2]

 append result "f"

 either (= 1 person) and (plural?) [
  if broadending? result [broaden result]
  append result "imid"
  ;-- handle 2nd Conj.
  replace result "ighf" "eó"
  replace result "aeó" "ó"
 ][
  either  0 person [
   if broadending? result [broaden result]
   append result reduce ["idh " make-person person plural?]
   ;-- handle 2nd Conj.
   replace result "ighf" "eó"
   replace result "aeó" "ó"
  ][
   if narrowending? result [narrow result]
   append result "ar"
   ;-- handle 2nd Conj.
   replace result "ighfe" "eóf"
   replace result "aeó" "ó"
  ]
 ]

 return result
]



=  before, after I had already worked alot to condense it 

FutureTense: 

[REBOL] oops, I have the answer to my own question, I guess!

2000-06-14 Thread Galt_Barber




somefunc: func [
  'param [word!]
][
 ; do stuff with param
]

Well, it turns out that instead of the awkward expression like
   do reduce [:somefunc someword]

I can simply use this:
  somefunc :someword

I had never used the : with anything but the word for a function,
not a word for another word.

It gets the value without evaluating it further, and for some reason reduce by
itself
doesn't do that:
  somefunc reduce someword
Oh, I see!  The word 'reduce is itself being passed without evaluation!
Wild !!!

-galt

Thanks to any of you who are busily composing the answer to my last question!





[REBOL] restart in FTP and HTTP Re:(2)

2000-06-13 Thread Galt_Barber




Thanks, Julian!  Yee-hah!





[REBOL] re: uppercase and lowercase

2000-06-13 Thread Galt_Barber




uppercase and lowercase work apparently only on any-string.
But it's too bad it doesn't work on character.
You can do a string or a filename, but not a single character.
You can write a lower-char function that converts the char
to a string then do lowercase then convert back to char again,
but it seems a bit wasteful and unnecessary.

I submit that making these functions work on a char and return a char is
a useful and reasonable thing.

Comments?

galt





[REBOL] weird behavior of /view Re:(2)

2000-06-12 Thread Galt_Barber




Thanks to Gabrielle and the other nice folks who
explained the "close upon script end" behavior of /View!
-galt





[REBOL] list values and series operations ... Re:(2)

2000-06-12 Thread Galt_Barber




List!s are actually stored differently from blocks, paths and hashes,
so any operation on them requires special code that has not been
implemented for all action types.
  - jim

It makes sense, of course.
If you need random access by position number then don't use a list.
That is almost by definition. Use a regular block instead.

Lists are I am guessing very efficient for certain algorithms requiring
rapid insertion/deleetion and sequential access only.
Since blocks are pretty fast, you would only need lists for
getting the extra performance boost in some critical code with certain
algorithms.
Maybe the list also uses slightly less storage overhead per element?

I doubt that the "special code" he refers to would be hard to write,
it's just that it would be slow as hell, you would for instance get
the 352nd element by starting at the head of the list and skipping
down 352 times.  Real Fast, eh?  That's why you don't even
want to do that.

But think about implementing a fast stack, where you insert or push an
object at the head of the list and pull or pop it also from the head.
This is one job that a list can do really efficiently.  I am sure
others can think of more.  I don't know if we have fast access
to the tail of the list also.  Normally one would assume that
reaching the tail would be slow unless a pointer is kept to it
specially.

Basically, if you can't imagine why you would need a list,
you probably don't need one.






[REBOL] hiccups in the stream

2000-06-12 Thread Galt_Barber




Hi,

I was just trying to do this
x: read some-url
and it gets hiccups in the stream every so often and timeouts.
Is there a way to extend this timeout default so that it tries
a little longer?
I noticed that when I just put the url into the browser it seems
to make it through the download.

The file is a bit large, several MB, but FTP is apparently not
an option at this time.  I do not know if it is my gateway to the
internet that is getting congestion or whether it is on the server
where the file resides, but either way there is little I can do
about the connection quality.

Thanks for the assistance,
-galt





[REBOL] downloading big files

2000-06-12 Thread Galt_Barber




Again, if there is no ftp available
but the file is there as http:/something
and you want to page it out to the disk
as it comes in because it is so large,
what does the code look like for that?
Do you still use read?  Do you need use open?
Do you need to open the port directly and
make a Get request or something for that url?

Thanks for your time!!

-galt





[REBOL] downloading big files Re:(2)

2000-06-12 Thread Galt_Barber




Sterling,

I spoke too soon, I still got a timeout!

 go
url= http://www.grafxsource.com/RnaG/6-3-00-Caitlin-45.rm
** Access Error: Network timeout.
** Where: data: copy a





[REBOL] re: downloading big file via http

2000-06-12 Thread Galt_Barber




url: http://www.someserver/somefile.rm

 http: open/direct/binary url

 print "http opened."

while [true] [
  w: wait [http]

{more code here}

]

it fails on the w: wait[http] line. why?
wait works on a tcp port, I know that from another project.
  Does wait not work with an http port?

---

I ran the url through my IE browser and it never timed out,
but you could watch, after about around a megabyte of data,
the download rate would plummet as if the server basically
lost interest in the request.

Then, I found that after cancelling, when I requested the same
url, IE was smart enough to just resume where it left off.
Well, it took about 20 re-tries, but I eventually got the 14.3 MB file.
Now, don't tell me you are going to let IE lick you!

How can I do the same thing (dowload the whole file) in Rebol?

is there a way to specify restarting a download in Rebol http?

is there a way to set it so it won't timeout?
Note: the timeout is actually on the client side,
because IE never times out...?

--

The file I am trying to download is

http://www.grafxsource.com/RnaG/6-3-00-Caitlin-45.rm

It's basically a capture of a couple of hours of Irish radio.

-galt






[REBOL] downloading big files Re:(4)

2000-06-12 Thread Galt_Barber




Larry, that was awefully nice of you check out the download !!  Thanks!

I saw the way to set the default timeout from your script.
I found that the default was 30.  30 what, I don't know,
but it sure isn't 30 seconds, unless that's the entire time
for the entire file, rather than the amount of time to wait
with no action, before giving up???

I have a slow connection - some sort of shared packet-thingy
that runs around as fast as a 56k modem, even though it's
supposed to be twice that fast.  In any case, I upped the
timeout to 90, which is three times as great and it still failed,
but it did get a lot further.

I am now setting it to 900 like this,

system/schemes/default/timeout: 900

And it's still running right now.

Can it be set to 0?  If you do that and it really is hung,
can you break out of it with the escape key at the console? (I guess so?).

Oh, and can't you use wait [port]  on a port opened on an http:// url?

-galt





[REBOL] re: big http request

2000-06-12 Thread Galt_Barber




I have just gotten the timeout error with the default set to 900,
set it to 9000, still got it, set it to 0, still got the timeout error.
Shouldn't setting it to zero get rid of the problem?
Well it didn't.

Although I got as far as 11mb once, I have still never got
the whole enchilada with Rebol.
Sure, I could have a better connection, but it works fine
for everything else, and it's no slower than the typical
home user enjoys.

galt





[REBOL] weird behavior of /view

2000-06-09 Thread Galt_Barber




If I go to a command prompt (NT), in my rebol/view directory,
I can run rebol.exe and it comes up on console window with rebol-prompt just
fine.

If I make a little test.r file that looks like this:
Rebol [ ] print "test!"
and then run it from the command line like this:
rebol test.r
I get a barely-perceptible flash like the window opened and shut real quick and
then nothing.

If I switch over to the rebol/core directory and do exactly the same thing, the
test.r
runs and the console window is open saying "test!" at the bottom just fine.

I have even deleted my .r association in file-types and anything else
I can think of like that but to no avail.

I tried looking at user.r and turning the demo setting on and off but it was no
good.

What the heck is making /View behave in this odd way?
I will try re-booting again, but I doubt it will help.

I can of course just manually execute the rebol.exe file and then
in the console window manually type in do %test.r, etc. , but that is surely a
drag.

-galt

Thanks!

p.s. Everything was working fine yesterday, oddly enough.






[REBOL] weird behavior of /view Re:(2)

2000-06-09 Thread Galt_Barber




 paraphrasing: add halt to end of script to stay in console mode and not exit.

Thanks for the info, Jim! It works.

I could have sworn I would have run into this before now,
because I have been working with view for a few days and didn't notice that.






[REBOL] q's regarding reb Re:(2)

2000-06-06 Thread Galt_Barber




 -galt

 p.s. I was so desperate to use Rebol that I hacked port 1433 to get into MS
 SQLServer 7.
Wassat?! Howd u do dat? And what did u achieve? :)
Brett.

Well, I posted the code for it but got no response whatsoever.
I assumed everybody had no interest in MSSql7.

Basically, to the best of my knowlegde, MS has not documented
the protocol they use, but you can figure most of it out for yourself,
with some effort.
This is the protocol that their odbc driver on the client uses
to communicate with the server.  It speaks MS's brand of SQL,
which is standard enough for most purposes.

The way I began hacking it was to set up a rebol program as a proxy that sat
on some other port -- 9005 is what I used from some tcp example code  --
and then used the client utility that came with sql7 to create a profile
that used 9005 instead of the usual 1433.  MS provides this ability to redirect
to another port mainly to support getting around firewall servers and things
like that.

In any case, with a marvelous tcp-friendly tool like Rebol it wasn't
long before I had my program sitting in the middle between the client
on 9005 and SQL7 on 1433, as a proxy, watching the traffic and logging
it.  From there, it's basically just a process of dissecting the stream
into meaningful bits.  It wasn't particularly meant to be human-readable,
but it was not too bad.  If MS had encrypted the stream or something that
would have made it much harder.

I also just learned enough to process the kinds of requests that I
would make in my app.  You could probably equally well figure out
any that I did not need to address.  Largely I was logging on, changing the
default db to access, doing various select statments, some create/drop table
statements, some insert/delete/set/select into stuff for updating, and most
of the data types I was working with were strings, although there were a
couple of numbers and dates, plus I had to deal with memos, which are
apparently always Unicode, and tables imported from MSAccess, which
are also always in Unicode (2 byte/char).

I also found out how to cancel a query that you are waiting for.
If you start a bad query that will run forever, you must send the server
a query-cancel on the connection, or else the stupid thing will keep
on running, and tying up one of its licenses.  I have a puny 15 or so,
so eventually I ran out while debugging one day.  Then I went back
to the proxy to watch what happens when you start and then cancel a query.

In any case, this is sufficient to get any version of Rebol connected today
to MSSqlServer7.

 As a security note, tools like Rebol are going to make
lazy administrators really sorry that they left in the "sa" user with no
password,
which is the default.  You can just walk right up to the port and say, Gimme.
I haven't tried it, but I imagine it would work.

There is also one thing that is a little less than clean about the login
request.
It is one of the most complex requests and it was also the first one I had to
overcome,
so I actually just store the entire request while in proxy mode to a file, and
then use
it later to connect by spitting the whole thing at the server.  It works.  I
don't even
break it down into which bit means which.   Since for my application it didn't
matter,
I didn't have to worry about that.  After working with so many other bits of the
stream, I could probably make pretty good guesses about it's structure now,
but I haven't bothered.  The two elements of the login request that you might
want to
change are the login and password.  I think that they try to hide the password
so it's not
passed in clear text in the stream, but I doubt it's super hard to figure out
what the pattern is.  I never needed to, as this program is just for an internal
process, and is not going to be installed at any customer site.

I would have rather used ODBC, but it wasn't available.  I am happy to say that
Rebol still came through for me and with a few days' effort was able to connect
to MSSql7 and do everything I needed.  Rebol is much better than VB for most
things,
and with /View now becoming available I may be able to do most of my
programming in Rebol from now on.  Wouldn't that be marvelous!

-galt

p.s.
I could re-post the code if people are interested.
I would have to chop out most of the actual app and
just leave the generic bits that are about talking to MSSql7
and decoding it's response.







[REBOL] FTP crashes rebol Re:(2)

2000-06-06 Thread Galt_Barber




Sterling, in your note to Tim to say that
append should work, although it would be slow and inefficient.

Is this really true?  I didn't think you could modify parts
of files using FTP.  What can FTP really do?

-galt





[REBOL] Timeout Re:

2000-06-06 Thread Galt_Barber




Hi, A.D.  Could you be more specific about your problem?
Usually, upping a timeout is not the correct solution
to the problem.  There is usually something else wrong.
Just my guess.





[REBOL] TextPad syntax for Rebol Re:(2)

2000-06-06 Thread Galt_Barber




what the heck is TextPad?  Is that like notepad for Linux?





[REBOL] One function per class Re:(7)

2000-06-05 Thread Galt_Barber




 I wrote something in BASIC a long way back on an Australian copy of a Tandy
 computer, that played tones when I struck keys on the keyboard.
 I guess that Dates Andrew also
 :) -Tim

Way back, in the time of yore, when real computer programmers used magnetic
cards or cassette tapes to hold programs...

And cursed when they didn't work. :-)

Andrew Martin

YOU had cassette tapes?  Well, you sure had it easy!

Why, we used to lie awake at night, DREAMIN o' cassette tapes!

-galt






[REBOL] One function per class Re:(9)

2000-06-05 Thread Galt_Barber




  I wrote something in BASIC a long way back on an Australian copy of a
Tandy
  computer, that played tones when I struck keys on the keyboard.
  I guess that Dates Andrew also
  :) -Tim

 Way back, in the time of yore, when real computer programmers used magnetic
 cards or cassette tapes to hold programs...
 
 And cursed when they didn't work. :-)
 
 Andrew Martin

 YOU had cassette tapes?  Well, you sure had it easy!

 Why, we used to lie awake at night, DREAMIN o' cassette tapes!

 -galt

So, you remember storing programs on punched paper tape, then?

- Michael Jelinek

Yup, I got a beautiful paper-tape punch a-rusting away at home right now!

Hey, Carl, when is Rebol/Command going to support the UBSKYOO/R paper tape API ?
I got some old assembler routines on paper tape I was planning to use with
Rebol.


-

Did anybody look at the /View viewer.r program I posted recently?
Why does the text field freak out after pressing the jump button
so that I have to switch the focus away and back before it wakes up again?
Am I doing something wrong?

-

-galt






[REBOL] q's regarding reb

2000-06-05 Thread Galt_Barber




 /View is very exciting!!

Carl,

Do we have a hint yet how much it is going to cost?


At the company I work for we develop software that
is used by large corporations with thousands of users,
and my guess is they don't want to pay major dinero for
a license for each person.  With VB programs in the old
days we could pay the devil, I mean MS, a bit o money
and then they didn't care how many times we distributed
our compiled programs.

Sometimes it's not even the money,
just the sheer headache of keeping track of how many people
they have using the program that gets to be unworkable.
I know that there are some fancy licensing things tools but
as our friend recently wrote, we like to simplicize.

Right now we are using the web more and more and that's good,
but some programs don't fit the web interface well, and
dynamic html can be both inadequate and suffering from
netscape/ie/etc. compatiblity problems.  Played with Java some,
but not exactly happy with where it's at.

It would be nice under these circumstances to be able to ditch
VB exe's on the client side and use Rebol/View.  But I have
no idea how much it costs or whether you might offer some
more flexible options in future.  My boss would just be interested
in delivering an application, not caring about how we did it,
as long as it worked - of course he's not carrying a torch for
Rebol, either.

We have never had great cross-platform abilities in the past -
the web has come the closest to making that possible -
so rebol would be a nice bonus in the sense that you'd be able
to say to clients, sure it works on Mac and Unix, too.
(We are a Windoze shop, of course).

In any case, will there be any hope of having affordable distributable
rebol/view app for guys like us who sell to the corporate clients
but are not staff people at the corporations?  MS largely ignores
companies like us.  We are not making software for individuals,
nor are we staff developers at some corporate site building internal
functionality.  We need maximum crossplatform and ease of
install and use and distribution at a reasonable cost and low
support/maintainence.

Anyway, I know that your focus is on enabling the people and
that means letting people make and run their own scripts, etc.
But people like my boss have no interest in that.
They are just trying to find a means to an end, the app.

Thanks for addressing my question,

-galt

p.s. I was so desperate to use Rebol that I hacked port 1433 to get into MS
SQLServer 7.
Please don't make me do that again, even though it was fun.






[REBOL] FTP crashes rebol Re:

2000-06-05 Thread Galt_Barber




Tim, I don't know much about FTP,
but what I have come to expect is that you can
copy, delete, rename files and directories.

FTP probably stands for Files Transfer Protocol.
My guess is that it works basically at the level
of a whole file, so trying to open and edit a file
live on the FTP server seems outside the bounds
of what it's supposed to be all about.

Maybe you need FSP, file server protocol.
just kidding ;-)

p.s. I almost never use FTP, so what do I know?





[REBOL] how do you move a file to another directory and preserve it's date?

2000-06-02 Thread Galt_Barber




how do you move a file to another directory and preserve it's date?

I can't figure out how to do this.
1) copying the file (write read %file) is the only I can find to move it.
2) I can find the date on the file using modified? but I can't set it.
3) there should be a move or copy function in rebol that preserves the date.

if I missed the answer on this, sorry.
thanks for you's help!

galt





[REBOL] find/any doesn't seem to work on a list of file names (block of file! values)

2000-06-02 Thread Galt_Barber




find/any doesn't seem to work on a list of file names (block of file! values)
I can do find without /any and if i give the entire filename as a file! value
then it returns the name.  But if I want to find the first one starting with
the letter g I can't say
   find/any files to file! "g*"
and have it work.
Instead it just returns none.
   find files to file! "greatstuff.txt"
will work, assuming that file is in the list.

is this broke, or am I just having a overlooking something obvious?

galt

p.s. I only tested this on /View beta 4.1





[REBOL] ooh aahh! view!!

2000-06-02 Thread Galt_Barber




--

Well, since nobody else got around to it,
I might as well kick it off!
OO
AA
OOhh Oohhh
Rebol/View is wonderful!!!



They say you should only put one idea in each e-mail to a discussion group
to keep things simple, but you know what? the world isn't...



I am still trying to digest all the goodies in  /View.
I suppose others are too, that must be why they are so quiet!

I just added a delete button to viewer.r which
moves an unwanted picture to a garbage directory,
and I did it without even reading the manual.
Way cool  !!!

-

By the way, lots of gui's let you dump a control at x,y,
but the real work for a lot of programmers is getting easy
layout of components as window size changes - having
it look good, work well, and be easy to program is what
anyone wants.  Are there examples of doing this yet?
Most of the demos I see have a non-resizable window/face.
I would assume that this is the kind of thing that the
flexible rebol language would excel at.
HOW IS IT DONE?
---

-galt

Oh, and thanks as usual for everybody's kind help.





[REBOL] re: find

2000-06-02 Thread Galt_Barber




oops - I assumed find worked on the whole list, but
only works on one element.

you have to do find on each element of the block to
find it with wild chars.

something seems non-intuitive about this arrangement.
If I wanted it to do just one element, I would just give
it one element.  If I want it to seach all the elements of
the block, and use wildcards, it should allow that.

how is this supposed to work?

find "dog" "dog"
works, giving head of string

find ["dog" "cat"] "dog"
works, giving head of list

find/any "dog" "d*"
works, giving head of string

find/any ["dog" "cat"] "d*"
does not work, gives none

Q: is there any scenario at all in which /any would
do anything when you are doing find on a block ?
And if it doesn't work, why doesn't the doc warn about that?
I foolishly assumed that it would find the first element in
the block that matched the string.

-galt






[REBOL] /view stuff

2000-06-02 Thread Galt_Barber




Duh, is there a /view list?  I can't remember where it is if it is,
but please let me know if this is not good for the regular list.
I just started using /view with the latest beta 4.1 announcement.



I am finding that the viewer.r utility that came with rebol/view
is really cool, but unfortuntely, the load-ed jpgs are not released
from memory when the next picture is load-ed, or something.
On NT, you can watch the memory usage climb and climb higher
until eventually you get out-of-mem.

I remember somebody used to have a way to manually force
garbage collection, but I don't remember what it was and
I don't know if it would help anyway.
--

While fooling around with the same program,
I sorted the file-list in alphabetical order.

I also changed the viewer.r to add a button called jump.
I can type in a new name for the file and hit the jump
button.  It works, but there's something odd happening.

After the first one or two I can't get my mouse in the
name field, even though it is still yellow.
By chance I noticed that if I switch away to another
field I can then switch back to the first and the field
responds again.

(by the way, I don't think these two problems are related,
because the viewer.r was choking out-of-mem before
I ever started tweaking the file)

I might as well include the program since somebody
will probably be wondering what stuff I changed.

(See attached file: viewer.r)

(I have not yet noted my own fiddling in the rebol script header itself.)

-galt

 viewer.r


[REBOL] One function per class Re:

2000-06-01 Thread Galt_Barber




Andrew, you play the fiddle?  I didn't know that!
I love playing the fiddle, too!  (although I seem
to spend more time playing with Rebol these days...)

-galt





[REBOL] re: info? so slow on WNT

2000-05-31 Thread Galt_Barber




correction, delete the file is what's slow!

It seems to be the info? call that is super slow - it takes about .5 to 1.0
seconds for each file,
which is extremely slow when you have to go through several hundred.
It even makes the whole machine run slow - other apps are bogged down.

I have two copies of rebol  running this code, and realplayer.
Realplayer is only using less thatn15% of cpu-
the two rebol copies are taking the other 85% of cpu time.  If I turn
realplayer off,
it doesn't get much faster.  Just typing this note was glacially slow.  What
gives???

I was deleteing the files after their size was too small.

Must it really be so slow?

-galt





[REBOL] stack space Re:

2000-05-16 Thread Galt_Barber




out of stack space usually means an infinite loop with recursion.
so increasing it to any amount, no matter how huge, is futile.
fix the bug instead.





[REBOL] two-digit return of now switches Re:

2000-05-08 Thread Galt_Barber




I think you may wish to check this further.

current-time: now/time

file-name: rejoin [
  now/year
  now/month
  now/day
  current-time/hour
  current-time/minute
  current-time/second
  ]

complete-file-name: rejoin [{%} file-name {.html}]

When I was looking at something similar, I hit a problem
because the integer returned is of course not 0-padded on the left.
So, is it (2000116) November 6th or is it January 16th??
Statistically it may be unlikely to cause a problem,
but if it could happen even once and that would mess you
up bad, then you better pre-pad the month and day with 0 when necessary.



rant



This is part of a general theme.

You can't strip out punctuation ( dates use  / - ) and not pad (0) instead --

not unless you have a pretty sophisticated encoding process,

which is rare enough.



It's similar with escape codes in strings and so forth.

We often want to have our cake and eat it too.



Unicode makes everything two bytes and that has the

advantage of simplicity.  But it bites in certain applications

where bandwidth or storage is precious.  Escape systems

potentially offer more flexibility, but they also introduce complexity.



C-strings suck, too.  Great, they can be of indefinite length.

But that also means you can't quickly get the length of the

string without scanning the whole thing.  And because there's

no escape-encoding of the 0-terminator, you can't use any

of those in a string.  And even though it's only 1 special

character that's restricted, it ruins so many applications.



And of course there isn't a c-programmer alive who

hasn't run right of the end of his string and corrupted

his memory.  It's a hell of a lot of fun, actually,

a bit like bungy-jumping.  Goodness gracious,

I hope there's a zero at the end of this thing!



I remember years ago trying to send a zero in part of

a printer-setup command sequence, and because dbase was

written in c, you couldn't send it to the printer at all.

Actually there was a work-around, but you had to write

and assemble little assembly language scripts and

load them in at run-time.  I'm sure others could come

up with loads of similar horror stories.



The day c disappears from the planet will be a happy one.

One day we'll look on it with feelings akin to the way

we feel today about COBOL.



/rant



good luck



-galt






[REBOL] web proxy

2000-05-08 Thread Galt_Barber




Basically, I wanted to know if it was possible,
and how, to write an http proxy server, using Rebol of course.

I want to be able to have the proxy filter page content,
e.g. translate to uppercase, to another font, to another
language, or other kinds of transformations on the text,
and have it be more or less invisible and automatic
to the person browsing.

I know that I could write an app that would put up a form
and you would fill out the url and submit it and the rebol
app could fetch the page, filter it, and return it,
but it gets tedious, and it really fails on urls with frames,
and other stuff.

I dont know if the http proxy server idea would be too
complex to make it worth it or if rebol has stuff built in
already that makes it very easy, or ...

And if somebody knows where to get docs on http proxy info,
that would be kind and helpful.


Galt Barber






[REBOL] online database manipulation Re:

2000-04-21 Thread Galt_Barber




Remember how excited you were when you described
this great new language called Rebol ?

And do you remember when your boss asked you if Rebol could
talk to the db and you had to just hang your head?

Well, things are looking up!

Can Rebol/Core really talk to databases today?  Yup!

I think some of you database folks out there are really going to
get a kick out of this.  Especially if you have access to ms-sql-server7.

My apologies for the rough state of the code.
Please share with us all any juicy little improvements made.

(See attached file: sqlproxy.r)

Remember, it ain't a party until Rebol shows up!

Galt Barber
[EMAIL PROTECTED]

p.s. If this is an old trick by now, my apologies;
I have been unable to monitor the list for
quite some time now...


 sqlproxy.r