Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
NjinN
@NjinN
count: 0
parse file-str [some [thru goal-str (count: count + 1)]]
BlairLW
@BlairLW
I got it @NjinN I need to see how you formatted your output and I will reply with code

I did something like this:

<start>
; find specific number
'''
text: read %temp.txt
count: 0
while [spot: find text "10"][
count: count + 1
text: next spot
]
print count;
'''

<end>

NjinN
@NjinN
@BlairLW just insert four space before your code
every line
BlairLW
@BlairLW
hrmm..it didn't work
NjinN
@NjinN
find specific number
text: read %temp.txt
count: 0
while [spot: find text "10"][
count: count + 1
text: next spot
]
print count '
BlairLW
@BlairLW
Yeah, I got nothing. I'll figure it out I guess. Thanks.
NjinN
@NjinN
@BlairLW Maybe find/tail can make your code more simply. But IMO, parse should be the best way to deal with any text
Toomas Vooglaid
@toomasv

@BlairLW Hi! Please use backticks instead of single quotes to format your code. This way:

```
text: read %temp.txt
count: 0
while [spot: find text "10"][
    count: count + 1
    text: next spot
]
print count
```

You could do it with parselike this:

count: 0 
parse read %temp.txt [any ["10" (count: count + 1) | skip]] 
print count
BlairLW
@BlairLW
I'll check it , thanks. For lack of better phrase - can you do a read from a variable? I can't seem to get it to work and my search skills must be bad
Toomas Vooglaid
@toomasv

@BlairLW Can you show code how you are trying to do this?

About your previous example, simplifying it a bit:

text: read %temp.txt 
count: 0 
while [text: find/tail text "10"][count: count + 1] 
print count
BlairLW
@BlairLW
@toomasv when I click a button, I want it to read a variable and display it in a field.
the variable is not static
Toomas Vooglaid
@toomasv
@BlairLW (Before @9214 gets to it, try to avoid the variable-word :smile: ) I'll try to cook an example.
BlairLW
@BlairLW
the word variable is "bad" in rebol?
Toomas Vooglaid
@toomasv
Strictly speaking, there are no variables in usual sense in Rebol/Red.
word: "I am not a variable!" 
view [t: field 150 button "Show" [t/text: word]]
Toomas Vooglaid
@toomasv
@BlairLW Example, why words are not like variables:
c1: object [a: 1] c2: object [a: 2] c3: object [a: 3]
set/only 'a reduce [in c1 'a in c2 'a in c3 'a]
a
;== [a a a]
reduce a
;== [1 2 3]
BlairLW
@BlairLW
@toomasv thanks. I discovered "form" problem solved :-)
Toomas Vooglaid
@toomasv
You are welcome! :smile:
Gabriele Santilli
@giesse

@NjinN async is tricky in REBOL 2. There's some info here https://codereview.stackexchange.com/questions/152718/minimal-async-web-server-in-rebol-2 but nobody has ever written good docs about it. If you can find it, Romano's atcp:// scheme may be the most complete and relatively user friendly implementation, otherwise my async:// scheme (linked from previous link) should work but you'll have to hunt around for examples on how to use it on the server side of things.

Generally speaking though, there are so many bugs and quirks in R2's async-modes that it's pretty hard to get a server to work reliably. You may want to use an existing solution like Uniserve or Cheyenne instead.

NjinN
@NjinN
@giesse Thanks a lot! I just want to write web page with Rebol in someway like PHP, it seems no server program support it. So I make a simple server program to implement that, there is no existing solution as i know.
Semseddin Moldibi
@endo64

@NjinN Also check https://www.cheyenne-server.org/ a web server written with Rebol and the author of Cheyenne is DocKimble, the author or Red as well.
It'a a full featured web server, natively support Rebol pages (RSP)

@ungaretti recently added a page about it on Helpin.red web site: http://helpin.red/AppendixII-WhilewewaitforfullCGI.html

