• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

World: r4wp

[Rebol School] REBOL School

cgi-block is your variable, and the rest are functions
Here is an example:

cgi-obj: construct decode-cgi read-cgi

;check the input
all [
	in cgi-obj 'email
	trnEmailAddress: to-email trim form cgi-obj/email
	not empty? trnEmailAddress
] [
	;evrything seems ok

 send trnEmailAddress reform ["Thank you. Your number is" token "."]
print "Error!"
Missing an 'if :)
oh, yes.. Thanks for correcting. IF ALL [ ...
Thanks guys. Endo: Special thanks for  going so far as type out an 
example that includes checking out that everything is OK.

 I realize that one cannot trust outside sources of info and that 
 one has to always be prepared to outsmart dumb users, but the needs 
 of this project are straightdforward and I am in unfamilar territory 
 so if it can make things easier I can go on a bit of faith for now. 
 That being said, better code that covers mistakes is better code 
 and I am appreciative of it.

 Sunanda: That is what I thought, but I had to be sure. Thanks for 
 helping with the details.

 Graham: Is that general advice or a comment on code examples I posted? 
 I thought I had done what you just said.
Hi, I have a small problem playing an mp3 file 
I have so far
player: "/Applications/Vox.app/Contents/MacOS/Vox"
thissong: "/Users/Arnold/Music/A song.mp3" 
thatsong: "/Users/Arnold/Music/A-song.mp3"       
And then 
call reform [player thissong]  
call reform [player thatsong] 

Playing thissong will start the musicplayer, but no music was found 
and playing  thatsong starts the player and is being played without 

Because most of my mp3's and directories they are in have spaces 
in their names so starting to play them from REBOL gets hard this 

I tried to-file thissong but this produces "%/......&20song.mp3" 
so it was not successful. (Allthough thatsong just played without 
a problem) :(
Any ideas please?
Another thing, I want to make an 'application' using REBOL that plays 
an mp3, an mp3 with a story for kids and I want to display the pictures 
from the book depending on maybe a timer(file) so the pictures are 
displayed acoording to the storyline. This also could be a helping 
aid for making presentations. 

I do not want to binary save my mp3 in the source of the application 
or in any other rebol-script so I just want to use the mp3 file and 
not convert it.

Furthermore I do not want an external app to be started unless it 
can be done under the hood and/or it can be controlled by my app 
because the presentation could be paused by the user. Any ideas where 
and how to start such script.
Yet another task I think REBOL could help me with. Say I could not 
find the subtitles for an ancient tv-series i stumbled upon on the 
net. But I found subtitles in English. I can translate but some words 
will reoccur often, so I imagine a rebol script showing an original 
line or words to be translated. I type some translations and when 
I translate a word, all equal words in the rest of the document will 
change, saving me quite some time.
Okay now the words are almost all translated. Unfortunately the words 
are in the wrong order. Now the app shows me the lines again and 
this time the words are little blocks that I can click and drag to 
the desired position.
Been there, done that, got the T-shirt??
Found the answer to my first task:

Had to read the documentation a little further and needed a function 
localize-file: func [file] [
    rejoin [{"} to-local-file clean-path file {"}]

Now call reform [player localize-file to-file thissong] does play 
the song!
A slightly shorter version that does the same, I think:
        localize-file: func [file [file!] ][
            mold to-local-file clean-path file 

I added [file!] to the parameter.....You get the parameter type-checked, 
hence a better error message if you pass it something that is not 
a file name.
@JohnM .. my last comment was on the code Endo posted which was missing 
an 'if
are you aware of the Universal Subtitles project? http://www.universalsubtitles.org
Graham: Sorry I was not clear. I was refering to you stating that 
I have to seed the generator first then generate my number.

You have to do it like this

random/seed now/precise
token: random/secure 1000000

and not like this

token: random/seed now/precise
random/seed does not return a value
Graham: Thanks. That makes sense out of something someone else told 
me. I thought the information was contradicting what you guys said 
earlier, it just means I misunderstood the order of things. The modiffer 
after the slash is closer to making a new command than it is an agrument 
than I had envisioned. The fact that random is part of both made 
me think they could be done together. Thank you for catching that 
I did not know that detail.

 Next part of myscrip enters something into a database. The server 
 will have an mySQL database installed. It is possible that alternative 
 could be used, but knowing for sure I have at no extra charge this 
 options means I am starting with this option.

 So I found a MySQL Driver for REBOL from here: http://softinnov.org/rebol/mysql.shtml

 I am following the instructions that came with the download. Is there 
 anything I should know. Maybe it is not the driver people use because 
 there are better ones. Maybe the author kills kittens on the weekend 
 and it is consider bad form to use it. Maybe it is harder than it 
 looks. Basically, please just tell me if there is general info about 
 it I should know that is not obvious. Thanks.

Hey, someone else is asking questions? i thought this was all about 
me! :-) :-)
It's pretty much the only driver used for mysql
odbc drivers for windows can only be used with the rebol/view, the 
gui build, unless you paid for a rebol/command sdk
Hi Bas, no didn't know that one, maybe there should be an universalopensubtitleday 
to generate more attention to it :)
The subtitles seem to be kept on their servers. Which is not a problem 
for a video on the web, but for my purpose it is not what I want.
On filename quoting, I have an ENQUOTE func (and a more generic ENCLOSE, 
ENCLOSED?, etc.) to make the intent clear. MOLD is shorter, but if 
you pass things around, not knowing if they've already been molded, 
you can get tripped up. At least I have.
MOLD is definitely more vague, could become anyshape the form of 
the mold is. An ENQUOTE saves the time finding out what it does.
You have to do it like this

random/seed now/precise
token: random/secure 

- mathematically, the above code does not differ from token: now/precise
(it is neither more "random" nor more "secure")
Except that you get a date instead of an integer?
Enlghten us Ladislav
The principle is that the token calculated that way:

1) depends only on now/precise, in fact

2) since there are the is the RANDOM/SEED and RANDOM calls, it is 
still possible that in some cases distinct NOW/PRECISE results lead 
to the same TOKEN value
Today I tried combining some tables in Excel, but without (frustrating!) 
no success. So tomorrow I will try and build a quicky REBOL script 
to put the data in one Rebdb databasetable and then do a dump of 
that and import that again in Excel.

