I need to let a block set the variable t3 to several lines from a webpage.
One line works like this:
|t3 link|
t3_ self readLine: 5 FromUrl: link
but I am using it to read a file where more than one line of the file needs to be set to t3 so that the smalltalk code sets t3 to:
lines 5 to (number of lines in file at URL, link) of link
Any ideas?
Offline
Do you want line breaks, or a long string?
Offline
I can do it tommrow, not now sorry.
Offline
sparks wrote:
I need to let a block set the variable t3 to several lines from a webpage.
One line works like this:
|t3 link|
t3_ self readLine: 5 FromUrl: link
but I am using it to read a file where more than one line of the file needs to be set to t3 so that the smalltalk code sets t3 to:
lines 5 to (number of lines in file at URL, link) of link
Any ideas?
|t3 t4 time totalTime link|
time = totalTime ifFalse:
[t3_ self readLine: 5 FromUrl: link.
t4_ t3 , t4.]
ifTrue:
[^ t4].
Offline
bbbeb wrote:
sparks wrote:
I need to let a block set the variable t3 to several lines from a webpage.
One line works like this:
|t3 link|
t3_ self readLine: 5 FromUrl: link
but I am using it to read a file where more than one line of the file needs to be set to t3 so that the smalltalk code sets t3 to:
lines 5 to (number of lines in file at URL, link) of link
Any ideas?|t3 t4 time totalTime link|
time = totalTime ifFalse:
[t3_ self readLine: 5 FromUrl: link.
t4_ t3 , t4.]
ifTrue:
[^ t4].
How do I set t3 to that?
Offline
sparks wrote:
bbbeb wrote:
sparks wrote:
I need to let a block set the variable t3 to several lines from a webpage.
One line works like this:
|t3 link|
t3_ self readLine: 5 FromUrl: link
but I am using it to read a file where more than one line of the file needs to be set to t3 so that the smalltalk code sets t3 to:
lines 5 to (number of lines in file at URL, link) of link
Any ideas?|t3 t4 time totalTime link|
time = totalTime ifFalse:
[t3_ self readLine: 5 FromUrl: link.
t4_ t3 , t4.]
ifTrue:
[^ t4].How do I set t3 to that?
|t3 t4 t5 time totalTime link|
t5_ ''.
time = totalTime ifFalse:
[t3_ self readLine: 5 FromUrl: link.
t4_ t3 , t4.]
ifTrue:
[t5_t4].
t3_ t5.
Offline
I dunno, wasn't my code XD
Offline
bbbeb wrote:
sparks wrote:
I need to let a block set the variable t3 to several lines from a webpage.
One line works like this:
|t3 link|
t3_ self readLine: 5 FromUrl: link
but I am using it to read a file where more than one line of the file needs to be set to t3 so that the smalltalk code sets t3 to:
lines 5 to (number of lines in file at URL, link) of link
Any ideas?|t3 t4 time totalTime link lineNum|
time = totalTime ifFalse:
[t3_ self readLine: lineNum FromUrl: link.
t4_ t3 , t4.]
ifTrue:
[t3_ t4].
^ t3.
There. I fixed it. I was in a rush.
Last edited by bbbeb (2010-12-15 23:14:53)
Offline
Here's a quicky fixy
| t3 link lns res curr | t3 _ self readLine: 5 FromUrl: link. lns _ t3 lines size. res _ t3 lines at: 5. curr _ 5. lns - 5 timesRepeat: [curr _ crr +1. res _ ' ' , t3 lines at: curr]. ^ res
there's definitely a much easier way to do this, but i've been working too much with VB recently and forgot half of my Squeak
Offline
Why is this block returning an error?
$String$ as one line
|t3 t4 time totalTime lineNum|
totalTime_ t1 asString lines size.
time_ 1.
time = totalTime ifFalse:
[
lineNum_time.
t3_ t1 asString lines at: lineNum.
t4_ t4 , ' ', t3.
time_ time + 1.]
ifTrue:
[^t4.].
??
(bring a string of more than one line and puts all the strings on one line with a space seperating each former line.)
Last edited by sparks (2010-12-16 15:02:36)
Offline
sparks wrote:
$String$ as one line
|t3 t4 time totalTime lineNum|
totalTime_ t1 lines size.
time_ 1.
time = totalTime
ifFalse:
[
lineNum_time.
t3_ t1 asString lines at: lineNum.
t4_ t4 , ' ', t3.
time_ time + 1.]
ifTrue:
[^t4.].
Offline