Ya want to learn do ya?
Translating is an art. Knowing how to speak in another lanaguage and converting it to another language. This is a list of posts on the forums that deal with language conversion: Programmming Language of C++ converted to PowerBasic.
This list is not everything that has been posted. But a good place to start to answer those questions on how to do it.
The oldest post I was able to bring up is dated: Apr 12th, 2000
Porting questions.. (http://www.powerbasic.com/support/pbforums/showthread.php?t=2097)
The place to start is in PowerBasic Help.
Under Help > Data Types > Comparative Data Type > C/C++ (also listed is Delphi, Visual Baisc 6)
Tom Hanlin has said:
"Programmer" is a verb, not a noun: it's a process of learning.
C passes all values BYVAL. In the case where a C program is passing a pointer to a value, then, it may make sense to translate this into PowerBASIC in either of two ways: as a BYVAL pointer, or as the actual value BYREF. For example, if there's a C parameter "LPDWORD lpd", you might reasonably translate this to PB either as "BYVAL lpd AS DWORD PTR" or as "BYREF d AS DWORD". It just depends on which is more convenient for you.
int64 is not a standard C type, although it's easy to guess that they mean a 64-bit integer, which is a QUAD in PowerBASIC. PB doesn't have an unsigned 64-bit integer type, but QUAD should suffice for that as well in most cases, in the same way you can generally get away with using a LONG instead of a DWORD for a HANDLE value.
When dealing with C, intrinsic types are in lowercase. Defined types are in all caps by convention. C is case-sensitive. Integer-class types can take a modifier of "signed" or "unsigned", and are signed by default. The size of a type may vary according to the compiler but, typically, the following applies for DOS and Windows C implementations:
"char" (or "signed char"): a signed byte. The PB translation may be BYTE or STRING * 1 depending on the situation.
"unsigned char": a byte. The PB translation will usually be BYTE, although there may be cases where STRING * 1 will be appropriate. You will frequently see defined C types that mean the same thing, such as "UCHAR" or "BYTE".
"int" (or "signed int"): a signed integer. If it's 16-bit C code, the PB translation is INTEGER. If it's 32-bit C code, the PB translation is LONG.
"unsigned int": an unsigned integer. If it's 16-bit C code, the PB translation is WORD. If it's 32-bit C code, the translation is DWORD. Often defined in C as a "UINT" or "DWORD" type.
"short": a signed 16-bit integer. In PB, INTEGER. Sometimes seen in C as the defined type "SHORT".
"long": a signed 32-bit integer. In PB, LONG. Sometimes seen in C as the defined type "LONG".
C arrays are defined by the number of elements and are indexed from zero:
"char foo[32]" translates to DIM foo(0 TO 31) AS BYTE or, more likely,
DIM foo AS STRING * 32, depending on the context.
A UINT is a DWORD. A DWORD is interchangeable with any pointer type, although there's no particularly good reason to prefer a DWORD when you can use the appropriate pointer type.
The LP prefix means "pointer". A C long is a PowerBASIC LONG. So, you're looking at a generic 32-bit return value-- use a DWORD or a LONG-- and understand that the result is actually a pointer to a LONG value. (Because FUNCTION..AS LONG PTR isn't valid syntax, but you can always return a LONG PTR as a LONG or a DWORD, since the data types are effectively the same under 32-bit Windows).
The common Windows SDK type, BOOLEAN, is actually a LONG (4-byte signed value). As noted, "1" is the "most true" value for C, whereas "-1" is the "most true" value for BASIC. With C or with BASIC, though, any non-zero value is considered "true".
About type names-- When you see something in C like this:
typedef struct tagATMSystem {
the best translation into a PB type is like this:
I'm not sure what that byplay was about a LONG being ok for a value from 0-255. If you mean, is it ok to translate a "char" to a "LONG", no-- these are different-size values. A "char" should translate as either a "STRING * 1" or as a "BYTE", depending on whether you want to consider it as a string or a numeric value.
Enoch, BOOL is not a 2-byte integer, unless you're porting from 16-bit C code. With 32-bit C, the "integer" and "BOOL" types translate to a PowerBASIC "LONG" (a 4-byte integer type).
C strings defined by "char *" should be ASCIIZ, not STRING, in PB.
...Tom Hanlin, PowerBASIC Staff
Opinions expressed may not be those of my employer or myself
What I have seen in C++ to PB in translation : sometimes it is easy to take what is on the left and move it to the right when converting to PowerBasic. I see it as a musical chairs.
Discussion on the languages:
Advantages over C/C++? (http://www.powerbasic.com/support/pbforums/showthread.php?t=7147)
The following is the list of Forums Articles:
Help converting C to PB for a DLL (http://www.powerbasic.com/support/pbforums/showthread.php?t=2225)
HANDLE HWND and others... (http://www.powerbasic.com/support/pbforums/showthread.php?t=2764)
C to PB Conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=2696)
C to PB conversion problem (http://www.powerbasic.com/support/pbforums/showthread.php?t=3793)
PB conversion of C/C++ SDK (http://www.powerbasic.com/support/pbforums/showthread.php?t=2927)
Specific C-porting questions (http://www.powerbasic.com/support/pbforums/showthread.php?t=3489)
C port of Type structure (http://www.powerbasic.com/support/pbforums/showthread.php?t=3585)
Help with some C code to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=3971)
Converting a C++ statement (http://www.powerbasic.com/support/pbforums/showthread.php?t=4321)
Accessing C array type from PB - looks easy enough? (http://www.powerbasic.com/support/pbforums/showthread.php?t=4424)
data conversion from a "C" struct (http://www.powerbasic.com/support/pbforums/showthread.php?t=4675)
translate C enum to PowerBasic (http://www.powerbasic.com/support/pbforums/showthread.php?t=5001)
C to PowerBasic translation (http://www.powerbasic.com/support/pbforums/showthread.php?t=5017)
C Conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=5371)
Translation from C++ to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=5403)
Would anyone know how to convert this (http://www.powerbasic.com/support/pbforums/showthread.php?t=5416)
C-2-PB Question Please! (http://www.powerbasic.com/support/pbforums/showthread.php?t=5549)
C construct help please (http://www.powerbasic.com/support/pbforums/showthread.php?t=6302)
Help in C DECL to PB declartion... (http://www.powerbasic.com/support/pbforums/showthread.php?t=6729)
Opaque structures: equiv. in PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=6879)
Another C-to-PB datatype question (http://www.powerbasic.com/support/pbforums/showthread.php?t=6901)
Porting C++ code (http://www.powerbasic.com/support/pbforums/showthread.php?t=7097)
Help needed !!! (http://www.powerbasic.com/support/pbforums/showthread.php?t=7210)
Porting C to PB - How do I cast a handle to a type? (http://www.powerbasic.com/support/pbforums/showthread.php?t=7600)
C to PB - Shifted Values in Constants (http://www.powerbasic.com/support/pbforums/showthread.php?t=7608)
C Declaration Conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=7674)
More C to PB Declarations Conversion... (http://www.powerbasic.com/support/pbforums/showthread.php?t=7680)
C Declaration to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=7705)
Simple SendMessage Question (http://www.powerbasic.com/support/pbforums/showthread.php?t=7768)
C Structure Definition in PowerBasic (http://www.powerbasic.com/support/pbforums/showthread.php?t=7772)
C to PB DataType Cross Reference (http://www.powerbasic.com/support/pbforums/showthread.php?t=8122)
Some C++ hearder conversion help (http://www.powerbasic.com/support/pbforums/showthread.php?t=8264)
C calling woes (http://www.powerbasic.com/support/pbforums/showthread.php?t=8292)
Some quick ideas on a CPP port (http://www.powerbasic.com/support/pbforums/showthread.php?t=8399)
Missing parts (http://www.powerbasic.com/support/pbforums/showthread.php?t=8734)
C Header Conversion Problem (http://www.powerbasic.com/support/pbforums/showthread.php?t=8894)
convert C declaration to PowerBasic (http://www.powerbasic.com/support/pbforums/showthread.php?t=9196)
C++ to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=9450)
Using REP INSW (http://www.powerbasic.com/support/pbforums/showthread.php?t=9558)
C++: char * & int* = PB: ???? (http://www.powerbasic.com/support/pbforums/showthread.php?t=9809)
a C to PB type conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=10030)
Converting C++ to PB/Win (http://www.powerbasic.com/support/pbforums/showthread.php?t=10395)
Converting C++ code to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=10617)
C to PBWin Conversion Problem (http://www.powerbasic.com/support/pbforums/showthread.php?t=10674)
HttpFilterProc C++ declaration conversion to PowerBASIC (http://www.powerbasic.com/support/pbforums/showthread.php?t=10779)
Convert from C (http://www.powerbasic.com/support/pbforums/showthread.php?t=10963)
Need help porting a couple of C functions (http://www.powerbasic.com/support/pbforums/showthread.php?t=11206)
Translate this c header into inc for PBWin (http://www.powerbasic.com/support/pbforums/showthread.php?t=11648)
Strings & C++ DLL (http://www.powerbasic.com/support/pbforums/showthread.php?t=11765)
declaring dll function with return value (http://www.powerbasic.com/support/pbforums/showthread.php?t=12172)
C type Conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=12181)
Tiny problem converting C++ to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=12472)
C# to PB? (http://www.powerbasic.com/support/pbforums/showthread.php?t=12634)
Need Help to convet C to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=12812)
Converting C Structure to PB UDT (http://www.powerbasic.com/support/pbforums/showthread.php?t=12925)
Please help: Translation syntax from C++ to PBWin (http://www.powerbasic.com/support/pbforums/showthread.php?t=13008)
C conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=13068)
C Convertion (http://www.powerbasic.com/support/pbforums/showthread.php?t=13072)
UDTs, UNIONS, C-code xlation... (http://www.powerbasic.com/support/pbforums/showthread.php?t=13229)
Help with C to PB 1-liner? (http://www.powerbasic.com/support/pbforums/showthread.php?t=13271)
hWrite problem (http://www.powerbasic.com/support/pbforums/showthread.php?t=13398)
C/C++ help (http://www.powerbasic.com/support/pbforums/showthread.php?t=13482)
C2PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=13515)
calling a C dll (http://www.powerbasic.com/support/pbforums/showthread.php?t=13542)
PB declaration of a C function (http://www.powerbasic.com/support/pbforums/showthread.php?t=13730)
Calling a C function correctly... (http://www.powerbasic.com/support/pbforums/showthread.php?t=13949)
C to PB help (http://www.powerbasic.com/support/pbforums/showthread.php?t=14019)
Help converting C struct to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=14055)
C to PB help (http://www.powerbasic.com/support/pbforums/showthread.php?t=14077)
Translating C Header files (http://www.powerbasic.com/support/pbforums/showthread.php?t=14265)
Translating C to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=14271)
Quick C++ converion (http://www.powerbasic.com/support/pbforums/showthread.php?t=14325)
Help converting this C structure? (http://www.powerbasic.com/support/pbforums/showthread.php?t=14339)
C++ To PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=14389)
C++ translation question.. (http://www.powerbasic.com/support/pbforums/showthread.php?t=19852)
C/C++ import libraries for PBDLL - Revisited (http://www.powerbasic.com/support/pbforums/showthread.php?t=19859)
Casting ? (C Conversion)Again: C to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=20411)
c header to PB converter in-progress (http://www.powerbasic.com/support/pbforums/showthread.php?t=19935)
C2PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=19998)
pointers from C++ to Pb (http://www.powerbasic.com/support/pbforums/showthread.php?t=20062)
Need Assistance from C Programmers (http://www.powerbasic.com/support/pbforums/showthread.php?t=20100)
Problems with bitshifting (http://www.powerbasic.com/support/pbforums/showthread.php?t=20158)
PB to C Declaration Question.. (http://www.powerbasic.com/support/pbforums/showthread.php?t=20361)
Some port help... (http://www.powerbasic.com/support/pbforums/showthread.php?t=20427)
C Conversion - Please Help!!! (http://www.powerbasic.com/support/pbforums/showthread.php?t=20456)
C and Far Pointers (http://www.powerbasic.com/support/pbforums/showthread.php?t=20610)
PB Equivevalent to some basic C/C++ Code? (Pointer to an array of chars) (http://www.powerbasic.com/support/pbforums/showthread.php?t=20624)
C typedef to PB Type question (http://www.powerbasic.com/support/pbforums/showthread.php?t=20681)
C to PB translation (http://www.powerbasic.com/support/pbforums/showthread.php?t=21051)
Help needed, C -> PB translation (http://www.powerbasic.com/support/pbforums/showthread.php?t=21139)
Type problem – C++ to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=21351)
Namespaces c++/PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=21355)
c to pb equivilant (http://www.powerbasic.com/support/pbforums/showthread.php?t=21399)
Again, C to Pb... (http://www.powerbasic.com/support/pbforums/showthread.php?t=21528)
Injection (?) Question.... (http://www.powerbasic.com/support/pbforums/showthread.php?t=21569)
C Declaration to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=21594)
Win HLLAPI C to PB Assistance (http://www.powerbasic.com/support/pbforums/showthread.php?t=21625)
C to Pb (again...) (http://www.powerbasic.com/support/pbforums/showthread.php?t=21647)
Convert C to PowerBasic (http://www.powerbasic.com/support/pbforums/showthread.php?t=21733)
Converting char* (http://www.powerbasic.com/support/pbforums/showthread.php?t=21756)
C++ to Powerbasic - USB2 programming with cypress CYUSB driver (http://www.powerbasic.com/support/pbforums/showthread.php?t=21799)
"Elegant" C into PB? (http://www.powerbasic.com/support/pbforums/showthread.php?t=21804)
Back to BASIC (http://www.powerbasic.com/support/pbforums/showthread.php?t=21840)
Returning QUAD for C++ compilers (http://www.powerbasic.com/support/pbforums/showthread.php?t=21909)
Bizzare 'C' UDT struct query... (http://www.powerbasic.com/support/pbforums/showthread.php?t=22039)
Help Converting C Header (http://www.powerbasic.com/support/pbforums/showthread.php?t=22049)
C# and PB string (http://www.powerbasic.com/support/pbforums/showthread.php?t=22122)
C# and PB (part II) (http://www.powerbasic.com/support/pbforums/showthread.php?t=22123)
C# and PB (example) (http://www.powerbasic.com/support/pbforums/showthread.php?t=22132)
Trouble converting from C to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=22192)
Trouble converting from C to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=22225)
Again: C conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=22238)
C translation arrays (http://www.powerbasic.com/support/pbforums/showthread.php?t=22466)
C To PowerBASIC Pointer Conversions (http://www.powerbasic.com/support/pbforums/showthread.php?t=22503)
Converting C to Pb (http://www.powerbasic.com/support/pbforums/showthread.php?t=22511)
A Question about conversion C to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=34736)
A Question about convert c to pb (http://www.powerbasic.com/support/pbforums/showthread.php?t=34800)
C to Basic-- #Define (http://www.powerbasic.com/support/pbforums/showthread.php?t=34863)
Using C Runtime Library With PBWin (http://www.powerbasic.com/support/pbforums/showthread.php?t=34989)
Translating a C++ class definition to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=35113)
Need quick hand with C to PB convert (http://www.powerbasic.com/support/pbforums/showthread.php?t=36113)
Help Converting C++ DLL to PB - Data Types Issue (http://www.powerbasic.com/support/pbforums/showthread.php?t=36393)
Convert C Macro to Declare Equates (http://www.powerbasic.com/support/pbforums/showthread.php?t=36736)
C conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=36933)
Tools to aid in converting C to PowerBASIC (http://www.powerbasic.com/support/pbforums/showthread.php?t=37399)
Help with 'C' conversion please? (http://www.powerbasic.com/support/pbforums/showthread.php?t=37720)
C conversion question (http://www.powerbasic.com/support/pbforums/showthread.php?t=39202)
C to PB Help needed (http://www.powerbasic.com/support/pbforums/showthread.php?t=39785)
More C Help needed (http://www.powerbasic.com/support/pbforums/showthread.php?t=39947)
C to Pb - NULL (http://www.powerbasic.com/support/pbforums/showthread.php?t=40647)
Help with C++ conversion (http://www.powerbasic.com/support/pbforums/showthread.php?t=40968)
Convert c style text (http://www.powerbasic.com/support/pbforums/showthread.php?t=41939)
Slack space need to line up PB and C++ UDT (http://www.powerbasic.com/support/pbforums/showthread.php?t=42720)
C conversion help: Starburn API (http://www.powerbasic.com/support/pbforums/showthread.php?t=42896)
Question to chunk UDT conversion from C++ (http://www.powerbasic.com/support/pbforums/showthread.php?t=43141)
Help Needed Interpreting C Requirements (http://www.powerbasic.com/support/pbforums/showthread.php?t=43868)
Help needed translating a C statement to a DECLARE (http://www.powerbasic.com/support/pbforums/showthread.php?t=44586)
Union IN a structure - ?? (http://www.powerbasic.com/support/pbforums/showthread.php?t=45399)
Help translate this c code.. (http://www.powerbasic.com/support/pbforums/showthread.php?t=46551)
C function translation (http://www.powerbasic.com/support/pbforums/showthread.php?t=46723)
C++ to PB again (http://www.powerbasic.com/support/pbforums/showthread.php?t=50550)
Struggling to convert MSDN C++ to PB (http://www.powerbasic.com/support/pbforums/showthread.php?t=52277)
what is the best way to translate "&=~" in pb? (http://www.powerbasic.com/support/pbforums/showthread.php?t=52901)
What is the best way to translate << (http://www.powerbasic.com/support/pbforums/showthread.php?t=52915)
Byte Order of Elements of a C Structure (http://www.powerbasic.com/support/pbforums/showthread.php?t=53292)
Are C Enumerations always Long data type (http://www.powerbasic.com/support/pbforums/showthread.php?t=53298)
Help with overlaid structures C++ to PB please (http://www.powerbasic.com/support/pbforums/showthread.php?t=53515)
How to translated into PBWin? (http://www.powerbasic.com/support/pbforums/showthread.php?t=53794)
How can I do this in PB? There is no function Pow() (http://www.powerbasic.com/support/pbforums/showthread.php?t=53809)
Asked ; Conversion C declarations into PB declarations syntax (http://www.powerbasic.com/support/pbforums/showthread.php?t=53888)
C++ to PowerBASIC conversion - A little help. (http://www.powerbasic.com/support/pbforums/showthread.php?t=54665)
P.S. can this be made a sticky???