So I combine data NAME PROP1 with NAME PROP2 giving a table NAME 
Any tips suggestions for lookalike scripts? Tia!
Doesn't sound like you need RebDB. You could just do the operation 
on an Excel export such as CSV format
Try using Gregg's perfect REBOL Excel Control Dialect: http://www.robertmuench.ch/development/projects/excel/dialect_documentation/

Also look at Brian's csv-tools on rebol.org:

Arnold, you can also take a look at an .xml file that Excel produces 
and see how that is configured. I've had better success with xml 
files than csv (though I use those as well) since you can add all 
kinds of formatting with XML.
@kaj and balance-line through the files. A possibility, has some 
tricky attentionpoints in it, and the preferred way when efficiency 
is in the picture or more than once usage. Db seems to be pretty 
straight forward and its a nice exercise in using that.
Thanks Endo, I mailed the links to my work.

@James To me xml just looks like a whole lot of <> characters and 
a lot of description extra. Having to deal with that too seems a 
lot of work more, need a tool for  working quick with xml.
Thank you for all of your suggestions!
There are several XML parsers for REBOL. The most advanced one is 
in the PowerMezz package
Does RebDB have easy Excel import/export?
I had the cvs file (one at a time is easiest) read/lines, parsed 
the comma's and then depending on the record with the key name = 
currentrecname being already in the table an insert or an update. 
But the update using db-update/where just gave me trouble beyond 
belief. Trying update within SQL (I am talking about Rebdb here) 
was no problem at least using 1 property at a time (had no more time 
testing). But how to do it using db-update is a mystery to me. Tried 
many things to no avail. My table I created using db-create bt [name 
additive papertype department weight weightline]   How do I update 
the record where name = ABCD and I need only to update columns weight 
and weigthline, both integer (but that's a coincidence, don't mind 
if it could be anything)?
And I thought this would be a quicky! :-)
Any clues if it is possible to test a file for EOF?
If that does the trick I'll try to trick it into believing this eof?: 
After some trial and error getting surprised with some thing that 
seemed to work yeterday but didn't today I got it figured out. I 
will post the scripts somewhere when there is interest in it.
A view question. Can the name of a button be changed after it has 
been created?

view layout [button "Text in Button"]

I want to change "Text in Button" to "New Text in Button" and redisplay 
it. I have not come across this anywhere so far?
Here's one way:

    view layout [b: button "Text in Button" [face/text: "Changed!" show 

Though it'd usually be better to assign the button to a word, so 
you can change the text at other points in your script too:
    view layout [
               but1: button "Text in Button"

               but2: button "Press me" [but1/text: "Changed!" show but1]
I usually label these as btn1 etc so I don't show my butt
When I use rename function to rename a file, the file date on my 
Mac OS X changes too. When I change a name using finder, carefully 
clicking the file and renaming it, the date does not change. Doe 
sthis happen on other platforms too? How to steer this behaviour?
I'm afraid this is where you run into the limitations due to REBOL 
being as platform neutral as possible
You can use rebol to get the mod date and change it back after the