I want to convert many decimal numbers available as strings to floats in one go. I am trying following code which combines these strings into a series and then convert them to floats. This works all right but fails if there is an error:
a: "1.5" b: "" c: "3.7" invars: [a b c] print a print type? a set invars foreach x invars [append  to-float reduce x] ; code to convert string series to float series; print a print type? a
The error is:
*** Script Error: cannot MAKE/TO float! from: "" *** Where: to *** Stack: to-float
For error correction, I tried following code:
temp:  foreach x invars [ y: copy "" either error? [set [y] to-float reduce x] [append temp reduce x] ; put original value if not convertable [append temp reduce y] ] print temp set invars temp print a print type? a
But this is also not working. Where is the problem and how can this be corrected?
I want to alter a series of variables from a loop, but the following code is not working:
a: 10 b: 20 c: 30 print reduce [a b c] ; output is 10 20 30 as expected varnames: [a b c] ; make a series of variables foreach i varnames [ ; loop to convert each to 0 i: 0 ] print "After conversion loop: " print reduce [a b c] ; values are still 10 20 30 (expected 0 0 0)
After running this code, I'd expect the values of
c to be changed, but they're not:
>> print reduce [a b c] 10 20 30
Where is the problem?
( Loads of photos and four videos )
I want to get values from 2 series into one but it is not working:
I have 2 series:
a: [1 2 3] b: [4 5 6 7]
I want to get all values in one list, so that I can access them as allv/1, allv/2... allv/7.
Following is not working since it makes a series of series and not series of values:
allv: [a b] print allv ; => prints all 6 values, but following do not work: print allv/1 ; => gives a (desired is 1) print allv/2 ; => gives b (desired is 2) print allv/3 ; => gives none (desired is 3)
I tried following function to combine values in one series:
mycombine: function [ll][ temp:  foreach l ll [ repeat i length? l [ temp: append temp l/:i ] ] temp] mycombine [a b]
But above gives error:
*** Script Error: length? does not allow word! for its series argument *** Where: length? *** Stack: rncombine
The series has got converted into word and is not working.
How can I solve this?
I have strings in a
namelist, that correspond to variables as well as field names in the application.
The function should read strings from namelist, add an 'f' to get field_names, and then put variable values in corresponding fields.
I tried following code, that does not give any error, but also does not work:
namelist: ["var1" "var2"] var1: 5 var2: 10 process: [ repeat i length? namelist [ (to-set-path compose rejoin [namelist/:i "f/text"] (to-word namelist/:i)) ] ] lay: layout [ text "Values to appear here: " var1f: field "a" var2f: field "b" button "Click" [do process] ] view lay
I want to remove all characters in a string except:
On linux command line, using
sed I would do this:
$ echo "testing-#$% yes.no" | sed 's/[^-_.a-zA-Z0-9 ]//g'
How can I achieve the same effect in Red language with PARSE? I looked at:
However, I could not codify it. I tried:
>> parse "mystring%^&" [#a - #z #A - #Z #0 - #9] == false >> parse "mystring%^&" [#a-#z#A-#Z#0-#9] == false
I am trying following code to read values from a list to be put into field elements which are also placed in another list:
Red [needs: view] view [ text "N1:" ff: field "" text "N2:" gg: field "" do [fldlist: [ff gg] vv: 5 ww: 10 varlist: [vv ww] ] button "Click" [ repeat i (length? varlist) [to-set-path to-word fldlist/i/text: varlist/:i] ] ]
However, it is not working. The error is:
*** Script Error: path fldlist/i/text: is not valid for none! type *** Where: set-path *** Stack: view do-events do-actor do-safe to-set-path to-word
I also tried
(:i) instead of just
i but it is not working. Where is the problem and how can it be solved? Thanks for your help.
Adventurer! Our fellowship of Necropoli Centauri Voyagers returns with the brand-new Bundle of Lamentations +2, our second offer featuring the weird-fantasy tabletop roleplaying game Lamentations of the Flame Princess. With a heavy-metal attitude and explicit non-work-safe illustrations, LotFP presents a horrific, ultra-violent twist on fantasy gaming. But for fearless gamers who are over 18 and have strong stomachs, the Lamentations line presents some of the hobby's most imaginative work from leading designers. This new LotFP collection (following last July's first spectacular offer, our top seller of 2016) includes .PDF ebooks of many recent award-winners like Broodmother Skyfortress, Blood in the Chocolate, and the amazing Veins in the Earth.
For just US$14.95 you get all eight titles in our Weird Starter Collection (retail value $62.50) as DRM-free .PDF ebooks:
I am trying to print out text from all GUI elements in following code:
sentlist: ["A" "B" "C"] main: function [slist] [ view collect [ repeat i length? slist [ keep compose [ text (slist/:i) field "" return ] ] keep [button "Printall" [ repeat i (2 * length? slist)[ print face/parent/pane/(i)/text ] ] ] ] ] (main sentlist)
It runs all right without any error and
text elements' text are properly printed out, but for
fields, only last field's entry is printed out for each field. Where is the problem and how can it be corrected? Thanks for your help.
I am trying to create a panel with dynamically created gui elements:
sentlist: ["A" "B" "C"] main: function [slist] [ view collect [ keep [below] repeat i length? slist [ keep[ text slist/i ; THIS STEP IS NOT WORKING field "" ] ] ] ] (main sentlist)
A series of strings is sent to the function for putting text labels from it. The GUI window/panel is opening all right but text elements do not have any label on it. Where is the problem and how can it be solved? Thanks for your help.
I am using following code to find products of 2 series of numbers and then to find sum of these products:
make-row: func [ compose [ t1: text "N1:" f1: field t2: text "N2: " f2: field t3: text "Product: " t4: text "" b: button "Get product" [ x: face/extra/2/text y: face/extra/4/text z: (to-integer x) * (to-integer y) face/extra/6/text: rejoin [z]] do [b/extra: reduce [t1 f1 t2 f2 t3 t4]] ] ] view compose [ (make-row) return (make-row) return b: button "Calculate" [t2/text: "..to be given"] t1: text "Sum of products:" t2: text "" ; NEED TO GET SUM OF ALL PRODUCTS IN ABOVE ROWS. ]
The first part is working all right - The products are being calculated properly. But how can I access these individual products to find sum of products? I could not find any way since the rows are not really objects whose public variables or methods/functions I may be able to access. How can this be solved? Thanks for your help.