World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
todun 15-Oct-2011 [4497] | @DideC: thanks. sorry for the late reply. |
james_nak 15-Oct-2011 [4498] | todun - thanks for posting your code. You know, I never knew there was a "move" function. in R2. |
todun 15-Oct-2011 [4499] | @james_nak: I just found that out here too. |
james_nak 15-Oct-2011 [4500] | Todun, just some of my thoughts. I think you are changing the order of the cards ito indicate the difficulty of a question. When you are saving the %temp-cards.txt, you are at a particular position in your series because of the "qa: next qa" so when you save/all it is saving the series from the current position to the end. If you want to save the whole series, you can add "head qa" which will bring the pointer back to the first item for the save but leave your pointer at the current question. It may help to do some simple tests: >> a: [1 2 3 4 5 6 7 8 9 10] == [1 2 3 4 5 6 7 8 9 10] >> a: next a == [2 3 4 5 6 7 8 9 10] >> save %test.txt a >> read %test.txt == "2 3 4 5 6 7 8 9 10" >> save %test.txt head a >> read %test.txt == "1 2 3 4 5 6 7 8 9 10" move/to a 5 == [6 7 8 9 10] >> save %test.txt head a >> read %test.txt == "1 3 4 5 2 6 7 8 9 10" etc. Also I like to add "probe" as in "probe qa" to different places in my code so I can see what is happening internally as I do stuff. Finally, might I suggest that you actually approach the issue in a different way altogether? You can have a block that has some metadata in it so that a question's difficulty can be assessed by other means such the word "hard" or some number such as 1 = easy and 10 = hard, for example. And allong with that you could keep track of how many times the person missed the question. [ 1 "California" "Sacramento" 1 1 0 1 ] where the block above refers to [ index Question Answer difficulty Attempts Wrong Correct] There's a lot more work to do this but if you can then search for the difficult questions, etc. Your program would control the order of the questions based on some filter such as difficulty, attempts. The user could just mark a question as difficult. Anyway, just a thought. I don't want to make your life hard and I need to go back to my own mess I started. I am in block-o-rama myself. |
Duke 23-Oct-2011 [4501] | Having trouble with the "switch" function. I'm entering the following at the REBOL terminal: >> time: 14:00 == 14:00 >> switch/default time [ [ 8:00 [send [wendy-:-domain-:-com] "Hey, get up!"] [ 12:30 [[cindy-:-dom-:-dom] "Joinme for lunch?"] [ 16:00 [send [group-:-every-:-dom] "Dinner anyone?"] [ ] For my trouble, I get: :) ** Script Error: switch is missing its case argument ** Near: switch/default time [ 8:00 [send [wendy-:-domain-:-com] "Hey, get up!"] 12:30 [[cindy-:-dom-:-dom] "Joinme for lunch?"] ... Am I using the REBOL terminal incorrectly? I'm using rebcore v 2.7.8 |
Henrik 23-Oct-2011 [4502x3] | with the /default refinement, you need one more block, to trigger the default case. |
for multi-line stuff, you can use the built-in very simple editor: >> editor "" write your script and save it and use CTRL-E (I think) to run it. | |
rebcore v 2.7.8 - ok, the editor is not in this version, so you would have to use another editor. | |
Duke 23-Oct-2011 [4505x2] | http://www.rebol.com/r3/docs/functions/switch.html |
Sorry about the previous msg - still getting used to Altme :o I'm taking the examples right from the URL in my previous msg. Is there a simple and bullet-proof way to enter the code at the REBOL console? | |
Henrik 23-Oct-2011 [4507] | You should be able to somewhat safely paste multiline code, but otherwise it's best for single line entry. Also note that the console does not behave identically on different OS'es. |
Ladislav 23-Oct-2011 [4508] | have you tried the do read clipboard:// expression? |
Henrik 23-Oct-2011 [4509] | When developing scripts, I like to use my favourite editor and hook up REBOL to a keyboard shortcut, which is a nice and quick way to study longer REBOL scripts. |
Ladislav 23-Oct-2011 [4510] | Or, if you want to examine what exactly is in the clipboard, you can: print read clipboard:// |
Duke 23-Oct-2011 [4511x3] | @Ladislav nope! but I will ... :) |
Is there an emacs mode for REBOL that you guys are aware of? | |
BTW, I just C&P the code into the console, and BINGO!!! :)) | |
Henrik 23-Oct-2011 [4514] | There should be an emacs mode available. I have never used it, though. |
Duke 23-Oct-2011 [4515] | @Henrik What??? Are you ill? LOL ... |
Henrik 23-Oct-2011 [4516] | I don't use emacs, hence I don't need the REBOL emacs mode. :-) |
Duke 23-Oct-2011 [4517x2] | @Henrik That's my point !! :)) |
Anyway ... thanks you guys!! | |
Izkata 23-Oct-2011 [4519] | @Duke: It works in the console if you put the opening bracket of the final block on the same line as the closing bracket of the previous block, like it is in the example |
Duke 24-Oct-2011 [4520] | @Izkata I see that! Thanks. My problem was that CORE's "line continuation" symbol - [ - was confusing me. Is there a way to change that to another symbol? I was getting it mixed up with the code's own [ and ]. |
Pekr 24-Oct-2011 [4521] | Have you investigated Core System object? It's interesting. Try: "help system" :-) Hmm, I thought it might be there, but it is not: >> help system/console SYSTEM/CONSOLE is an object of value: history block! length: 2 keys none! none prompt string! ">> " result string! "== " escape string! "(escape)" busy string! "|/-\" tab-size integer! 4 break logic! true lookup function! Console filename completion lookup. |
Duke 24-Oct-2011 [4522] | It would have been too good to be true, if it had been there :D How would those values be changed from the console? Like say the tab-size? |
Pekr 24-Oct-2011 [4523x3] | system/console/tab-size: 8 :-) |
it is just normal object, so you can acces its value by path. | |
So let's say, that we have kind of Windows REBOL registry in here :-) A system structure, you can access to get some configuration, etc. | |
Sunanda 24-Oct-2011 [4526] | The one thing you do not seem able to change is the [ continuation char |
Pekr 24-Oct-2011 [4527x2] | just try e.g. system/console/prompt: "-->" |
in fact, we have two continuation chars, [, and {, and both make sense - the first one is the continuation of a program, or a block, the secong one is for a multiple line string | |
Duke 24-Oct-2011 [4529] | @Pekr It might make sense to have 2 line continuation chars, but IMHO, it makes no sense to have those chars *the same* as symbols you'd find in REBOL code. It can become too confusing -especially for beginners. I suppose that is the reason why the console/prompt is set to >> and not {{ or ]] :) |
Ladislav 24-Oct-2011 [4530x4] | This is a misunderstandin, Duke. #"[" is not a "line continuation" symbol |
It is simply so, that you can continue, because the interpreter "knows" you did not enclose the block yet | |
use do read clipboard:// to input any number of lines | |
Example: 1 + 2 >> do read clipboard:// == 3 | |
Duke 24-Oct-2011 [4534] | @Ladislav I don't understand what you mean? I might have used the wrong terminology - sure! MY corcern is that IF I had a choice, I would NOT want to see a { symbol at the beginning of a multi-line REBOL snippet, entered at the console. So how does what your advise above relate to MY concern?? :) |
Sunanda 24-Oct-2011 [4535] | The REBOL console is trying to be helpful in indicating that at least one "]" or "}" needs to be supplied to complete an expression. But I'm with Duke -- more helpful visual indicators would be nice; as would the ability to override the default ones. |
Duke 24-Oct-2011 [4536] | @Sunanda I see! So the "[" character is simply a hint. Wouldn't it have been more intuitive to have used the "]" char - to indicate that an open '"[" needs to be closed?? I'm glad that the LISP REPL doesn't do this - not the ones that i use anyway :)) But thanks! You've cleared things up a bit.... |
Ladislav 24-Oct-2011 [4537x4] | The REBOL console is trying to be helpful in indicating that at least one ]" or "}" needs to be supplied to complete an expression." - yes, and that is where I wanted to point out, that there is no "line continuation symbol", since what is going on is not that the interpreter encountered a "line continuation symbol" (it did not), but that it expect you to close the open block |
But, OTOH, if you really do want to write an expression like 1 + 2 in the interpreter console, you can use this trick: do [ 1 + 2 ] | |
I would NOT want to see a { symbol at the beginning of a multi-line REBOL snippet, entered at the console. - that is easy | |
What exactly it is you *would want* to see? | |
Duke 24-Oct-2011 [4541] | @Ladislav Thanks for clearing that up! At the moment, I'm simply reading http://www.rebol.com/docs/words/wswitch.htmland trying out the snippets to do 2 things: 1. Learn to use the REBOL console 2. Learn REBOL syntax etc Entering those multiline snippets is what was a problem - until now. The console prints a "[" after each CR. For a noob, this chars looks and feel just like the ones IN the code. :)) |
Ladislav 24-Oct-2011 [4542x2] | I do understand, but that does not answer my question. As far as I am concerned, I use the do read clipboard:// approach when trying some code snippets |
But, anyway, what it is you would want to see? | |
Sunanda 24-Oct-2011 [4544] | here's a cheap'n'cheerful console replacement that concatenates an expression until it reads a blank line. Then it executes it. (Two blank lines to exit). Feel free to change the console prompt characters. my-con: func [ /local in-line in-buff err ][ forever [ in-buff: copy "" in-line: copy "" forever [ in-line: ask "In > " if in-line = "" [break] append in-buff join " " in-line ] if in-buff = "" [break] err: none if error? err: try [print ["Out > " do in-buff] true] [ print ["Oops > " mold disarm err] ] ] exit ] |
Pekr 24-Oct-2011 [4545] | Duke - I think that in fact it is not much of an issue? How often do you use multiline expression in REBOL interactive console session? It does not allow you to go back anyway, so ... |
Duke 24-Oct-2011 [4546] | @Sunanda Thanks! Can't wait to try it out! :) |
older newer | first last |