Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - phred

Pages: [1]
1
Quote
Why strings for numeric input?

Well, I'm pretty sure there may have been a reason but I can't remember it now, or consistency; something like that. Pretty sure.

phred

2
Something I worked on a couple of years ago modeling Microsoft's function, which may or may not already be up here.
phred

Code: QB64: [Select]
  1. a$ = "Visit Microsoft!" 'original string
  2. b$ = "microsoft" 'search string
  3. c$ = "W3Schools" 'replacement string
  4.  
  5. a$ = "001x002X003x004x005"
  6. b$ = "x"
  7. c$ = "z"
  8.  
  9. 'f$ = "-1"
  10. 'f$ = "0"
  11.  
  12. d$ = replacesub$(a$, b$, c$, d$, e$, f$, g$)
  13.  
  14. FUNCTION replacesub$ (expression$, find$, replacewith$, start$, count$, compare$, exact$)
  15.     IF start$ = "" THEN start = 1 ELSE start = VAL(start$)
  16.     IF count$ = "" THEN count = -1 ELSE count = VAL(count$)
  17.     IF compare$ = "" THEN compare = 0 ELSE compare = VAL(compare$) 'default is for case sensitve
  18.  
  19.     IF find$ = "" OR replacewith$ = "" OR count = 0 THEN replacesub$ = expression$: EXIT FUNCTION
  20.     IF expression$ = "" OR start > LEN(expression$) THEN replacesub$ = "": EXIT FUNCTION
  21.  
  22.     IF exact$ <> "" THEN 'pad values to isolate whole word
  23.         find$ = " " + find$ + " "
  24.         replacewith$ = " " + replacewith$ + " "
  25.     END IF
  26.  
  27.     working$ = expression$
  28.     start2 = start
  29.  
  30.     rl = LEN(find$)
  31.     tally = 0
  32.     IF compare <> 0 THEN
  33.         working$ = LCASE$(working$)
  34.         find$ = LCASE$(find$)
  35.     END IF
  36.     rf = INSTR(start, working$, find$)
  37.     DO WHILE rf
  38.         tmp1$ = MID$(working$, 1, rf - 1) 'copy mid$ from start to beginning of found replacement
  39.         tmp2$ = MID$(working$, rf + rl) 'then copy from end of replacement to end of the text string (rf + rl)
  40.         working$ = tmp1$ + replacewith$ + tmp2$
  41.         start = rf
  42.         rf = INSTR(start, working$, find$)
  43.         tally = tally + 1: IF tally = count THEN EXIT DO
  44.     LOOP
  45.     working$ = MID$(working$, start2)
  46.     replacesub$ = working$
  47.  
  48.  
  49. 'VB - Replace$(expression, find, replacewith[, start[, count[, compare]]])
  50. 'Arguments
  51.  
  52. 'expression
  53. '    Required. String expression containing substring to replace.
  54. 'find
  55. '    Required. Substring being searched for.
  56. 'replacewith
  57. '    Required. Replacement substring.
  58. 'start
  59. '    Optional. Position within expression where substring search is to begin. If omitted, 1 is assumed. Must be used in conjunction with count.
  60. 'count
  61. '    Optional. Number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Must be used in conjunction with start.
  62. 'compare
  63. '    Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, the default value is 0, which means perform a binary comparison.
  64. '
  65. 'if find = "" or replacewith = "" or count = 0 then return expression
  66. 'if expression = "" or start > len(expression) return ""
  67.  

3
QB64 Discussion / Re: QB(64) vs. (Open)COMAL?
« on: January 02, 2019, 11:00:04 am »
The string functions resemble True Basic's, (and Decimal Basic's), where a$(1:5) returns the first 5 characters.

4
QB64 Discussion / Re: How big is yours?
« on: November 28, 2018, 11:13:01 am »
I learned to type on an IBM Selectric in a high school business class while I was learning the intricacies of punch cards and COBOL.  The typing ended up being a better time investment than the punch cards did and yes, that ball could fly!

5
InForm-based programs / Re: [InForm] Windows 7's run dialog clone
« on: February 26, 2018, 03:39:50 pm »
That did the trick, works like a champ now!

6
InForm-based programs / Re: [InForm] Windows 7's run dialog clone
« on: February 26, 2018, 02:09:59 pm »
Can't get it to compile under Windows 10, I keep getting  Library not found in line 15 of ***\inform.ui included on current line, although in the file manager I can see that it's there where it claims it can't find it.  If I open the inform.ui file it says it can't find Library "falcon. "  Does this by chance require the latest version of QB64, I'm still using 1.1 because I'm lazy.

7
InForm-based programs / Re: [InForm] Windows 7's run dialog clone
« on: February 26, 2018, 11:10:44 am »
I'm going to try this in Windows 10 since Microsoft thoughtfully removed the "Run" dialog.

9
QB64 Discussion / Re: QB64 offline documentation package from Wikipedia ..
« on: February 25, 2018, 12:00:48 pm »
Upload speed is a little over 3 Mbps so should be okay, I'm trying again.
Looks like it goes up, it uploads for about 6 seconds, says "waiting for QB64,org", then a couple of seconds it shows:

"Your attachment couldn't be saved. This might happen because it took too long to upload or the file is bigger than the server will allow.
Please consult your server administrator for more information."

10
QB64 Discussion / Re: QB64 offline documentation package from Wikipedia ..
« on: February 24, 2018, 03:13:07 pm »
I've tried several times to send up the zip but it errors out, I would have thought at 2838k it would have been okay, says 20000k max.

11
QB64 Discussion / Re: QB64 offline documentation package from Wikipedia ..
« on: February 24, 2018, 11:26:44 am »
I have a offline copy downloaded January 13th if it'll help anybody.

Pages: [1]