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 - freetrav

Pages: [1] 2 3
1
QB64 Discussion / Re: I cannot type single or double quotes
« on: November 22, 2021, 10:13:30 am »
Great. Problem solved: i had to install and use the US keyboard instead of US international. Thanks!

On the US-International keyboard, the apostrophe and quote key is a 'dead' key - that is, it doubles as the acute and umlaut diacritic marks, so that if you type (for example) " then a, you'll get รค. To get the apostrophe or quote, press the key, followed by space.

If QB64 doesn't honor the system settings for keyboard and/or code page, you may get anomalous results - but I never had a problem with older versions.

2
QB64 Discussion / Re: Text to Speech: PowerShell coding assistance, please
« on: December 21, 2020, 02:33:25 pm »
@GTC

Always glad to see someone else on the forum using PowerShell to do stuff. I love PowerShell.

I swear by PowerShell. I swear at VBScript.

3
QB64 Discussion / Re: Text to Speech: PowerShell coding assistance, please
« on: December 21, 2020, 11:19:02 am »
Thank you very much for the reply and suggestions.

when I click that link I get "404: Page Not Available"

I'd have to study up on that. I was hoping that possibly a line or two could be simply added to Prithak's original code snippet.

Link is fixed; I didn't see that the automatic parser included the semicolon (;) as part of the URL. Sorry about that. :)

4
QB64 Discussion / Re: Text to Speech: PowerShell coding assistance, please
« on: December 21, 2020, 07:49:16 am »
In an old and closed thread here:

https://www.qb64.org/forum/index.php?topic=3383.msg126966#new

... Prithak gave us a neat little demo of how to use PowerShell to voice text strings:

Code: QB64: [Select]
  1.    
  2.         INPUT "Enter text: "; text$
  3.         SHELL _HIDE "Powershell -Command " + CHR$(34) + "Add-Type -AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('" + text$ + "');" + CHR$(34)


Using that code, I want to change the default voice and I gather that I have to incorporate this "method" but I am seriously ignorant of OO programming technique -- especially in regard to how it maps to QB64 code --  so if someone would show me how to incorporate the following Select.Voice code into Prithak's example, then I will be very grateful.

SpeechSynthesizer.SelectVoice("Microsoft David Desktop")
You will have to write out a PowerShell script and then invoke it. The PowerShell code you need is
Code: [Select]
Add-Type -AssemblyName System.Speech
$voice = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$voice.SelectVoice("Microsoft David Desktop")
$voice.Speak("Take that, Goliath!")

The .NET SpeechSynthesizer class also supports SSML (Speech Synthesis Markup Language); I wrote an article about using it (in connection with a ficlang) at http://www.freelancetraveller.com/features/tbb/ssml.html; the article also covers basic speech synthesis in PowerShell.