NjinN
@NjinN
@endo64 Great, thanks
hiiamboris
@hiiamboris
I've come to seek your advice ☻ In case I don't see a polar bear in my kitchen...
Does it make sense to you that rotate of the Draw dialect currently rotates around 0.5x0.5 pivot? I think we should change it to 0.0x0.0 (see red/red#3504).
hiiamboris
@hiiamboris
Same question on scale
Toomas Vooglaid
@toomasv
@hiiamboris Seems correct:
im: draw 3x3 [box 0x0 2x2 pen red line 0x0 2x0 pen blue line 2x0 2x2 pen green line 2x2 0x2 pen yellow line 0x2 0x0]
view/tight  [box draw [scale 20 20 image im 0x0 2x2]]
image.png
Not only rotate and scale, but draw on first place :smile:
view/tight [box draw [scale 20 20 [
    box 0x0 2x2 pen red line 0x0 2x0 pen blue line 2x0 2x2 pen green line 2x2 0x2 pen yellow line 0x2 0x0
]]]
Toomas Vooglaid
@toomasv
image.png
hiiamboris
@hiiamboris
@toomasv It does not bother you that the scaling applies around the center of the top left pixel, not around the top left corner of that pixel?
Toomas Vooglaid
@toomasv
I mean, you are correct!
hiiamboris
@hiiamboris
Oh! Okay ☺
Toomas Vooglaid
@toomasv
From the other side, as a base of calculations, center-of-pixel seems ok. Think of e.g. line-caps and width:
view/tight [box draw [transform 0x0 90 20 20 50x10 [
    fill-pen orange box 0x0 2x2 
    pen red line-cap square line 0x0 2x0 
    pen blue line-cap round line 2x0 2x2 
    pen green line-cap flat line 2x2 0x2 
    pen yellow line-width .5 line 0x2 0x0
]]]
image.png
hiiamboris
@hiiamboris
I don't see how that would have affected line-caps and width... With upper left corner of the image as a pivot your command will be transform 0x0 90 20 20 40x0 instead. I think... Which is more intuitive, no? 2x2 * 20 = 40x40
You wouldn't have to manually add another 0.5x0.5 * 20x20 = 10x10
Toomas Vooglaid
@toomasv
That's true.
hiiamboris
@hiiamboris
What I really dislike about the coordinate system is that draw commands refer as 0x0 (line 0x0 ...) to the same pixel that you would later extract as image/(1x1). Simply. Annoying. ;) But I suspect this is not gonna change...
Toomas Vooglaid
@toomasv
Yeah, I have hit my head against this several times :dizzy_face:
nedzadarek
@nedzadarek

@hiiamboris I do not find this annoying.
draw/shape draws things in all direction (e.g. view [base draw [translate 100x100 line -2x0 -50x-55]]. It make sense that you start from 0x0 and move in any direction.
images and other series first index being 1 make sense too. I mean you want to a first element -> 1st.

ps. of course it is just my opinions. You can make (and I think you have already made) a contra-argument about 0-based indexing.

hiiamboris
@hiiamboris
Well I mean the amount of extra work required to properly subtract and add and otherwise take care of the indexes, and the effort it takes to keep in mind in what expression what origin you are using is annoying ☺
That and the fact that you'll have to tell everybody who uses draw that they have two different coordinate systems - one for indexes and one for commands...
I see even more complications though. When they make a pair! of float!s, there'll be a tough choice. Will we map all integer pairs to pixel centers, like 0x0 will be the same as 0.5x0.5? Or will we let the image lie mostly in the right lower quadrant and let it extend just half a pixel to all 3 other quadrants?
I think this one deserves a REP
nedzadarek
@nedzadarek
@hiiamboris excuse my ignorance, but what is the purpose of float-based pairs with the images/draw etc? You want to draw on exact pixel (using integers points): 42x42 not on not-precise point (using floats): 3.14x3.14.
hiiamboris
@hiiamboris
But I do want to draw on floats! I do want seamless animation, subpixel pen positioning, continuous scaling and on and on. Otherwise forget about vector graphics
Scaling is already alright though, as it's not dictated by a pair!
nedzadarek
@nedzadarek

@hiiamboris

But I do want to draw on floats!

but you only have integers

Otherwise forget about vector graphics

but isn't vector scaling/rotating indifferent? Using floats you may introduce some errors.

I'm still confused but I'm not good in the graphics.

hiiamboris
@hiiamboris
What's your point?
nedzadarek
@nedzadarek
My point is that you don't need float-pairs for such things.