(For what it's worth, I think you'd be better off directly calling .NET from QB64, if that's possible.)

5
QB64 Discussion / Re: old software for qb4.5
« on: October 15, 2020, 01:37:32 pm »
Yeah, 7zip opens pretty much all of the common Windows and *ix archive formats, and many of the less-common ones. The page at 7-zip.org lists the formats it supports:

Quote
  • Supported formats:
    • Packing / unpacking: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
    • Unpacking only: AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR and Z.

6
Is that what you guys are looking for, an Immediate Window?

So you can test a snippet of code.

That's part of it; another part of it is for scribbling up quick-and-dirty one-offs - the kind of thing that other people might do in bash, powershell, python, windows batch, etc.

7
There's no +1 button on the forums!  I need a +1 button!

8
QB64 Discussion / Re: Update windows 10
« on: August 16, 2019, 11:05:12 am »
I am glad you solved the problem but you said, "The same program in Qbasic, using dosbox, does not give error."

How could this be? I was lead to believe you had a general file access problem and Windows 10 does shut down access to root directory...

DOSBox drives don't correspond directly to host OS drives; if the DOSBox C: is mapped to C:\USERS\JOE\DOCUMENTS\DOSDRIVE, then QBASIC OPEN "C:\WINDOWS\FOO.TXT" FOR INPUT AS #1 will actually be accessing C:\USERS\JOE\DOCUMENTS\DOSDRIVE\WINDOWS\FOO.TXT. So, in DOSBox, you won't actually be accessing the root of the Windows C: drive, and thus won't get intercepted and denied.

9
QB64 Discussion / Re: HEBREW in QB64 console?
« on: August 13, 2019, 10:22:24 am »
Well, you can start with REVERSE$ from Rosetta Code.

Code: QB64: [Select]
  1. FUNCTION reverse$(a$)
  2.    b$ = ""
  3.    FOR i = 1 TO LEN(a$)
  4.       b$ = MID$(a$, i, 1) + b$
  5.    NEXT i
  6.    reverse$ = b$

Then, add enough spaces on the left to push it out to the console width to right-justify it so that it will look right.

10
QB64 Discussion / Re: HEBREW in QB64 console?
« on: August 13, 2019, 09:59:14 am »
Why not write a PrintHebrew routine that takes the string and reverses it, then pads it out to the console width to right-align it?

11
QB64 Discussion / Re: Wiki wrong
« on: July 25, 2019, 12:56:10 pm »
Steve, I understand how it actually works (your explanation); my concern is that this is "broken as designed" because the behavior is unpredictable unless you know the actual values being passed at any given call. I'm not asking for strong typing (a la Pascal) - but I should be able to determine what will happen on a call by inspection, without having to know what the actual value is at run time. If I have a sub

Code: QB64: [Select]
  1. SUB DoSomething(Ecks)
  2.    ...

and DoSomething expects Ecks to be a numeric type - integer, single, or double - and it tries to modify Ecks mathematically, there's nothing stopping me from writing the bogus code

Code: QB64: [Select]
  1. Em = "A String"
  2. DoSomething Em

Which should blow up in my face because I can't do math on "A String".

Arguably, it's my responsibility as codemonger to do input validation before passing data to subroutines/functions - but there's a difference between doing the basic bookkeeping of variable and parameter types versus validating e.g., that the input has only valid characters, matches a (regex) pattern, is within a specified numeric range, etc.

I contend that a compiler that doesn't do the bookkeeping has to be considered 'broken as designed'. Especially if I want to write libraries for general use, where I have NO control over what's passed in. Or use those created by others, which more often than not are poorly documented if documented at all.

12
QB64 Discussion / Re: Wiki wrong
« on: July 25, 2019, 11:02:35 am »
Hmmm... I perceive possible issues with that. Consider:

SUB AddOne (Ecks AS INTEGER)
   Ecks = Ecks + 1
END SUB

SUB DIV2 (Ecks)
   Ecks = Ecks / 2.0
END SUB


If I call AddOne:

Q=3.5
AddOne Q

I would expect/want an error to be thrown, because Q can't be demoted to INTEGER. Ideally, this can (and should) be detected at compile time. If I call DIV2:

Q%=5
DIV2 Q

I would expect/want an error to be thrown, because the result of calling DIV2 can't be demoted to INTEGER (signalled by the % suffix to the varname). Ideally, this should issue a WARNING at compile time, because of the possible type mismatch; if the warning is ignored, the error should be thrown at run time. If I call either:

AddOne 3
DIV2 4

I would expect/want an error to be thrown, because the SUB is trying to modify a parameter that is not a variable. Ideally, the errors should be caught at compile time. This is why some sort of indicator (like Pascal's VAR parameters) should be used.

13
QB64 Discussion / Re: Wiki wrong
« on: July 25, 2019, 10:22:11 am »
I fundamentally do not have a problem with a procedure/subroutine or function modifying its arguments, but I think that where that is permitted, there needs to be some indication in the declaration that a parameter may be modified - for example, what would happen if in the SUB ADD_UP I had called it as "ADD_UP 1,2,answer"?

This is the difference between 'call by value' and 'call by reference'. In Pascal, call by reference is indicated by prefixing the parameter name with VAR, e.g., Procedure AddUp(var Answer:Integer; first, second: integer;); ...

14
Quote
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration
Is it true? I strongly disagree.

Not only do I disagree about 'mutilation', I emphatically contend that making such a statement - even if the BASIC-exposed student does have subsequent problems learning good programming habits - says more about the teacher than about the student, and still more about the language-bigotry of the person making the statement.

15
QB64 Discussion / Re: Brain damage! Alert BASIC is Toxic!
« on: June 07, 2019, 03:07:37 pm »
While there may be something to what the article says, I question whether the emphasis may be in the wrong place - in my experience, it's not that BASIC or COBOL is a crappy language (although they both do have 'features' that encourage poor practice); it's that most BASIC (or COBOL) instructors teach poorly. Even if you're using a low-end BASIC like Apple's Integer BASIC or AppleSoft BASIC, or Commodore's BASIC on the PET (rather than a mid-BASIC like GW-BASIC or BetterBASIC, or a high-end BASIC like QB/QB64, Visual BASIC, or CA-REALIZER), you can write well-structured, more-or-less modular code. However, you have to be taught to think about the problem in the structured way, rather than the sort of ad-hockery that people accuse BASIC (rather than BASIC instructors) of encouraging.

(I say that there may be something to what the article says, because I've experienced it - it doesn't matter what syntax I'm using, be it C, Pascal, BASIC, PowerShell, LISP, APL, or whatever; I have a tendency to "write my code in Pascal". This is a very pronounced tendency; when I took a 'survey of programming languages' course in college, one of the languages surveyed was APL. When I handed in the APL project, the instructor returned it with full marks, but also a written comment, "You're a Pascal programmer, aren't you?". He could tell from the way I wrote the APL, even though I used proper APL 'idioms' and shortcuts.)

Pages: [1] 2 3